1

I'm using PHP and SendGrid to send emails, within the content of the email there are some links but gmail removes the href from all of them, this does not happen with other providers such as iCloud.

For expmaple, the result of:

<a href="https://espn.com" target="_blank" rel="noopener">ESPN</a>

Is:

<a rel="noopener">ESPN</a>

Even the target is removed sometimes

My domain is already verified in the mail provider (SendGrid), what I can do?


Code:

$email = new \SendGrid\Mail\Mail(); 
$email->setFrom("myemail@icloud.com", "Header text");
$email->setSubject('Subject');
$email->addTo("customer@gmail.com", 'Customer name');
$email->addContent(
    "text/html", '<a href="https://espn.com" target="_blank" rel="noopener">ESPN</a>'
);
$sendgrid = new \SendGrid('theToken');
try {
    $response = $sendgrid->send($email);
    /* print $response->statusCode() . "\n";
    print_r($response->headers());
    print $response->body() . "\n"; */
} catch (Exception $e) {
    /* echo 'Caught exception: '. $e->getMessage() ."\n"; */
}

GMail Sample: enter image description here

iCloud Sample: enter image description here


As can you see, the problem is only in gmail

1 Answers1

0

Gmail seems to remove links from spam emails. Have you noticed that both your mail clients have identified this email as spam? Our PHP based mail solution sends emails with links to GMail without issue. If you send such email to yourself, you will not encounter a problem: email with link from myself

So the solution is to ensure that you are trusted as the sender of emails. Gmail has guidelines for this.

seeker
  • 806
  • 4
  • 7