I encountered a problem with the attachment sent by mimemails. I used directly the mimemail interface and i attached PDF documents to the mail. Everything seems fine, but in several cases i get an PDF attachment only filled with "NULL". After a longer investigation I detected, that the problem only occurs in my MS Outlook eMail cient. In the case of using my webclient, everything worked fine.
The problem is MS Outlook and the CRLF. In the mimemail.inc file, I found the usage of chunk_split (line 312). It is used in the following way: chunk_split(base64_encode($file)).
The PHP documentation describes the following: string chunk_split ( string $body [, int $chunklen = 76 [, string $end = "\r\n" ]] )
This means in the above described case, the crlf = "\r\n" will be used. And this is a problem for MS Outlook. MS Outlook expects only a crlf = "\n".
So please replace the line 312 in the mimemail.inc with: chunk_split(base64_encode($file), 76, variable_get('mimemail_crlf', "\n"))
and the problem won't occur anymore.

#3 mimemail_1372660_01.patch514 bytessgabe
Members fund testing for the Drupal project. Drupal Association Learn more


sgabe’s picture

I can't reproduce, I have tested with Outlook 2007 and the attached PDF is fine.

eueco’s picture

Are you sure, that you have the same environment?! MS Outlook 2007 yes, but also on the server side? I am using qmail on Ubuntu 10.04. So trust me, in this combination the "\r\n" was a problem for my qmail/Outlook combination. You can also google a little bit and you will find some similar problems with the "\r\n". How ever, I changed it in my installation and now its working fine.

sgabe’s picture

Title: MS Outlook problems with mimemail pdf attachments » Set the proper line ending when calling chunk_split()
Status: Active » Fixed
514 bytes

Committed to both branches.

Status: Fixed » Closed (fixed)

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