问题
How to insert image in mail body when user click on send button. I am using php mail
回答1:
To create an HTML email you can do something like this:
...
$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.
edit You can read more about how to create HTML emails using PHP from here: http://css-tricks.com/sending-nice-html-email-with-php/
回答2:
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
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).
Hope this helps, all the best...
回答3:
To insert image in body of mail, you can use phpmailerclass which links are
http://www.phpclasses.org/package/264-PHP-Full-featured-email-transfer-class-for-PHP.html
http://sourceforge.net/projects/phpmailer/
回答4:
The correct is almost as the above marked answer. One most important part omitted is the absolute part of the image as indicated below:
$message = "<html><head></head><body>";
$message .= "http://example.com/images/link-image.jpg' alt='' />";
$headers = "From: $from_email"; $headers .= "Content-type: text/html";
mail($to, $subject, $message, $headers);
来源:https://stackoverflow.com/questions/5390138/insert-image-in-mail-body