如何在邮件主题中设置umlautü [英] How to set an umlaut ü in the mail subject

查看:106
本文介绍了如何在邮件主题中设置umlautü的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要生成包含变音符号的德语电子邮件。在电子邮件本身,这是完美的,但不是在电子邮件的主题。我尝试了许多不同的变音符号,除了ü,他们都似乎工作。我也试过不同的邮件库(HTMLMimeMail& PHPMailer),他们都失败了:

  $ 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆