abhi10kumar 0 Junior Poster

I am sending mail after a user enter his/her email. In email message there is link which will be opened by user. The anchor tag is working fine in Gmail but not in Yahoo Mail/Indiatimes Mail.

Here is the code block:

{
 $emailurl="3gmobile.co.in/phone_details.php?id=".$_REQUEST['id']."&model=".$_REQUEST['model']."&redirect=1";
 $headers = "From: Donotreply@domain.co.in\r\n";
 $headers .= "MIME-Version: 1.0\r\n";
 $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
 $subject="Coupon Code";
 $body="Dear ".$_POST['name'].", <br>Thanks for visting our site. <br>The Coupon Code is :  <strong>$rowcode[couponcode]</strong> of the Mobile <strong>$rowcode[name]</strong>. 
 <br>1. Click the 'LIKE' button on the 'Android Festival' page -<br>
2. Copy the coupon code for the phone you want to buy. <br>
    3. Go to Saholic.com and choose your product, and <br>
4. Apply the coupon code on the cart page to get the discount.<br>
5. Click <a href='3gmobile.co.in'>3Gmobile.co.in</a> to open";

 $smsmessage="Dear ".$_POST['name'].", Thanks for visting our site. The code is : $rowcode[couponcode]";
 $status='0';
 if(mail($_POST["email"], $subject, $body, $headers))
  {
   $status='1';
   sendSMS($_POST["phone"], $smsmessage);
   mysql_query("insert into buy_details (buyername, buyeremail, buyerphone, model) values ('".$_POST['name']."', '".$_POST['email']."', '".$_POST['phone']."', '$rowcode[name]')");
   $url="phone_details.php?id=".$_REQUEST['id']."&model=".$_REQUEST['model'];
   echo "<meta http-equiv=\"refresh\" content=\"1;URL=$url\" />";
}

Dani AI

Generated

— When an anchor works in Gmail but not in Yahoo/Indiatimes the usual culprits are: the href is not a full URL with a scheme (http:// or https://), the HTML in the message has been HTML-escaped so the client sees literal "&lt;a&gt;" text, or the mail client is rewriting/stripping suspicious links. Gmail often auto-detects bare domains; other webmail clients are stricter.

First, inspect the raw message source in Yahoo/Indiatimes to confirm what the client actually received. Look for a real <a href="..."> tag in the source. If you see &lt;a or &amp;lt;a the body was escaped before sending and must be sent as real HTML. Also ensure the href contains an absolute URL beginning with http:// or https:// and that query parts are URL-encoded and use &amp; inside the attribute.

A minimal safe pattern for the HTML body looks like:

$body  = '<html><body>';
$body .= 'Dear ' . htmlspecialchars($_POST['name'], ENT_QUOTES) . ',<br>';
$body .= 'Click: <a href="https://3gmobile.co.in/phone_details.php?id=' . urlencode($_REQUEST['id']) . '&amp;model=' . urlencode($_REQUEST['model']) . '&amp;redirect=1">3Gmobile.co.in</a>';
$body .= '</body></html>';

Also make sure the mail headers indicate an HTML message and that you send with proper line endings. If links are still altered, check deliverability (use authenticated SMTP, SPF/DKIM) because some providers rewrite or block links in messages that look unauthenticated. See the PHP mail() documentation for header handling and the HTML <a> element docs for href rules: PHP mail() manual, MDN <a> element.

Quick checklist: raw source shows <a> tag, href starts with scheme, query parts urlencoded, message sent as HTML, and mailer uses authenticated delivery.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.