Multipart email with swift

荒凉一梦 提交于 2019-12-10 15:45:49

问题


Multipart messages are not being correctly shown on gmail when on the iPhone. I have:

$message->setBody($this->body, 'text/html');
$message->addPart($this->text_body, 'plain/text');

I have also used:

$message->addPart($this->body, 'text/html');
$message->addPart($this->text_body, 'plain/text');

But in both cases, when reading gmail from the iPhone I get the message as a 'MIME-attachment'... No html and the MIME-attachment cannot even be read. The message will display fine if I don't add the text part...

Any ideas?


回答1:


You need to do:

$message->setBody($your_plain_text_email_here);
$message->addPart($your_html_email_here, 'text/html');

I just had the exact same question and this worked for me on the Mac mail app, iPhone mail app and Horde (webmail, it came up as plain text.)




回答2:


I know this post is quite old, but in case someone finds this on Google like I did, the problem above is the mine-type definition. The correct mime-type is text/plain and not plain/text, like so :

$message->addPart($this->text_body, 'text/plain');

The final version that worked for me looks like this :

$message->setBody($this->body, 'multipart/alternative');
$message->addPart($this->body, 'text/html');
$message->addPart($this->text_body, 'text/plain');



回答3:


I would have to see the source code of the email to be able to provide you with a reason why you have problem.

$message->setBody($this->body, 'multipart/alternative');
$message->addPart($this->body, 'text/html');
$message->addPart($this->text_body, 'plain/text');

As far as I have see so far there is no email class out there that respects the RFC regulations. I built my own and also built in a SMTP server into it so it sends the email directly not via mail().



来源:https://stackoverflow.com/questions/10589518/multipart-email-with-swift

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!