I can't get font-style: italic
and font-size:11px
to show properly in Gmail with a HTML formatted email. Why?
<p style="font-size: 11px; font-style: italic; line-height: 1.5; word-break: break-word; text-align: center; mso-line-height-alt: 21px; margin: 0;">
<span style="font-size: 11px; font-style: italic; color: #2C3E50;">Some countries and/or payment systems are not yet supported for buy and cash-out functions.<br>Please read our <a href="https://test.com/faq/?Display_FAQ=1984">FAQ</a> for more information.</span>
</p>
What I see in the browser when opening the HTML directly (GOOD):
What I see in Gmail (NOT GOOD):
I validated the HTML with http://premailer.dialect.ca/ and it doesn't say anything is wrong in this regard. I checked many answers on Stackoverflow but none helped: 1, 2
I am sending the email using PHPMailer. On server, we use ssmtp for dispatching email. Here is the PHPMailer code:
function send_email($address, $subject, $email_template_path) {
require '/home/composer/vendor/autoload.php';
$mail = new PHPMailer(true); // true` enables exceptions
try {
//Server settings
// $mail->SMTPDebug = SMTP::DEBUG_SERVER; // Enable verbose debug output
$mail->isSMTP();
$mail->Host = 'mail.smth.net';
$mail->SMTPAuth = true;
$mail->Username = 'mailer@domain.com';
$mail->Password = 'some&pas3eWer';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = 587; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
//Recipients
$mail->setFrom('info@mydomain.com', 'Info');
$mail->addAddress($address);
$mail->addReplyTo('support@mydomain.com', 'Support');
// Attachments
// $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = file_get_contents($email_template_path); // see https://pastebin.com/raw/WUhap2DQ
$mail->send();
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
}
The issue was with improperly formatted code. In one of the style=...
I was missing a ;
.