=?utf-8邮件主题phpmailer
如何编辑我的函数以摆脱 “=?utf-8?B?0JfQsNC60LDQtyDQstGL0L/QuNGB0LrQuCBkb2xzbm93ICIgM9C00LDQtNCw?” 邮件主题 此函数(EncodeHeader)是邮件消息的编码头,需要以某种方式进行更正。代码如下所示:=?utf-8邮件主题phpmailer,php,email,phpmailer,Php,Email,Phpmailer,如何编辑我的函数以摆脱 “=?utf-8?B?0JfQsNC60LDQtyDQstGL0L/QuNGB0LrQuCBkb2xzbm93ICIgM9C00LDQtNCw?” 邮件主题 此函数(EncodeHeader)是邮件消息的编码头,需要以某种方式进行更正。代码如下所示: public function EncodeHeader($str, $position = 'text') { $x = 0; switch (strtolower($position)) { case 'phras
public function EncodeHeader($str, $position = 'text') {
$x = 0;
switch (strtolower($position)) {
case 'phrase':
if (!preg_match('/[\200-\377]/', $str)) {
// Can't use addslashes as we don't know what value has magic_quotes_sybase
$encoded = addcslashes($str, "\0..\37\177\\\"");
if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
return ($encoded);
} else {
return ("\"$encoded\"");
}
}
$x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
break;
case 'comment':
$x = preg_match_all('/[()"]/', $str, $matches);
// Fall-through
case 'text':
default:
$x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
break;
}
if ($x == 0) {
return ($str);
}
$maxlen = 75 - 7 - strlen($this->CharSet);
// Try to select the encoding which should produce the shortest output
if (strlen($str)/3 < $x) {
$encoding = 'B';
if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
// Use a custom function which correctly encodes and wraps long
// multibyte strings without breaking lines within a character
$encoded = $this->Base64EncodeWrapMB($str);
} else {
$encoded = base64_encode($str);
$maxlen -= $maxlen % 4;
$encoded = trim(chunk_split($encoded, $maxlen, "\n"));
}
} else {
$encoding = 'Q';
$encoded = $this->EncodeQ($str, $position);
$encoded = $this->WrapText($encoded, $maxlen, true);
$encoded = str_replace('='.$this->LE, "\n", trim($encoded));
}
$encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
$encoded = trim(str_replace("\n", $this->LE, $encoded));
return $encoded;
}
public函数EncodeHeader($str,$position='text'){
$x=0;
开关(strtolower($位置)){
案例“短语”:
如果(!preg_匹配('/[\200-\377]/',$str)){
//无法使用addslashes,因为我们不知道magic\u quotes\u sybase的值
$encoded=addcslashes($str,“\0..\37\177\\”);
如果($str==$encoded)和&!preg_匹配('/[^A-Za-z0-9!$%&'*+\/=?^ `{124;}-]/',$str)){
返回($编码);
}否则{
返回(“\”$encoded\”);
}
}
$x=preg_match_all('/[^\040\041\043-\133\135-\176]/',$str,$matches);
打破
案例“评论”:
$x=preg_match_all('/[()“]/',$str,$matches);
//失败
案例“文本”:
违约:
$x+=preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/',$str,$matches);
打破
}
如果($x==0){
回报($str);
}
$maxlen=75-7-strlen($this->CharSet);
//尝试选择产生最短输出的编码
如果(strlen($str)/3<$x){
$encoding='B';
如果(函数_存在('mb_strlen')&&&$this->HasMultiBytes($str)){
//使用一个自定义函数,正确地编码和包装长
//多字节字符串,不打断字符内的行
$encoded=$this->Base64EncodeWrapMB($str);
}否则{
$encoded=base64_encode($str);
$maxlen-=$maxlen%4;
$encoded=trim(块分割($encoded$maxlen,“\n”);
}
}否则{
$encoding='Q';
$encoded=$this->EncodeQ($str,$position);
$encoded=$this->WrapText($encoded,$maxlen,true);
$encoded=str_replace('='.$this->LE,“\n”,trim($encoded));
}
$encoded=preg_replace('/^(.*)$/m',“=?”$this->CharSet.?$encodeding?\\1?=”,$encoded);
$encoded=trim(str_replace(“\n”,$this->LE,$encoded));
返回$encoded;
}
我听说必须编码的字符不能用引号括起来
这个东西在“这是一个新的工作主题”这样的信息中效果很好,但在这不是“这是一个新的工作主题”时崩溃了“试试这个会对你有帮助的。它可以处理所有的编码。试试这个会对你有所帮助。它可以处理所有的编码。不要创建自己的mime电子邮件。只需使用PHPMailer或Swiftmailer,让他们自己处理。你会发现你的电子邮件减少到4或5行代码(对于一个基本的代码),因为你尝试自己做每件事。这已经是PHPMailer了。不要构建你自己的mime电子邮件。只需使用PHPMailer或Swiftmailer,让他们自己处理。你会发现你的电子邮件减少到4或5行代码(对于一个基本的代码),因为你尝试自己做每件事。这已经是PHPMailer了。它已经为wordpress提供了cform插件。这不是一个选项,它已经为wordpress提供了cform插件。这不是一个选择