如何在时事通讯中发送图像?

发布于 2024-09-06 22:16:02 字数 197 浏览 3 评论 0原文

谁能告诉我如何将图像作为时事通讯的主体部分发送。我如何从后端添加任何图像,以便当我向订阅者发送新闻通讯时,我想要显示的图像作为邮件的主体部分。

实际上我想说的是,我有一个可以输入文本的表单,并且该文本在时事通讯中效果很好。现在我也想在表单中添加图像,这样我就不需要写任何东西,只有图像会作为邮件的主体部分进入邮件。

太感谢了。 你们一直非常支持我。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

凡尘雨 2024-09-13 22:16:02

如果您的时事通讯采用 HTML 格式,只需链接到服务器上的实时图像即可。

如果您没有自己的服务器,只需将图像托管在任何类型的免费图像托管(imageshack.us)中,并在电子邮件正文中添加:

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

当用户打开电子邮件时,图像将从服务器。

只要电子邮件是多部分的(如之前建议的),任何“无法阅读”HTML 的用户都将获得文本版本,该版本可以具有指向实时服务器上图像的“硬链接”。

希望这对您有帮助

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

甜柠檬 2024-09-13 22:16:02

首先,您需要以 HTML 格式发送新闻通讯。然后,您可以将图像插入新闻通讯中,因为

<img src="image_url">

image_url 可以是远程的或嵌入的。远程图像使电子邮件变得更小,但大多数邮件客户端会征求用户的批准。嵌入的图像将在不询问用户的情况下显示,但它将成为电子邮件的一部分。

要使用远程图像,只需将图像托管在某处并将 URL 作为 image_url 即可。

嵌入图像需要编码为 MIME 部分。这样做并不简单。您需要使用像 PhpMailer 这样的包,

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

这是一个例子,

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

$mail->From="[email protected]";
$mail->FromName="Your Name";

$mail->AddAddress("[email protected]");
$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";
}
?>

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="[email protected]";
$mail->FromName="Your Name";

$mail->AddAddress("[email protected]");
$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";
}
?>
红墙和绿瓦 2024-09-13 22:16:02

您应该创建一个多部分 MIME 消息,其中包含图像,也许还包含一些 HTML。

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

够运 2024-09-13 22:16:02

我不建议在电子邮件中附加图像......这是向电子邮件服务提供商发出的许多标志之一,表明您正在发送垃圾邮件。最好按照 Marcos 解决方案中列出的方式进行操作,并通过绝对 URL 从另一台服务器链接。还要记住避免明显的电子邮件禁忌,否则会给您带来黑旗。只需一封有问题的电子邮件,垃圾邮件过滤器就会向 RBL 积极举报您。相信我,从这些名单中删除并不有趣!

我的公司每天代表客户发送数万封电子邮件。我们尝试在某一点嵌入进行测试,发现超过 50% 的电子邮件要么无法送达,要么在垃圾邮件过滤的“深渊”中丢失。通过链接,我们的送达率远高于 85%,当然这取决于所提供电子邮件的质量。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文