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.
"Email a friend" script mod question
Moderator: General Moderators
Re: "Email a friend" script mod question
Change the "Content-type: text/plain" part to "Content-type: text/html". Unless you've borked something else (which you haven't, as far as I can tell), it should work.
Also, one of your newlines is messed.
Also, one of your newlines is messed.
Re: "Email a friend" script mod question
What is a "newline", and how is it messed up? And how do I incorporate the html "<a href, etc." into this script correctly?
Thank you
Thank you
Re: "Email a friend" script mod question
A newline is a line break. CR, LF, CRLF, you know. \r, \n, and \r\n. In your script, you messed one up — it says \n\r instead of \r\n.
Re: "Email a friend" script mod question
Oh - of course, I see. Thank you.
Now how and where do I insert the HTML for the outgoing email?
Cheers
Now how and where do I insert the HTML for the outgoing email?
Cheers
Re: "Email a friend" script mod question
Just stick it in the message body.
Obviously you'll have to change the paths to absolute URLs, but other than that, this should work fine.
Code: Select all
$your_message .= "<a href=\"../mywebpage.html\"><img src=\"myimage.jpg\" alt=\"blahblah\" width=\"144\" height=\"69\" border=\"0\" /></a>";Re: "Email a friend" script mod question
Thank you SO much! I'm off to try.
Cheers
Cheers