how to send image in newsletter?

和自甴很熟 提交于 2019-12-06 01:06:50

问题


can anyone tell me how can i send images as main body part in newsletter. how can i add any image from backend such that when i send a newsletter to the subscribers the image i want to show goes as main body part of the mail.

actually what i am saying is i have a form in which i can enter text and that text goes well in newsletter. now i want to add images in the form as well so that i don't need to write anything and only image will go in the mail as main body part of mail.

Thank you so much. you guys have been very supportive to me.


回答1:


If your newsletter is in HTML format, simply link to the live images that are on a server.

If you don't have your own server, simply host the images in any sort of free images hosting i.e. (imageshack.us) and on the body of your emails add:

<img src="http://imageshack.us/myimage.png">

And when the user opens the email, the images will load from the server.

As long as the email is multi-part (as previously suggested), any users that "can't read" HTML, will get the text version, which can have "hard-links" to the images on your live server.

Hope this helps you




回答2:


First, you need to send your newsletter as HTML. Then, you can insert the image in your newsletter as

<img src="image_url">

The image_url can be remote or embedded. The remote image makes email smaller but most mail clients will ask user's approval. The embedded image will be displayed without asking user but it will be part of Email.

To use remote image, just host the image somewhere and put the URL as image_url.

Embedded image needs to be encoded as MIME parts. It's not trivial to do this. You need to use a package like PhpMailer,

http://sourceforge.net/projects/phpmailer/

Here is an example,

<?php
require("class.phpmailer-lite.php");
$mail = new PHPMailerLite();

$mail->From="you@example.com";
$mail->FromName="Your Name";

$mail->AddAddress("list@example.com");
$mail->Subject = "Your fancy newsletter";

$mail->IsHTML(true);
$mail->AddEmbeddedImage('image.png', 'image_id', 'test.png', 'base64', 'image/png');
$mail->Body = <<<EOT
<h1>My Newsletter</h1>
<p>This picture is embedded in newsletter: <img src="cid:image_id" /></p>
EOT;
$mail->AltBody="Text only, sorry no image";

if(!$mail->Send())
{
   echo "Error sending: " . $mail->ErrorInfo;
}
else
{
   echo "Mail is sent";
}
?>



回答3:


You should create a multipart mime message, containing the image and maybe some HTML.




回答4:


I wouldn't recommend attaching images to an email....it's one of many flags to email service providers that you're sending spam. Best to do as listed in Marcos' solution and link from another server via absolute URL. Remember also to avoid the obvious email no-nos that will get you black flagged. It only takes one questionable email to raise a flag with a spam filter that will aggressively report you to the RBL's. And trust me, it's not fun to get off those lists!

My company sends tens of thousands of emails on behalf of our clients every day. We tried embedding at one point for a test, and found that more than 50% of our emails were either undeliverable or lost in the "great abyss" of spam filtering. By linking, we're at well over 85% deliverablility, depending of course on the quality of the emails provided.



来源:https://stackoverflow.com/questions/3131815/how-to-send-image-in-newsletter

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