Mail_Mime 图像附件问题
由于某种原因,如果我使用以下代码,似乎只会发送一张图像:
$sql = mysql_query("SELECT photo FROM article_info");
while($row = mysql_fetch_assoc($sql)) {
$mime->addHTMLImage($row['photo']);
}
但如果我手动输入每个图像:
$mime->addHTMLImage("path_to/image1.jpg");
$mime->addHTMLImage("path_to/image2.jpg");
两张图像都会被发送。现在有趣的是,在第一段代码中,通过电子邮件发送的图像是 image2.jpg。就像如果由于某种原因, $mime 被覆盖,或者其他什么。我做错了什么吗?为什么我只发送/接收一张图像?有什么建议吗?提前致谢。
For some reason, if I use the following code, only one image seems to get sent:
$sql = mysql_query("SELECT photo FROM article_info");
while($row = mysql_fetch_assoc($sql)) {
$mime->addHTMLImage($row['photo']);
}
But if I were to manually enter each image:
$mime->addHTMLImage("path_to/image1.jpg");
$mime->addHTMLImage("path_to/image2.jpg");
Both images will be sent. Now what's interesting is that with the first piece of code, the image that gets sent though email is image2.jpg. Like if for some reason, $mime gets overwritten, or something. Am I doing something wrong? Why would I only be sending/receiving one image? Any suggestions? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要指定图像的名称作为第三个参数。目前,该名称为空,因此您可以使用新的 image-without-a-name 覆盖 image-without-a-name。
http://pear.php.net/manual/en /package.mail.mail-mime.addhtmlimage.php
You need to specify the name of the image as third parameter. Currently, the name is empty and thus you overwrite the image-without-a-name with the new image-without-a-name.
http://pear.php.net/manual/en/package.mail.mail-mime.addhtmlimage.php