Jump to content

Link to site in mail function


shirvo

Recommended Posts

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>)
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
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
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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.