Call for assistance: SMTP Authentication + MimeMail integration

Events happening in the community are now at Drupal community events on www.drupal.org.
allie micka's picture

One of the questions that came up was how to leverage the consistent theme and UI of MimeMail when you've got deliverability issues with your hosting environment.

The solution to deliverability issues is to use the excellent. SMTP Authentication module. However, due in part to Drupal's architecture and SMTP Authentication's implementation, MimeMail and SMTP Authentication may be mutually exclusive in some cases:

http://drupal.org/node/132903
http://drupal.org/node/149984
http://drupal.org/node/111690
http://drupal.org/node/66711

( plus at least twice that many dupe's and 3 times as many forum questions ). This may also prevent other modules that rely on MimeMail from working ( e.g. Send or SimpleNews ), and prevents the ability to send themed system messages.

The fix is a relatively small change to the smtp module: Implement a hook_mailengine() in the SMTP module, and conditionally enable the drupal_mail_wrapper() function in that module - in case another module ( e.g. devel or mimemail ) has already gobbled up this namespace.

Anyone with the time and inclination to follow up on this will be doing lots of folks a big favor!

Comments

There is someone actively

oadaeh's picture

There is someone actively working on this issue. Hopefully he will post here with news, information, questions, etc.

I started looking into this last night

jsm174's picture

I was at your presentation at Drupalcon and I really wanted to help out. I'm somewhat new to this, so please bare with me.

I made the changes suggested in http://drupal.org/node/132903.

As I was making the changes, I ended up making Mime Mail a dependency for SMTP.

That probably wasn't the best approach. The SMTP module should pretty much work just the way it works now if mime mail isn't installed.

So I'm wondering for what conditions should the variable smtp_library not be set and drupal_mail_wrapper not be included.
I'm guessing whenever mime mail exists and is active and smtp_on is enabled.

One thing that is confusing is the E-mail engine setting on the Mail admin page. If the SMTP module is enabled and installed, would it be a good idea for mime mail to just force that setting to the SMTP mail engine.

Finally, one last thing I noticed was the send loop in the smtp_mailengine.

   foreach ($message['address'] as $a) {
    .
    .
    .
   }

I'm not sure if it's just my connection, but this is very slow using Gmail over SSL.

As it is now, I'm pretty sure the SMTP module groups all the recipients together and sends out one email.

Given some feedback, I should have a preliminary patch Tuesday or Wednesday.

-- Jason

Need to add multipart/alternative to SMTP...

jsm174's picture

Sorry for taking so long to get back to this. Turns out Drupalcon Boston was very good to me in outside work endeavours.

In the SMTP module, I wrapped drupal_mail_wrapper with _drupal_mail_wrapper(). If the MimeMail module is present, drupal_mail_wrapper() will never be added. If MimeMail exists, the smtp_mailengine() function is added which calls the wrapped _drupal_mail_wrapper().

I have a dilemma when it comes to mimemail_rfc_headers(). Since MimeMail takes care of formatting the body and the headers, I'd rather just call the SmtpSend() directly in PHPMailer. I guess though that defeats the purpose of how PHPMailer is supposed to be used...

Anyway, using default MimeMail settings with the SMTP module via the Contact Page, the content type comes back as multipart/alternative. I modified _drupal_mail_wrapper() to handle this. Current HEAD does not, so you end up getting a message that contains the boundary information.

I'm going to run some tests trying to sending attachments so we'll see what happens.

-- Jason

Attachments work

jsm174's picture

I just tested attachments and they work fine.

I went back to MimeMail and turned on Plain Text only. In this case the attachment did not go through. Just wanted to make sure this works as expected.

Use GMail via SMTP the from is still incorrect. I'll play a little more with unless someone objects, I'll put the patch under:

http://drupal.org/node/132903

-- Jason

I strongly recommend to use

anybody's picture

I strongly recommend to use "phpmailer.module" for Drupal 7. After lots of WTF's I decided to change from SMTP to PHPMailer and everything worked fine ad hoc.

Mail

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: