shirvo Posted December 9, 2006 Share Posted December 9, 2006 $to = "tom@hotmail.com";$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 Quote Link to comment 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>) Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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: activation@ausfamily.com\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 Quote Link to comment 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: activation@ausfamily.com\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] 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.