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 Link to comment https://forums.phpfreaks.com/topic/102584-solved-having-a-link-inside-a-message-of-an-email/ 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 Link to comment https://forums.phpfreaks.com/topic/102584-solved-having-a-link-inside-a-message-of-an-email/#findComment-525378 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 Link to comment https://forums.phpfreaks.com/topic/102584-solved-having-a-link-inside-a-message-of-an-email/#findComment-525400 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. Link to comment https://forums.phpfreaks.com/topic/102584-solved-having-a-link-inside-a-message-of-an-email/#findComment-525403 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 protected]"; $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 Link to comment https://forums.phpfreaks.com/topic/102584-solved-having-a-link-inside-a-message-of-an-email/#findComment-525453 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 protected]"; $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); ?> Link to comment https://forums.phpfreaks.com/topic/102584-solved-having-a-link-inside-a-message-of-an-email/#findComment-526082 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 Link to comment https://forums.phpfreaks.com/topic/102584-solved-having-a-link-inside-a-message-of-an-email/#findComment-528515 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; ?> Link to comment https://forums.phpfreaks.com/topic/102584-solved-having-a-link-inside-a-message-of-an-email/#findComment-528527 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. Link to comment https://forums.phpfreaks.com/topic/102584-solved-having-a-link-inside-a-message-of-an-email/#findComment-528531 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.