Are you familiar with the sendmail.class.php library from Gunter Bauer?
I've used this successfully for some time to send mails with attachments. I just can't seem to get it up and running on a new host. The mail will send ok, but somehow the MIME headers are being obscured, causing gmail to not recognise it as a multipart MIME message.
All of the headers are there, and they all look ok to the named eye. But gmail just displays them in the body of the message instead of interpreting them. I can run the same script on different servers to send the same mail with the same attachment to the same gmail address. One works as expected, the other just displays the headers in the body of the mail.
When I look closely at the raw text of the generated mails, I notice two things:
The "incorrect" server appears to be somehow introducing some extra white space between the lines (even though the generating code is identical).
And I think this may actually be the problem - the "incorrect" server is adding a pair of extra headers into the mix.
"Correct" server snippet:
From: Just Someone <admin@sdljfdskljfdskj.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="1150196777448e9c292aeba"
--1150196777448e9c292aeba
Content-Type: multipart/alternative; boundary="1150196777448e9c2923567"
--1150196777448e9c2923567
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
Your file is attached
--1150196777448e9c2923567
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
<html><body>Your file is attached</body></html>
--1150196777448e9c2923567--
--1150196777448e9c292aeba
Content-Type: application/octet-stream; name="file.tgz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="file.tgz"
3Y82ZYBuIJmBJdJY+xGnIOF+wDoKrtetG5QVzJthiAOFAsvuggC9gOCcdmokDutDFgMHEaqK
Corresponding snippet from the "incorrect" server
From: Just Someone <admin@sdljfdskljfdskj.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="1150201972448eb0748ab7c"
Message-Id: <20060613123252.9705F1E047E@sdljfdskljfdskj.com>
Date: Tue, 13 Jun 2006 08:32:52 -0400 (EDT)
--1150201972448eb0748ab7c
Content-Type: multipart/alternative; boundary="1150201972448eb07485d26"
--1150201972448eb07485d26
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
Your file is attached
--1150201972448eb07485d26
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
<html><body>Your file is attached</body></html>
--1150201972448eb07485d26--
--1150201972448eb0748ab7c
Content-Type: application/octet-stream; name="file.tgz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="file.tgz"
IyEvYmluL2Jhc2gKc2VuZGF0dGFjaD0iL3Zhci93d3cvd3d3Lm1haWxleHBpcmUuY29tL2Jp
Any thoughts on this.
Is there a PHP.ini setting which could cause one server to interpret "\r\n" differently on different servers? Both are running linux.
Could the "extra" Message-ID and Date headers after the Content-Type header be causing the problem? If so, how can I stop my MTA from including these (they're not coming from the code). Both servers are running postfix.
Any help appreciated.
Thanks,
Just