Attached is a simple patch that addresses two problems, one of which appears to the the root cause of several other open issues in the queue.

Mime Detection

The line of code that handles detection of whether or not the messages is plain text or not only works if the content-type header ONLY contains 'text/html'. This patch changes the logic to test whether or not content-type CONTAINS 'text/html'. This addresses some integration problems with the mimemail module.

From header gets mangled

Several modules call the Drupal mail wrapper with email addresses in the format "Sender Name " <sender@domain.com>. The logic within the smtp module assumes a single "Sender Name" and feeds that name (defaults to be your site name) into the phpmailer code.

The phpmailer code assumes that it has been handed two pieces of data, one is a sender name, one is a from address. In actuality the from address already contains a sender name and from address, but it does not know that. It goes ahead and combines them, producing mangled From header fields that look like

your-site-name <Sender Name <"sender"@domain.com>>

This patch adds a very simple check to the mail address formatting routine that came along with phpmailer. It looks for the open and close angle brackets in the from field. If they are present, it simply uses that address.

This has the effect of allowing modules to override the sender name and from address, which is important for many modules. I found it in the context of organic groups and sending out post notifications. OG and smtp.module don't play well nicely together.

Now they can.

Comments

suzanne.aldrich’s picture

Hi, I tried this patch out and it totally fixed the problem I had with the html showing up in the email on retrieval from gmail. Thanks for your hard work!

oadaeh’s picture

The fix for the headers problem has been committed here: http://drupal.org/cvs?commit=90617

oadaeh’s picture

Status: Reviewed & tested by the community » Fixed

The fix for the from field problem has been committed here: http://drupal.org/cvs?commit=90638

Thanks for the help.

scott.mclewin’s picture

Great, thanks for the quick turnaround.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.