更新时间:2023-11-27 20:16:52
我发现标题应该以不同的方式编写.特别是,其中一些是 mime 对象的参数,而不是电子邮件标题.然后应该将 mime_params 数组传递给 get() 函数.
I discovered that the headers are supposed to be written differently. In particular, some of them are parameters for the mime object, and not email headers. Then the mime_params array should be passed to the get() function.
这是设置标题的正确方法:
This is the correct way to set the headers:
$headers = array(
'From' => 'info@mydomain.com',
'Return-Path' => 'info@mydomain.com',
'Subject' => 'mysubject',
'Content-Type' => 'text/html; charset=UTF-8'
);
$mime_params = array(
'text_encoding' => '7bit',
'text_charset' => 'UTF-8',
'html_charset' => 'UTF-8',
'head_charset' => 'UTF-8'
);
$mime = new Mail_mime();
$html = '<html><body><b>my body</b></body></html>';
$text = 'my body';
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$body = $mime->get($mime_params);
$headers = $mime->headers($headers);
$mail_object =& Mail::factory('smtp', $GLOBALS['pear_mail_config']);
$mail_object->send('test@mydomain.com', $headers, $body);