在邮件 php 中嵌入图像

发布于 2024-12-20 10:13:54 字数 1246 浏览 3 评论 0原文

我正在尝试为我的网络杂志发送时事通讯。我的 PHP 代码是:

$to = $allEmails[$i];
        $subject = $sub;
        $message = $msg;
        //$message .= '<p>To unsubscribe , click here <a href="http://www.7sisters.in/index.php?menu=unsubscribe&email='.$to.'">Unsubscribe</a></p>';
        $message .= '<br />To unsubscribe , click here ';
        $message .= "http://www.7sisters.in/index.php?menu=unsubscribe&email=".$to;
        $message .= '<img src="http://css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Change Request" />';
        $message = stripcslashes($message);





        $from = $from_mail;
        //$headers = "From:" . $from;

        $headers = "From:" . $from . "\r\n" .
                   "Reply-To:" . $from . "\r\n" .
                   "X-Mailer: PHP/" . phpversion();
        $headers .= 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";         

        mail($to,$subject,$message,$headers); 

我按照教程 http://css -tricks.com/2866-sending-nice-html-email-with-php/ 在该邮件中嵌入图像。但邮件中没有显示图像!

I am trying to send newsletter for my web magazine . My PHP code is :

$to = $allEmails[$i];
        $subject = $sub;
        $message = $msg;
        //$message .= '<p>To unsubscribe , click here <a href="http://www.7sisters.in/index.php?menu=unsubscribe&email='.$to.'">Unsubscribe</a></p>';
        $message .= '<br />To unsubscribe , click here ';
        $message .= "http://www.7sisters.in/index.php?menu=unsubscribe&email=".$to;
        $message .= '<img src="http://css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Change Request" />';
        $message = stripcslashes($message);





        $from = $from_mail;
        //$headers = "From:" . $from;

        $headers = "From:" . $from . "\r\n" .
                   "Reply-To:" . $from . "\r\n" .
                   "X-Mailer: PHP/" . phpversion();
        $headers .= 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";         

        mail($to,$subject,$message,$headers); 

I followed the tutorial http://css-tricks.com/2866-sending-nice-html-email-with-php/ to embed images within that mail . But the image is not showing within the mail !

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

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

发布评论

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

评论(2

浪荡不羁 2024-12-27 10:13:54

试试这个

        $subject = $sub;
        $message = $msg;
        //$message .= '<p>To unsubscribe , click here <a href="http://www.7sisters.in/index.php?menu=unsubscribe&email='.$to.'">Unsubscribe</a></p>';
        $message .= '<br />To unsubscribe , click here ';
        $message .= "http://www.7sisters.in/index.php?menu=unsubscribe&email=".$to;

        $message = stripcslashes($message);
        $message .= '<img src="http://css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Change Request" />';

Try this

        $subject = $sub;
        $message = $msg;
        //$message .= '<p>To unsubscribe , click here <a href="http://www.7sisters.in/index.php?menu=unsubscribe&email='.$to.'">Unsubscribe</a></p>';
        $message .= '<br />To unsubscribe , click here ';
        $message .= "http://www.7sisters.in/index.php?menu=unsubscribe&email=".$to;

        $message = stripcslashes($message);
        $message .= '<img src="http://css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Change Request" />';
盛装女皇 2024-12-27 10:13:54

你应该看到这篇文章:
在邮件 php 中嵌入图像

许多客户端/浏览器最初不会下载图像。如果您想要更好的体验,您应该按照该问题中的讨论将其包含在内来嵌入它。

这里也有一个很好的教程:
http://www.litfuel.net/tutorials/mail2.htm

you should see this post:
Embed images within mail php

A lot of clients/browsers will not download images initially. If you want a better experience, you should embed it by including it as discussed in that question.

A good tutorial here too:
http://www.litfuel.net/tutorials/mail2.htm

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