Reputation: 6676
I'm using the following to generate a SwiftMail message (excuse the wrappers)
$message = $mailHelper->createMessage(); // This is an instance of Swift_Message
$message->setTo($addresses)
->setFrom([$template->getEmail() => $template->getName()])
->setSubject($template->getSubject())
->setBody($template->getTextContent($twig, $replacements), 'text/plain');
$message->addPart($template->getHtmlContent($twig, $replacements), 'text/html');
$mailHelper->sendMessage($message)
I receive the message ok, but in gmail it shows me the text version. All the encoding looks correct to me.
Return-Path: <[email]>
Received: from [127.0.0.1] (ec2-54-149-246-93.us-west-2.compute.amazonaws.com. [54.149.246.93])
by smtp.gmail.com with ESMTPSA id kv7sm1686300pab.20.2015.09.10.09.11.03
for <[email]>
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
Thu, 10 Sep 2015 09:11:04 -0700 (PDT)
Message-ID: <[email protected]>
Date: Thu, 10 Sep 2015 16:11:03 +0000
Subject: Welcome to [App]
From: [Company] <[email]>
To: "[email]" <[email]>
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="_=_swift_v4_1441901463_d2266ae39e8919de6200347d60861abb_=_"
--_=_swift_v4_1441901463_d2266ae39e8919de6200347d60861abb_=_
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
[url]
--_=_swift_v4_1441901463_d2266ae39e8919de6200347d60861abb_=_
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<a href=3D"app://[url]">[url]</a>
--_=_swift_v4_1441901463_d2266ae39e8919de6200347d60861abb_=_--
Upvotes: 1
Views: 148
Reputation: 6676
So it turns out there were two mistakes.
1) Using a custom schema in the href (which I removed from the example above because I considered it sensitive). I guess gmail considers the schema dangerous and then strips the anchor. This is actually a good thing.
2) I was in fact seeing the content from the html version, it's just the only thing that was left was the url, which is what was in the text version too.
TL;DR: Don't use a custom schema for your mobile app in emails. Route it through a browser first.
Upvotes: 1