Answer the question
In order to leave comments, you need to log in
Zf2 how to fix encoding issue when sending Zend\Mail\Message?
I send a message like this:
$body = 'тест';
$textPart = new MimePart($body);
$textPart->type = "text/html";
$textPart->encoding = Zend\Mime\Mime::ENCODING_BASE64;
$body = new MimeMessage();
$body->setParts(array($textPart));
$message = new \Zend\Mail\Message();
$message->setFrom('[email protected]');
$message->addTo('[email protected]');
$message->setSubject('Получен новый');
$message->setEncoding('UTF-8');
$message->setBody($body);
$smtpOptions = new \Zend\Mail\Transport\SmtpOptions();
$smtpOptions->setHost('smtp.gmail.com')
->setConnectionClass('login')
->setName('smtp.gmail.com')
->setConnectionConfig(array(
'username' => '',
'password' => '',
'ssl' => 'tls',
)
);
$transport = new \Zend\Mail\Transport\Smtp($smtpOptions);
$transport->send($message);
Answer the question
In order to leave comments, you need to log in
$headers = $message->getHeaders();
$headers->removeHeader('Content-Type');
$headers->addHeaderLine('Content-Type', 'text/html; charset=UTF-8');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question