All messages are sent as Html, regardless of whether they are actually formatted for HTML or plain text.
In AmazonSesSystem::mail() the line:
$message['message']['Body']['Html']['Data'] = $message['body'];
tells Amazon to send the body as Html.
This causes problems, for example, if you are sending a plain text message, the line breaks will be lost and the message displayed as one line.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 7.x-1.0-rc1-2502575.patch | 1.12 KB | longlivelance |
Comments
Comment #2
tkuldeep17 commentedComment #5
balintbrewsIt might have been inconvenient before this change to lose all line breaks when a message is intended to be sent as plain text. But sending the message body through
nl2br()completely breaks HTML emails with bodies that are already constructed as HTML and contain line breaks — which most of them do for the sake of readability.So HTML emails can be critically broken with the current approach, while I also understand that plain text emails are important to have line breaks in them.
I'm really not sure what the best way is to overcome this issue. Mime Mail allows users to determine their preference regarding plain text vs. HTML emails, as well as having a global fallback value. I thought this module could rely on that setting (even wrote a patch for it), then I realized that Mime Mail is not even required by this module, as Amazon outputs the necessary headers and all that just fine for HTML emails.
Comment #6
longlivelance commentedI need this module to work now and HTML emails are completely broken now as mentioned above in #5. This might not be the best solution, but I think it is going in the right direction. The rules could probably be more thought out then what I put. Basically with this patch, if the Content-Type header is not set to text\plain then email will send as html.
Comment #7
deweydb commentedThanks for the patch, this worked well for us. And we submit our vote to have this patch included in the module. Without this patch this module is completely broken for HTML emails coming from stuff like simple_news or other modules that send html template emails.
Comment #8
anish.a commentedCan be made RTBC if its working.
Comment #9
nicrodgersI agree that the fix committed in 20f8fe2 isn't the right solution. However I also think the approach in #6 isn't right, either.
Take a look at the Amazon SES API reference: the Body object can specify text, HTML or both.
This means that we need to know whether we have an email to be sent as HTML, or plain text (or both), then populate either $message['message']['Body']['Html'] or $message['message']['Body']['Text'] accordingly and not just send everything as Html.
The default Drupal-7 mailing system assumes that the message body is html and converts it to plain text before sending, and amazon_ses currently assumes the message body is html and sends it as as html.
One solution would be to add an option to the amazon_ses configuration form: Send messages as [HTML/Text] and let the site admin decide? Or we build on the idea in #6 to check the headers, but instead of always sending as HTml, we either populate $message['message']['Body']['Text'] or $message['message']['Body']['HTML'].
Thoughts?
Comment #10
Laust commentedSince an HTML mail should also contain a plain text version, both $message['message']['Body']['Text'] and $message['message']['Body']['HTML'] should be possible to be populated at the same time - and if only $message['message']['Body']['HTML'] is populated, a plain text version should be generated in lieu of $message['message']['Body']['Text'].
Comment #11
davisbenThis has been fixed in 2.0.x.