dazz_club Posted April 23, 2008 Share Posted April 23, 2008 I have a simple email script and i would like to put a link inside the body of the message, like click here or something, but im runin into trouble. As what appears is the actual code. I added the backward slash in the right places where quotes are found, but no luck. here is the script $sendTo = "my@email"; $subject = "Thank you"; $headers = "From:$company_email \n "; $headers .= " $first_name $surname \r\n"; $headers .= "Reply-To: $company_email \r\n"; $message = "Hi $member, This email is sent to you to inform you that <span style=\"font-weight:bold;\" >$first_name $surname</span> has become a member. For more details please click <a href=\"http://www.mysite.com/email/private/\">here to login</a>. From Administrator"; mail($sendTo, $subject, $message, $headers); kind regards Dazzclub Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 23, 2008 Share Posted April 23, 2008 In order to put html in emails you need to setup the headers to support html. http://www.sitepoint.com/article/advanced-email-php/4 Quote Link to comment Share on other sites More sharing options...
dazz_club Posted April 23, 2008 Author Share Posted April 23, 2008 Hi Lol, i know, just come back rom read a tut on sitepoint. cheers for the link aswell Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 23, 2008 Share Posted April 23, 2008 Let me know if you have any questions from there, that tutorial should get you started though. One thing to note is that not all email clients support html, so it's always a good idea to have a txt version ready as well. Quote Link to comment Share on other sites More sharing options...
dazz_club Posted April 23, 2008 Author Share Posted April 23, 2008 Hi, After reading the tut, i realised what headers are needed and then implement them. I need to go over it again for clarity but so far i have been successfull. Below is the script i am using; sendTo = "email@hotmail.com"; $subject = "welcome"; $headers = "From:$company_email \n "; $headers .= " $first_name $surname \r\n"; $headers .= "Reply-To: $company_email \r\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $message = "Hi Linda, This email is sent to you to inform you that <span style=\"font-weight:bold;\">$first_name $surname</span> has become a member. For more details please click <a href=\"http://www.mysite/bulletins/private/\">here to login</a>. From Administrator"; mail($sendTo, $subject, $message, $headers); Kind regards Dazzclub Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 24, 2008 Share Posted April 24, 2008 It's looking good, the only thing I would add is using heredoc in the message. <?php sendTo = "email@hotmail.com"; $subject = "welcome"; $headers = "From:$company_email \n "; $headers .= " $first_name $surname \r\n"; $headers .= "Reply-To: $company_email \r\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $message = <<<EMAIL Hi Linda,<br /> This email is sent to you to inform you that <span style=\"font-weight:bold;\">$first_name $surname</span> has become a member.<br /> For more details please click <a href=\"http://www.mysite/bulletins/private/\">here to login</a>. From Administrator EMAIL; mail($sendTo, $subject, $message, $headers); ?> Quote Link to comment Share on other sites More sharing options...
dazz_club Posted April 27, 2008 Author Share Posted April 27, 2008 pardon my stupidity but whats a heredoc, are you pointing to where i should start the body of the message. So remove the line so it looks like this, $message="blah blah........"; kind regards Dazzclub Quote Link to comment Share on other sites More sharing options...
p2grace Posted April 27, 2008 Share Posted April 27, 2008 No heredoc allows both double and single quotes in the string content using <<<STRING STRING; instead of quotes. <?php // Regular string $string = "Notice I have to escape quotes \"$here\""; // heredoc $string = <<<STRING Notice I do not have to escape quotes "$here" STRING; ?> Quote Link to comment Share on other sites More sharing options...
dazz_club Posted April 27, 2008 Author Share Posted April 27, 2008 o right, thanks dude, really appreciate you coming back on this one. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.