我正在使用PHP Mail Function发送 HTML 电子邮件,在我的电子邮件主题中我可以这样。
\n\nJust one more step - Confirm Your Account\xc3\xa2\xe2\x82\xac \nRun Code Online (Sandbox Code Playgroud)\n\n我无法弄清楚“ \xc3\xa2\xe2\x82\xac ”是如何进入“ Account\xc3\xa2\xe2\x82\xac ”的,因为我从来没有把它放在变量上。下面是代码。
\n\n被调用的函数
\n\n$html = template_registration($name, $email, $user_code);\nsendmail($html, $email, $name, "Just one more step - Confirm Your Account\xe2\x80\x8f");\n\n\nfunction sendmail($html, $to, $name, $subject){\n require_once( site_path . "/framework/PHPMailer/PHPMailerAutoload.php" );\n $mail = new PHPMailer;\n $mail->isSendmail();\n $mail->setFrom(\'notifications@example.com\', \'Example\');\n $mail->addAddress($to, $name);\n $mail->Subject = $subject;\n $mail->msgHTML($html);\n if ( $mail->send() ) {\n return true;\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n请帮忙,我什至不知道在谷歌上搜索什么。
\n您需要设置标题:
\n\n$headers = \'Content-Type: text/html; charset=UTF-8\';\nmail($to, $subject, $message, $headers);\nRun Code Online (Sandbox Code Playgroud)\n\n否则电子邮件将被错误解释。
\n\n或者根据您的代码:
\n\n$mail->CharSet = \'UTF-8\'; //before sending it of course\nRun Code Online (Sandbox Code Playgroud)\n\n可能\xc3\xa2\xe2\x82\xac源自电子邮件的其余部分,但由于编码“错误”,系统无法产生这种差异(非常容易)。