Jump to content

send image with mail function


asmith

Recommended Posts

To do this the easy way, have your background available on the web. Then just create a simple HTML email.

 

For example:

 

<?php 
$from = "[email protected]";
$to = "[email protected]";
$subject = "Hello!";

$headers = "From: {$from}\r\n"; 
$headers .= "MIME-Version: 1.0\r\n"; 
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n\r\n";

$message = '<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY background="http://us.i1.yimg.com/us.yimg.com/i/us/sch/gr/bggreendiag.gif">

message goes here
<img height=1 width=1 src="http://pksml.net/blank.gif">
</BODY>
</HTML>';


//send message 
if (mail("$to", "$subject", "$message", "$headers"))
{echo "Mail sent!";} else {echo "Mail NOT sent!";}
?> 

 

Notice the background in the body tag of the HTML message.

 

To show pictures, I found it necessary to place one in the body of the HTML, so I just put a blank transparent picture there.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.