problem with HTML email on pear_mime/Pear_Mail

36 Views Asked by At

I have problem, I'm using Pear_mail and Mail_mime functions to send mail with attachment, everything works fine with gmail, but in *live.com and *mail.ru addresses I have problem that encoding not working, IDK where to start.

Tried to change unicode options but no luck.

$to = "$email";
$cc = '[email protected]';
$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>");
}

As I say everything is OK on gmail, here is example from live.com

--=_4e8df4505d0670b28bd8f214089c1ef5 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=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 without attachment everything is OK, Here is code without attachment

$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

There are 1 best solutions below

0
On

Solved, Removed 'text/html;charset=utf-8' and everything is ok...