tomcat
September 13, 2004, 7:01am
1
Hi,
Does someone have a working script to embed images inside
a html email generated from php.
This is my function that currently works but It keeps trying to download the image live if i am offline.It needs to be embedded so you can still see it while offline.
$HTML .= "<img src=\“http://www.mysite.com/image.jpg\\ ”>\r
";
$HTML .= "rest of the content here\r
";
$HTML .= "rest of the content here\r
";
$to = myself@mysite.com ;
$from = “info@mysite.com ”;
$rp = ‘me@mysite.com’;
$subject = “subject of the mail”;
$headers = “From: Website<” . $from . “>”;
$headers .= "
MIME-Version: 1.0
" . "Content-Type: text/html;
";
$headers .= "Return-Path: $rp \r
";
$message = $HTML;
$ok = @mail ($to, $subject, $message, $headers);
Can someone chage this for me so that the img
<img src=\“http://www.mysite.com/image.jpg\\ ”>
gets embedded in the mail.
Thanks a milion
set image like a coockie so it will be stored into temp internet folder!
system
September 13, 2004, 9:05pm
3
Yo
set image like a coockie so it will be stored into temp internet folder!
Maybe you could post some script that you have working ?
Anyways, not sure exactly what your problem is, I suspect that your not setting the correct MIME TYPE, though to save yourself a lot of hassle, have you heard about PHP Mailer ?
Features
Can send emails with multiple TOs, CCs, BCCs and REPLY-TOs[]Redundant SMTP servers[ ]Multipart/alternative emails for mail clients that do not read HTML email[]Support for 8bit, base64, binary, and quoted-printable encoding[ ]Uses the same [color=#000080]methods[/color] as the very popular AspEmail active server (COM) component[]SMTP authentication[ ]Word wrap[/list][list][]Address reset functions[ ]HTML email[*]Tested on multiple SMTP servers: [url=“http://www.sendmail.org/”][color=#000080]Sendmail[/color], [url=“http://www.qmail.org/”][color=#000080]qmail[/color], [url=“http://www.postfix.org/”][color=#000080]Postfix[/color] , Imail, Exchange, Mercury, Courier[]Works on any win32 or nix platform[ ]Flexible debugging[ ]Custom mail headers[]Multiple fs, string, and binary attachments (those from database, string, etc)[ ]Embedded image support
Does the job for you, and saves you a lot of time and hassle. You can also find examples and the documentation at the same link
http://phpmailer.sourceforge.net/
tomcat
September 14, 2004, 5:58am
4
I did post a working sample of an html mail.
I did have a look at the php mailer and I’m a bit blond trying to implement the class
I’m just looking for a standard html mail function with embeded images
without using a database like the sample in the phpmailer
SpikeZ
September 14, 2004, 9:29am
5
what you could do is set the body of the message as a variable ie:
/* message */
$message = '
<html>
<head>
<title>email message</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td align="left" background="http://yoursite.com/images/generic_images/emailbgtop.jpg"><img src="http://yoursite.com/images/generic_images/emailheader.jpg" width="413" height="127"></td>
</tr>
<tr>
<td align="center"><font face="Tahoma, Verdana, Arial" font size="2"><br>
message text::message text::message text::message text::message text::message text::message text
</font></td>
</tr>
<tr bgcolor="#ECECEC">
<td align="center" bgcolor="#FFFFFF"><strong><font face="Tahoma, Verdana, Arial" font size="2" color="#0DC005">Thank You! :) </font></strong></td> </tr>
<tr bgcolor="#ECECEC">
<td background="http://yoursite.com/images/generic_images/emailbgbottom.jpg"><img src="http://yoursite.com/images/generic_images/emailbgbottom.jpg" width="166" height="77"></td>
</tr>
</table>
</body>
</html>
';
The advantage of doing the message like this is that you can design the page seperately and then drop it in between the quotes.
You then need to set the headers. So the whole code looks like:
$to = "$_POST[name] <$_POST[email]>" . ", " ; // note the comma
/* subject */
$subject = "Advert Placement on http://yoursite.com";
/* message */
<html>
<head>
<title>email message</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td align="left" background="http://yoursite.com/images/generic_images/emailbgtop.jpg"><img src="http://yoursite.com/images/generic_images/emailheader.jpg" width="413" height="127"></td>
</tr>
<tr>
<td align="center"><font face="Tahoma, Verdana, Arial" font size="2"><br>
message text::message text::message text::message text::message text::message text::message text
</font></td>
</tr>
<tr bgcolor="#ECECEC">
<td align="center" bgcolor="#FFFFFF"><strong><font face="Tahoma, Verdana, Arial" font size="2" color="#0DC005">Thank You! :) </font></strong></td> </tr>
<tr bgcolor="#ECECEC">
<td background="http://yoursite.com/images/generic_images/emailbgbottom.jpg"><img src="http://yoursite.com/images/generic_images/emailbgbottom.jpg" width="166" height="77"></td>
</tr>
</table>
</body>
</html>
';
/* To send HTML mail */
$headers = "MIME-Version: 1.0\\r\
";
$headers .= "Content-type: text/html; charset=iso-8859-1\\r\
";
/* additional headers */
$headers .= "From: YoursiteAdmin <admin@yoursite.com>\\r\
";
/* and now mail it */
mail($to, $subject, $message, $headers);
Hope this helps
SpikeZ
tomcat
If you’re trying to implement the mime-mailer, first send yourself a message with images and view its source. Second, read http://www.faqs.org/rfcs/rfc1521.html to find out what do “multipart/mixed” and “content-id” mean.
Then… implement the mailer. There is nothing magical about this.