php - Encoding Issue with Gmail SMTP and Zend\Mail\Message- Zend Framework 2 -


i need write accented letters email body, utf-8 encode doesn't work. gmail setting i've selected option "use unicode (utf-8) outgoing messages".

i'm using gmail smtp , zend\mail\messsage. tried 4 different methods, not 1 works.

complete function:

    public function sendregistrationemail(){     $message = new message();     $message->addto($this->email)         ->addfrom(self::from)         ->setsubject($this->subject)         ->setencoding('utf-8')         ->setbody('àèéòù');      $transport = new smtptransport();     $options   = new smtpoptions($this->smtp);     $transport->setoptions($options);     $transport->send($message);    } 

1:

->setbody('àèéòù');  output: à èéòù 

2:

->setbody(utf8_encode('àèéòù')); output: àèéòù 

3:

 ->setencoding('utf-8')  ->setbody('àèéòù');  output: à èéòù 

4:

->setencoding('utf-8') ->setbody(utf8_encode('àèéòù')); output:àèéòù 

i tried select gmail settings "avoid unicode (utf-8) encoding outgoing messages", resuts same! doing wrong? help!

i found solution here:

http://framework.zend.com/manual/current/en/modules/zend.mail.message.html

if need use html email:

$html = new mimepart($htmlmarkup); $html->type = "text/html; charset = utf-8"; 

else, pure text email:

$text = new mimepart($textcontent); $text->type = "text/plain; charset = utf-8";  $body = new mimemessage(); $body->setparts(array($text or $html));   .....rest of message instance.... ->setbody($body); 

i don't understand reason why setencoding('utf-8') doesn't work. there other solutions?


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -