提交表单后,在电子邮件(SMTP)中使用UTF-8进行故障排除

时间:2016-02-11 16:11:38

标签: php forms post utf-8 smtp

我收到CP1252的邮件,因为有了cyrylics需要UTF-8。

我的PHP代码:

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";

if($_SERVER["REQUEST_METHOD"] == "POST")
{
$to = '...@mail.com';
$from = '...@mail.com';
$subject = 'SUBJECT';
$body='par1:   '.$_POST['par1'].'Message:  '.$_POST['message'];

$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body);
$SMTPChat = $SMTPMail->SendMail();
}

...

<head> 
    <meta charset="utf-8">
    <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>

我也有

<form method="post" action="" accept-charset="UTF-8" > 

我尝试了很多选项,但无论如何都有CP1252的邮件。 如何为这个问题找到正确的解决方案?

0 个答案:

没有答案