"Email a friend" script mod question
Posted: Thu Nov 13, 2008 3:42 pm
Hello all, newbie question here.
I'm trying to modify a php "email a friend" script so that the email that's sent to the friend is in HTML format so I can include a picture.
I think I've isolated the pertinent part of the code to this:
function email($from, $from_name, $to, $message)
{
//header("Location: thankyou.html");return;
$headers .= "From: ".$from."\r\n";
$headers .= "Content-type: text/plain; charset=ISO-8859-1";
$your_domian_name = "www.mydomain.com";
//edit what you want your vistors to see in their email here
$subject = $from_name." sent you an invitation to $your_domian_name";
$your_message = "Hello!\r\n";
$your_message.= ucfirst($from_name);
$your_message.= " wants you to check out $your_domian_name\r\n";
$your_message.= "Sender's Message:\n\r";
<a href="../mywebpage.html"><img src="myimage.jpg" alt="blahblah" width="144" height="69" border="0" /></a>
$message=$your_message.stripslashes($message);
if (mail($to,$subject,$message,$headers) ) {
return true;
} else {
return false;
}
I'm pretty sure that I must need to change the content type from text to HTML. How do I do that? Also, you see the href tag below the last $your_message. How do I correctly format that? And do I need to ad anything else to make it work?
Any help or direction on this will be MUCH appreciated. Cheers.
I'm trying to modify a php "email a friend" script so that the email that's sent to the friend is in HTML format so I can include a picture.
I think I've isolated the pertinent part of the code to this:
function email($from, $from_name, $to, $message)
{
//header("Location: thankyou.html");return;
$headers .= "From: ".$from."\r\n";
$headers .= "Content-type: text/plain; charset=ISO-8859-1";
$your_domian_name = "www.mydomain.com";
//edit what you want your vistors to see in their email here
$subject = $from_name." sent you an invitation to $your_domian_name";
$your_message = "Hello!\r\n";
$your_message.= ucfirst($from_name);
$your_message.= " wants you to check out $your_domian_name\r\n";
$your_message.= "Sender's Message:\n\r";
<a href="../mywebpage.html"><img src="myimage.jpg" alt="blahblah" width="144" height="69" border="0" /></a>
$message=$your_message.stripslashes($message);
if (mail($to,$subject,$message,$headers) ) {
return true;
} else {
return false;
}
I'm pretty sure that I must need to change the content type from text to HTML. How do I do that? Also, you see the href tag below the last $your_message. How do I correctly format that? And do I need to ad anything else to make it work?
Any help or direction on this will be MUCH appreciated. Cheers.