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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

david_garcia’s picture

Status: Active » Needs review
FileSize
1.46 KB

Here goes a patch:

- Try to detect plain text messages.

- Make sure that message subject is properly ASCII encoded as per standards.

david_garcia’s picture

Original patch had 2 issues:

- Added BOM to file!!! what a mess....

- Missing whitespace before encoded subject + comment on why we should have this.

david_garcia’s picture

try to retest...

sgabe’s picture

It is by design to convert all site mails to HTML when using Mime Mail as the default mail system.

Steven Jones’s picture

So 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.

david_garcia’s picture

It 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).

sgabe’s picture

It 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.

sgabe’s picture

In #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.

If you are using Mime Mail as default mail sytem, make sure to enable Convert line breaks into HTML and Convert URLs into links with a long enough maximum length for e.g. password reset URLs!

sgabe’s picture

Status: Needs review » Closed (works as designed)

Closed due to no activity.