php 在邮件正文中插入图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5390138/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
insert image in mail body
提问by ZEESHAN IQBAL
How to insert image in mail body when user click on send button. I am using php mail
当用户单击发送按钮时如何在邮件正文中插入图像。我正在使用 php 邮件
回答by sarcastyx
To create an HTML email you can do something like this:
要创建 HTML 电子邮件,您可以执行以下操作:
...
$message = "<html><head></head><body>";
$message .= "<img src='link-image.jpg' alt='' /></body></html>";
$headers = "From: $from_email";
$headers .= "Content-type: text/html";
mail($to, $subject, $message, $headers);
This should build an HTML email for you and you should then be able to insert just normal html.
这应该为您构建一个 HTML 电子邮件,然后您应该能够插入普通的 html。
editYou can read more about how to create HTML emails using PHP from here: http://css-tricks.com/sending-nice-html-email-with-php/
编辑您可以从这里阅读有关如何使用 PHP 创建 HTML 电子邮件的更多信息:http: //css-tricks.com/sending-nice-html-email-with-php/
回答by Catalin
If you are actually asking: How to attach and insert inline images in a html email? you can use this for guidance :) https://www.quora.com/What-is-meant-by-inline-images-in-HTML
如果您实际上是在问:如何在 html 电子邮件中附加和插入内嵌图像?你可以用它作为指导:) https://www.quora.com/What-is-meant-by-inline-images-in-HTML
In that example, pay extra attention to how the src attribute of the img tag is filled (the "cid" is actually the id given as "Content-ID:" for the image attachment header).
在该示例中,请特别注意 img 标签的 src 属性是如何填充的(“cid”实际上是作为图像附件标题的“Content-ID:”给出的 id)。
Hope this helps, all the best...
希望这会有所帮助,祝您一切顺利...
回答by Sanjeev Kumar Jha
To insert image in body of mail, you can use phpmailerclass which links are
要在邮件正文中插入图像,您可以使用 phpmailerclass 哪些链接是
http://www.phpclasses.org/package/264-PHP-Full-featured-email-transfer-class-for-PHP.html
http://www.phpclasses.org/package/264-PHP-Full-featured-email-transfer-class-for-PHP.html
回答by Magige Daniel
The correct is almost as the above marked answer. One most important part omitted is the absolute part of the imageas indicated below:
正确的几乎是上面标记的答案。省略的一个最重要的部分是图像的绝对部分,如下所示:
$message = "<html><head></head><body>";
$message .= "<img src='http://example.com/images/link-image.jpg' alt='' /></body></html>";
$headers = "From: $from_email";
$headers .= "Content-type: text/html";
mail($to, $subject, $message, $headers);