shirvo Posted December 9, 2006 Share Posted December 9, 2006 $to = "[email protected]";$subject = "Registered";$body = "hello";mail($to, $subject, $body)In the "$body" i want to have a link in there so when people get the email they can click it and go to an activation page. What code do i use to add that link??? Please help Link to comment https://forums.phpfreaks.com/topic/30007-link-to-site-in-mail-function/ Share on other sites More sharing options...
bljepp69 Posted December 9, 2006 Share Posted December 9, 2006 The mail() function as you've described it above, sends a text-based email. So, you could simply type out the link like this - http://www.mysite.com - and then it's up to the recipient's email client as to whether or not it gets displayed as a link or as text. You won't have control of that.If you want to send HTML mail, it gets a bit more complicated because you have to send a bunch of headers in the mail() function. However, then you would be able to send a link, and, assuming the recipient can receive an HTML email, they will see the link as you describe it in HTML (e.g. <a href="http://www.mysite.com">My site</a>) Link to comment https://forums.phpfreaks.com/topic/30007-link-to-site-in-mail-function/#findComment-137932 Share on other sites More sharing options...
shirvo Posted December 9, 2006 Author Share Posted December 9, 2006 Well could you tell me what headers i would have to use because i tried that and it only came up as text Link to comment https://forums.phpfreaks.com/topic/30007-link-to-site-in-mail-function/#findComment-137983 Share on other sites More sharing options...
tomfmason Posted December 9, 2006 Share Posted December 9, 2006 Here are some decent headers for that..[code=php:0]$headers = "FROM: your_email_address\r\n";$headers .= "MIME-Version: 1.0\r\n";$headers .= "Content-type: multipart/alternative;\r\n";$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";$headers .= "Content-Transfer-Encoding: 7bit";$headers .= "\r\n";[/code]Hope that helps,Tom Link to comment https://forums.phpfreaks.com/topic/30007-link-to-site-in-mail-function/#findComment-137992 Share on other sites More sharing options...
shirvo Posted December 9, 2006 Author Share Posted December 9, 2006 nope that still doesn't help.$headers = "FROM: [email protected]\r\n";$headers .= "MIME-Version: 1.0\r\n";$headers .= "Content-type: multipart/alternative;\r\n";$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";$headers .= "Content-Transfer-Encoding: 7bit";$headers .= "\r\n";$to = $email;$subject = "Registered";$body = "<html><body>hi <a href=\"www.ausfamily.com/authentication.php"\>Activation</a></body></html>";mail($to, $subject, $body, $headers);This is my code and the page wont even work. Please help. i really need to have this work Link to comment https://forums.phpfreaks.com/topic/30007-link-to-site-in-mail-function/#findComment-138003 Share on other sites More sharing options...
bljepp69 Posted December 9, 2006 Share Posted December 9, 2006 Those are good headers. The only thing I can see in the above code that wouldn't work is you missed where you escaped a " in the URL. That would cause a parse error. Try:[code]$headers = "FROM: [email protected]\r\n";$headers .= "MIME-Version: 1.0\r\n";$headers .= "Content-type: multipart/alternative;\r\n";$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";$headers .= "Content-Transfer-Encoding: 7bit";$headers .= "\r\n";$to = $email;$subject = "Registered";$body = "<html><body>hi <a href=\"www.ausfamily.com/authentication.php\">Activation</a></body></html>";mail($to, $subject, $body, $headers);[/code] Link to comment https://forums.phpfreaks.com/topic/30007-link-to-site-in-mail-function/#findComment-138060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.