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("[email protected]", "Header text");
$email->setSubject('Subject');
$email->addTo("[email protected]", '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"; */
}
As can you see, the problem is only in gmail


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:
So the solution is to ensure that you are trusted as the sender of emails. Gmail has guidelines for this.