I must be missing something because someone must have com across this before me....
Using MimeMail with PHP Mailer.
Current Behaviour:
Default system messages such as password retrieval or account validation are, by default, configured as plain text messages. When activating MimeMail module, method mimemail_prepare_message() uses:
// Body is empty, this is a plaintext message.
if (empty($body)) {
$plain = TRUE;
}
So it automatically wraps the plain text message as HTML, completely messing up the way it is displayed.
Expected Behaviour:
MimeMail is able to detect plain-text messages automatically based on body content and prepare message accordingly.
As per this post:
http://chrisrockwell.com/using-the-mime-mail-drupal-project-to-send-plai...
By default MimeMail does not behave well with messages that are prepared not thinking in setting the "PLAIN" and "PLAINTEXT" parameters.
Comment | File | Size | Author |
---|---|---|---|
#3 | 2235939-subject-encoding-html-body_0.patch | 1.58 KB | david_garcia |
Comments
Comment #1
david_garcia CreditAttribution: david_garcia commentedHere goes a patch:
- Try to detect plain text messages.
- Make sure that message subject is properly ASCII encoded as per standards.
Comment #2
david_garcia CreditAttribution: david_garcia commentedOriginal patch had 2 issues:
- Added BOM to file!!! what a mess....
- Missing whitespace before encoded subject + comment on why we should have this.
Comment #3
david_garcia CreditAttribution: david_garcia commentedtry to retest...
Comment #4
sgabe CreditAttribution: sgabe commentedIt is by design to convert all site mails to HTML when using Mime Mail as the default mail system.
Comment #5
Steven Jones CreditAttribution: Steven Jones commentedSo if you want to be able to send a specific mail by a certain mail handling system, then I highly recommend the Mail System module which allows you to do just this. So you can have a specific email as HTML and then everything else as plaintext etc.
Comment #6
david_garcia CreditAttribution: david_garcia commentedIt does not look to me like a good "default" behaviour. I mean, either core is wrong, ir Mime Mail is wrong, let me explain:
- MimeMail assumes that for a message to be plain text, it should include $message['params']['plain'] = TRUE, $message['params']['plaintext'] = $body;
- In many places (including core) and contributed modules they are sending out plain text e-mails without using ['plain'] or anything like that, they assume everything is plain text.
Based on those premises, if you plug in MimeMail as default Mail System some outbound e-mails might get easily broken if, for example, they include non encoded HTML characters.
So... why not make MimeMail a little bit smarter and instead of assuming everything thrown at it is HTML perform a simple check:
if (strlen($body) == strlen(strip_tags($body))) {
to make a final decision on whether the incoming mail is actualy HTML...
@Steven Jones: You are totally right, and I have been using Mail System all along, but it is a pain in the **** to start fracturing your installation among differente Mail Systems, not to mention, that it is a try-test-catch procedure to detect which outbound mails are compatible with MimeMail and which not.
With the above patch I was able to use MimeMail as default mail system and do not need the MailSystem module in many of my installations (except for those with ubercart, it uses it's own and conflictive mail processing system).
Comment #7
sgabe CreditAttribution: sgabe commentedIt is not just about the content but also the styling of a message. Currently you are able to create a HTML layout and use CSS to send out pretty emails as site messages. Your proposed change would not allow that anymore.
Comment #8
sgabe CreditAttribution: sgabe commentedIn #2066263: Emails Written in Plain Text do not Include Paragraph or Line Break Tags I have added a note about the necessary filters when using MimeMail system as default.
Comment #9
sgabe CreditAttribution: sgabe commentedClosed due to no activity.