如何在邮件主题中设置umlautü [英] How to set an umlaut ü in the mail subject
问题描述
$ mail = new htmlMimeMail() ;
$ mail-> setTextEncoding(base64);
$ mail-> setHTMLEncoding(base64);
$ mail-> setTextCharset(UTF-8);
$ mail-> setHTMLCharset(UTF-8);
$ mail-> setHeadCharset(UTF-8);
$ mail-> setSMTPParams(mailinglist_smtp_host,mailinglist_smtp_port);
$ mail-> setHtml(test);
$ mail-> setFrom(test@test.nl);
$ mail-> setSubject(ï,ö,ë,ä和é工作,但添加ü它不);
$ recipients [] =me@myhost.nl;
$ mail-> send($ recipients);
&
code> $ mail = new PHPMailer();
$ mail-> IsMail();
$ mail-> FromName ='test';
$ mail-> From ='test@test.nl';
$ mail-> AddAddress(me@myhost.nl);
$ mail-> Subject =ï,ö,ë,ä和é工作,但添加ü它不;
$ mail-> Body =test;
$ mail-> Send();
任何人都可以帮助我找到这个问题的根源和解决方案?
你应该 quoted-printable 编码主题标题。
像这样:
$ mail-> Subject ==?UTF-8?Q? 。 quoted_printable_encode(ï,ö,ë,ä和é工作,但添加ü它不)。 ?=;
PHP中引用的可打印编码: http://www.php.net/manual/en/function.quoted-printable-encode.php
编辑: $ mail-> CharSet =UTF-8;
做了这个工作。
I need to generate German e-mails which contain umlaut characters. In the e-mail itself this works perfectly, but not in the subject of the e-mail. I've tried many different umlaut letters and they all seem to work except for the ü. I also tried different mail libraries (HTMLMimeMail & PHPMailer) and they both fail at this:
$mail = new htmlMimeMail();
$mail->setTextEncoding("base64");
$mail->setHTMLEncoding("base64");
$mail->setTextCharset("UTF-8");
$mail->setHTMLCharset("UTF-8");
$mail->setHeadCharset("UTF-8");
$mail->setSMTPParams(mailinglist_smtp_host,mailinglist_smtp_port);
$mail->setHtml("test");
$mail->setFrom("test@test.nl");
$mail->setSubject("The ï, ö, ë, ä, and é work, but when adding the ü it doesn't");
$recipients[] = "me@myhost.nl";
$mail->send($recipients);
&
$mail = new PHPMailer();
$mail->IsMail();
$mail->FromName = 'test';
$mail->From = 'test@test.nl';
$mail->AddAddress("me@myhost.nl");
$mail->Subject = "The ï, ö, ë, ä, and é work, but when adding the ü it doesn't";
$mail->Body = "test";
$mail->Send();
Can anyone help me find the source of and the solution to this problem?
You should quoted-printable encode the subject header.
Like this:
$mail->Subject = "=?UTF-8?Q?" . quoted_printable_encode("The ï, ö, ë, ä, and é work, but when adding the ü it doesn't") . "?=";
Quoted printable encode in PHP: http://www.php.net/manual/en/function.quoted-printable-encode.php
Edit: $mail->CharSet = "UTF-8";
did the job.
这篇关于如何在邮件主题中设置umlautü的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!