pear_mime / Pear_Mail上的HTML电子邮件出现问题

时间:2019-05-14 09:31:41

标签: php email pear mail-mime

我有问题,我正在使用Pear_mailMail_mime函数发送带附件的邮件,所有内容都可以与gmail一起正常使用,但是在* live.com和* mail.ru地址中我有问题该编码无效,IDK从哪里开始。

试图更改unicode选项,但没有运气。

$to = "$email";
$cc = 'registration@tafu.edu.ge';
$recipients = $to.", ".$cc;

$email_subject = "Registration";
$email_body = '<html>
<head>
  <title>Registration</title>
</head>
<body>
  <p>'.$firstname.', your status has been confirmed.</p>

</body>
</html>' ;


$headers = array ('From' => $email_from, 'To' => $to, 'Subject' => $email_subject, 'Reply-To' => $email_address,     'MIME-Version' => 1, 'Content-type' => 'text/html;charset=utf-8');

$crlf = "\n";

$mime = new Mail_mime(array('eol' => $crlf));

$mime->setHTMLBody($email_body);
$mime->addAttachment($path1, 'image/jpeg');
$mime->addAttachment($path, 'image/jpeg');
$mimeparams['text_encoding']="8bit"; 
$mimeparams['text_charset']="UTF-8"; 
$mimeparams['html_charset']="UTF-8"; 
$mimeparams['head_charset']="UTF-8"; 
$email_body = $mime->get($mimeparams);
$headers = $mime->headers($headers);


$mail = $smtp->send($recipients, $headers, $email_body);


if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
}

正如我所说的,在gmail上一切正常,这是来自live.com的示例

  

-= _ 4e8df4505d0670b28bd8f214089c1ef5 Content-Transfer-Encoding:quoted-printable Content-Type:text / html;字符集= UTF-8   = E1 = 83 = 90 = E1 = 83 = 9C = E1 = 83 = 98,= E1 = 83 = 97 = E1 = 83 = A5 = E1 = 83 = 95 = E1 = 83 = 94 = E1 = = 83 = 9C = E1 = 83 = 98 = E1 = 83 = 9B = E1 = 83 = 9D = E1 = 83 = 9C = E1 = 83 = 90 = E1 = 83 = AA = E1 = 83 = 94 = E1 = = 83 = 9B = E1 = 83 = 94 = E1 = 83 = 91 = E1 = 83 = 98 = E1 = 83 = 93 = E1 = 83 = 90 = E1 = 83 = A4 = E1 = 83 = 98 = E1 = = 83 = A5 = E1 = 83 = A1 = E1 = 83 = 98 = E1 = 83 = A0 = E1 = 83 = 93 = E1 = 83 = 90。   = E1 = 83 = 9D = E1 = 83 = A0 = E1 = 83 = 98 = E1 = 83 = A1 = E1 = 83 = 90 = E1 = 83 = 9B = E1 = 83 = A3 = E1 = 83 = = A8 = E1 = 83 = 90 = E1 = 83 = 9D = E1 = 83 = 93 = E1 = 83 = A6 = E1 = 83 = 98 = E1 = 83 = A1 = E1 = 83 = 92 = E1 = 83 = = 90 = E1 = 83 = 9C = E1 = 83 = 9B = E1 = 83 = 90 = E1 = 83 = 95 = E1 = 83 = 9A = E1 = 83 = 9D = E1 = 83 = 91 = E1 = 83 = 90 = = E1 = 83 = A8 = E1 = 83 = 98 = E1 = 83 = 97 = E1 = 83 = A5 = E1 = 83 = 95 = E1 = 83 = 94 = E1 = 83 = 9C = E1 = 83 = 9B = = E1 = 83 = 98 = E1 = 83 = 98 = E1 = 83 = A6 = E1 = 83 = 94 = E1 = 83 = 91 = E1 = 83 = 97 = E1 = 83 = 9E = E1 = 83 = 90 = = E1 = 83 = A1 = E1 = 83 = A3 = E1 = 83 = AE = E1 = 83 = A1 = E1 = 83 = A0 = E1 = 83 = 94 = E1 = 83 = 92 = E1 = 83 = 98 = = E1 = 83 = A1 = E1 = 83 = A2 = E1 = 83 = A0 = E1 = 83 = 90 = E1 = 83 = AA = E1 = 83 = 98 = E1 = 83 = 98 = E1 = 83 = A1   = = E1 = 83 = 97 = E1 = 83 = 90 = E1 = 83 = 9D = E1 = 83 = 91 = E1 = 83 = 90 = E1 = 83 = 96 = E1 = 83 = 94。   = E1 = 83 = 92 = E1 = 83 = 97 = E1 = 83 = AE = E1 = 83 = 9D = E1 = 83 = 95 = E1 = 83 = 97,= E1 = 83 = 92 = E1 = = 83 = 90 = E1 = 83 = 93 = E1 = 83 = 90 = E1 = 83 = AE = E1 = 83 = 94 = E1 = 83 = 93 = E1 = 83 = 9D = E1 = 83 = 97 = E1 =

没有附件的BTW一切正常, 这是没有附件的代码

$to = $_GET['email'];
$firstname = $_GET['firstname'];
$email_subject = "Failed";
$email_body = '<html>
<head>
  <title>Failed</title>
</head>
<body>
<p>'.$firstname.', ERROR!</p>
</body>
</html>' ;


$headers = array ('From' => $email_from, 'To' => $to, 'Subject' => $email_subject, 'Reply-To' => $email_address,     'MIME-Version' => 1,    'Content-type' => 'text/html;charset=utf-8');

$mail = $smtp->send($to, $headers, $email_body);


if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
}

1 个答案:

答案 0 :(得分:0)

已解决, 删除了'text / html; charset = utf-8',一切正常...