Click to See Complete Forum and Search --> : Including image in HTML e-mail
gizmo
09-24-2007, 10:07 AM
I have modified the code in the 'sticky' on uploading images so that I am sent an e-mail when someone does so. I would like to include a copy of the image in that e-mail, but find MIME types and the PHP Manual in that area heavy going. I can put a link to the image in my e-mail message, but want it to be HTML so that I can see the image itself in the message. I can do the coding for any necessary resizing of the image. I am sure the answer is simple once you know how.
hastx
09-24-2007, 11:35 AM
If you have the image hosted somewhere on the internet, just include it in your html source as usual
<img src="http://www.domain.com/where_image_is/img.jpg">
gizmo
09-24-2007, 11:43 AM
I've already done that bit, but how do I get the e-mail that is sent to me to accept HTML? In other words, how do I make it an HTML e-mail as opposed to plain text?
rulian
09-24-2007, 11:57 AM
you cannot control whether the user will accept HTML emails or not,
the most you can do is have an alternate text version of the email available
Yelgnidroc
09-24-2007, 12:23 PM
If I am sending an html e-mail I always send a mime e-mail with plain text as well because not everyone can read html e-mails.
gizmo
09-24-2007, 12:38 PM
The e-mail to be sent to me as the sole recipient and I wish to receive it in HTML format so that I can include with the text a single image using the <img> tag already discussed.
bokeh
09-24-2007, 03:53 PM
function HTMLemail($to, $subject, $content, $headers = null)
{
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$message = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n".
'<html>'."\n".
'<head>'."\n".
'<title></title>'."\n".
'</head>'."\n".
'<body>'."\n".
"{$content}\n".
'</body>'."\n".
'</html>'."\n";
return @mail($to, $subject, $message, $headers);
}
gizmo
09-25-2007, 01:46 AM
Many thanks, Bokeh, your help is much appreciated..