Hi there,
I am writing php to send email containing Chinese text. The chinese displays correctly depending on different mail servers, it seems.
I can read the chinese text if I open the email using webmail on my telco's website (Telstra's Bigpond in Australia) or Yahoo mail. If I look at the same email using MS Outlook then the chinese text is just rubbish.
So I experimented and wrote (VS2008) the code using the Smtp.Client (Microsoft System.Net.Mail ) rather then php. This method gives me the correct chinese text in both webmail and Outlook.
Can someone explain to me what is going on here?
Given I must use php, how do I reproduce smtp.client code in php?
In the php code below how much of the $Header stuff do I actually need?
Sorry for such a long winded question and thanks in advance.
Here is my codes, both php and c# - <?php
-
$charset = "utf-8";
-
$to = "$_POST[EmailAddress]";
-
$subject = "Student Enrollment";
-
$body = "尊敬的家 Welcome to the Sydney";
-
-
//HEADERS
-
$header .= "X-Mailer: Whatever you want\n";
-
$header .= "Return-Path: <someperson@example.com>\n";
-
$header .= "MIME-Version: 1.0\n";
-
$header .= "From:denis@yahoo.com.au\n";
-
$header .= "X-Accept-Language: cn\n";
-
$header .= "Content-Type: text/plain; charset={$charset}\n";
-
$header .= "Content-Transfer-Encoding: 8bit\n";
-
-
if (mail($to,$subject,$body,$header))
-
{
-
echo("<p>A confirmation email has been sent.</p>");
-
}
-
else
-
{
-
echo("<p>We are unable to send you an email.</p>");
-
}
-
?>
-
-
////////////////////////////////
-
-
MailMessage mail = new MailMessage();
-
-
mail.From = new MailAddress("denis@yahoo.com.au");
-
mail.To.Add(address);
-
mail.Subject = subject;
-
mail.Body = body;
-
-
SmtpClient smtp = new SmtpClient("mail.bigpond.com");
-
try
-
{
-
smtp.Send(mail);
-
}
4 6622 Markus 6,050
Recognized Expert Expert
I suspect this is because of PHP's lax handling of Unicode characters. You might try out PHP6 as one of it's main goals is to improve multi-byte and unicode character support.
Mark.
Mark,
Thanks very much for your response.
Unfortunately I don't control what version of php to use.
Since Smtp.Client in the .Net environment works do you think it will work if I write the php using smtp?
I know hardly anything about smtp. I have searched the net about smtp in php and what I have found mentions changing the configuration and seem complicated.
Can you point me to some smtp code which I can use fairly easily?
Thanks
Denis
Dormilich 8,658
Recognized Expert Moderator Expert
a fairly easy (to use and well documented) PHP Mail Script is SwiftMailer, though I didn’t try sending chinese text with it.
Thanks Dormilich.
SwiftMailer looks interesting. I will have a look.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Antonio |
last post by:
With the following page aspx
I try to translate one my page from English to Chinese, using UTF8,
the result Is that the Chinese characters do not come read correctly,
if instead I insert directly the address
http://babelfish.altavista.com/babelfish/trurl_pagecontent?url=http://www.etantonio.it/en/index.aspx&lp=en_zh
into the browser the page he comes shown correctly in Chinese, if i
save it and put it in my site and with the same below...
|
by: pabv |
last post by:
Hello all,
I am having a few issues with encoding to chinese characters and
perhaps someone might be able to assist.
At the moment I am only able to see chinese characters when displayed
as part of a datagrid. When an input textbox is displayed it does not
display chinese characters, but rather the unicode characters stored
in the mssql 2000 server backend.
|
by: Jason Chan |
last post by:
Some chinese characters data (in Big5 encoding) is stored in database.
I tried to display the data in an aspx but the characters cannot display
correctly.
I tried anything I think is related:
- Setting the charset, codepage of the page
- changed the responseEncoding in web.config to Big5
- hardcoded Response.ContentEncoding to 950 (codepage of Big5)
- Change the file encoding to Big5 (in save option)
None of them work.
|
by: nauticalmac |
last post by:
I'm using CDO to send mail to the site owner from ASP pages with forms.
Recently one of my forms is occasionally sending email with what seems
to be an insertion which is replacing the plain text part of the email
with something else. Looking at the server sent email source, the
hacked emails have the following:
This is a multi-part message in MIME format.
------=_NextPart_000_0001_01C60610.91D1FFA0
Content-Type: text/plain;...
|
by: antonyliu2002 |
last post by:
I've set up the virtual smtp server on my IIS 5.1 like so:
1. Assign IP address to "All Unassigned", and listen to port 25.
2. Access Connection granted to "127.0.0.1".
3. Relay only allow "127.0.0.1".
4. Authentication: "Anonymous access" only.
5. Outbound connection listen to TCP 25.
Besides,
| |
by: ... |
last post by:
Hi
I need to send a chr(255) to a serial port. When I send it, through
comm.write (chr(255)) it sends a chr(63) ... in Hex, I write chr(&FF) and it
actually sends chr(&3F) ... why does this happen, and how can I send it
right ?
I'm using vb.net 2005 express with framework 2.0
Thanks for an answear ...
|
by: Andy Lim |
last post by:
Hi all,
In my recent project, my client uses Chinese Star software to type the
articles in chinese (using MS Word), and I need to display these articles
within ASP.NET pages. And, for this very purpose I also installed a copy of
Chinese Star software in my development machine, so I can correctly renders
the doc correctly.
Ussually I just copy the text from the original DOC file they supplied, and
paste it onto a blank ASP.NET page.
|
by: Andy Lim |
last post by:
Hi all,
In my recent project, my client uses Chinese Star software to type the
articles in chinese (using MS Word), and I need to display these articles
within ASP.NET pages. And, for this very purpose I also installed a copy of
Chinese Star software in my development machine, so I can correctly renders
the doc correctly.
Ussually I just copy the text from the original DOC file they supplied, and
paste it onto a blank ASP.NET page.
|
by: Figmo |
last post by:
I'm having a problem working with foreign characters (well....foreign
to me anyway)
I have a textbox control on a form. The font is set to MS Arial
Unicode. If I use the Chinese input method I can type characters
into this box no problem. They display correctly. I can also copy
and paste Chinese characters from web sites into this text box and
they display no problem.
Here is my problem. If I put some Chinese characters in the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |