how to send email with graphic via php

六月ゝ 毕业季﹏ 提交于 2019-12-01 05:40:43

问题


I would like to send HTML email with graphic elements included. I have no idea to attach garaphics to this email.


回答1:


You probably don't want to do an inline attachment by hand, it's far easier, and less error prone to use a library, like PHPMailer.
It can attach the inline images, or if you give it some HTML code, it will attach the images by itself and modify the code to display them.




回答2:


You can try Swift Mailer




回答3:


I'm not going to bore you with a mediocre explanation here so instead let me link to this great tutorial over at Sitepoint which explained it to me in plain English! - advanced-email-php




回答4:


The short version is that you are probably best off creating a HTML formatted messages, and using the header parameter of the php mail function.

 $headers = "From: sender@example.com\n" .
    "MIME-Version: 1.0\n" .
    "Content-type: text/html; charset=iso-8859-1";
 mail(to@example.com, 'subject line', 'your message text <strong>with HTML in it</strong>', $headers);

The sitepoint.com article referenced by Jimmy provides an excellent and complete description of your options.



来源:https://stackoverflow.com/questions/157208/how-to-send-email-with-graphic-via-php

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