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#
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#
Code:
<?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); }
Comment