Jump to content

hyperlinks sent not working in yahoomail


freelance84

Recommended Posts

Does anyone know how to send hyperlinks to yahoo mail?

 

My site sends out an activation email. When I receive the email in msn, I can click the activate link. However the same email received in yahoo mail; the link is not click-able, all i get is the text between the <a> tags.

 

Here is the email sent from the php:

$msg = "<HTML><HEAD><TITLE>My Message</TITLE></HEAD>
<BODY>
Hi $f_name $s_name, thank you for registering with mysite.<br/><br/>

This email is to confirm to us that this is your email address. 
Please click on the following link to proceed with the registration:<br/><br/>

<a href=\"www.mysite.net?102=$ID\">**Click here to confirm with mysite that this is your email address**</a><br/><br/><br/>

If you were not expecting this email then somebody has tried to register a 
<a href=\"www.mysite.net\">mysite</a> account with your email. If so, you can 
remove the attempt by clicking on the remove link below. This will ensure your email 
address is not held in our system.<br/><br/>

<a href=\"www.mysite.net?999=$ID\">**REMOVE ATTEMPT**</a><br/><br/><br/>

Please also note that this is an automated email, and cannot be replied to. If you 
need to contact mysite, please <a href=\"www.mysite.net\">click here</a> and follow 
the contactUs link.<br/><br/>
Thank You
</BODY>
</HTML>";
$headers = "From: accounts@mysite.net\nReply-To: no-reply@mysite.net\nContent-Type: text/html; charset=iso-8859-1";

 

All of the links in yahoo mail are just coming up as text.

 

Any pointers here would be brilliant!

Link to comment
Share on other sites

May need to send the mime type header as well.

 

I know html emails are often sent with PHP's mail(), but just FYI: the PHP manual says "If intending to send HTML or otherwise Complex mails, it is recommended to use the PEAR package » PEAR::Mail_Mime."

Link to comment
Share on other sites

Blimey thanks for all the responses.

 

I've added the http:// but no change. I'm now going to find out what the mime type is and try to implement it.

 

Pikachu2000, you mentioned sending a multipart version. How exactly do you mean? Is it possible to determine how the email is being read by the recipient and therefore show one message or the other? (ie the html version and non html version)

Link to comment
Share on other sites

I did a test with your code on my machine. When the "http://" wasn't in the URLs, I got the same results as you using both mail and PHPMailer. When I put the "http://" in, the links were clickable -- when using PHPMailer. I didn't try with regular PHP mail().

 

The mail client being used decides which version to show, HTML or Plain text.

 

Ken

Link to comment
Share on other sites

Ken, were you receiving the mail in yahoo?

 

I added the MIME header as well as the http but still no clickable links. I'm going to download PHPmailer, which version did you test in, the latest?

 

Thanks Pikachu2000, i'm going to implement the multipart now as well.

Link to comment
Share on other sites

Yes, I was sending to my Yahoo account.  I tested with the latest PHPMailer.

 

Here is the code I tested:

<?php
require_once('./PHPMailer/class.phpmailer.php'); // change this to where you've put the class
$mail             = new PHPMailer();
$ID = rand(10,99);
$msg = "<HTML><HEAD><TITLE>My Message</TITLE></HEAD>
<BODY>
Hi $f_name $s_name, thank you for registering with mysite.<br/><br/>

This email is to confirm to us that this is your email address.
Please click on the following link to proceed with the registration:<br/><br/>

<a href='http://www.mysite.net?102=$ID'>**Click here to confirm with mysite that this is your email address**</a><br/><br/><br/>

If you were not expecting this email then somebody has tried to register a
<a href='http://www.mysite.net'>mysite</a> account with your email. If so, you can
remove the attempt by clicking on the remove link below. This will ensure your email
address is not held in our system.<br/><br/>

<a href='http://www.mysite.net?999=$ID'>**REMOVE ATTEMPT**</a><br/><br/><br/>

Please also note that this is an automated email, and cannot be replied to. If you
need to contact mysite, please <a href='http://www.mysite.net'>click here</a> and follow
the contactUs link.<br/><br/>
Thank You
</BODY>
</HTML>";
$mail->AddReplyTo("kenrbnsn@rbnsn.com","Ken Robinson");

$mail->SetFrom('from.address@here', 'From Name');

$address = "to.address@herr";
$mail->AddAddress($address, "To Name");

$mail->Subject    = "PHPMailer Test";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($msg);
if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}
?>

 

Ken

Link to comment
Share on other sites

oh, just one more question on the code you put up:

 

When I put in the http:// I had to escape the double forward slash otherwise my editor was saying it was a comment, ie

<a href=\"http:\//www.mysite.net?102=$ID_confirm\">**Click here to confirm with mysite that this is your email address**<br/>
		 					Or copy and paste into address bar: www.mysite.net?102=$ID_confirm</a><br/><br/><br/>

 

But i noticed that you haven't escaped anything, is this just a typo or is there no need to escape special characters on multi-lined instances like this?

Link to comment
Share on other sites

I can't believe it! Using single quotes instead of double quotes and just using the mail() has solved the issue!

 

ie this works:

//sedning the email confirmation message and link
$to = $email;
$subject = "mysite confirmation email";
$msg = "<HTML><HEAD><TITLE>My Message</TITLE></HEAD>
<BODY>
Hi $f_name $s_name, thank you for registering with mysite .<br/><br/>

This email is to confirm to us that this is your email address. Please click on the following link to proceed with the registration:<br/><br/>

<a href='http://www.mysite .net?102=$ID_confirm'>**Click here to confirm with mysite that this is your email address**<br/>
Or copy and paste into address bar: www.mysite .net?102=$ID_confirm</a><br/><br/><br/>

If you were not expecting this email then somebody has tried to register a <a href=\"www.mysite .net\">mysite </a> account with your email. If so, you can remove the attempt by clicking on the remove link below. This will ensure your email address is not held in our system.<br/><br/>

<a href='http://www.mysite .net?999=$ID_remove'>**REMOVE ATTEMPT**<br/>www.mysite .net?999=$ID_remove</a><br/><br/><br/>

Please also note that this is an automated email, and cannot be replied to. If you need to contact mysite , please <a href=\"www.mysite .net\">click here</a> and follow the contactUs link.<br/><br/>
Thank You
</BODY>
</HTML>";
$headers = "From: accounts@mysite .net\nReply-To: no-reply@mysite .net\nContent-Type: text/html; charset=iso-8859-1\MIME-Version: 1.0";
mail("$to","$subject","$msg","$headers");

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.