I have some PHP code that takes in data from an HTML form, creates a PDF (using fpdf), and then e-mails the user that PDF. I am using PHPMailer to send the pdf file to the user. This all seems to work fine, with a valid PDF arriving at the specified e-mail address.
In some cases, when users have forwarded on this e-mail to a third party (it's always the same third party), the third party have been reporting the PDF is unreadable (as in corrupt). It only happens on a small number of occasions, and I can't find a common theme. The messages are sent to an Office 365 system, which will also be where messages are forwarded from.
The e-mails are normally picked up by my users on their work issues iPad, from where the message will be forwarded.
Having done some digging, I have noticed that the raw content for a message with corrupted PDF look like this (the header of the BASE64 section). The xxxxx is me.
--_005_A421FDCEF50F4B6D813D37045CFF0CBExxxxxx_
Content-Transfer-Encoding: BASE64
Content-Disposition: ATTACHMENT;
size=1375857;
modification-date="Thu, 16 Jun 2016 13:18:11 GMT";
filename=xxxxx92471462.pdf;
creation-date="Thu, 16 Jun 2016 13:18:11 GMT"
Content-Type: APPLICATION/PDF;
name=xxxxxbe92471462.pdf
Content-Id: <8D340DC9CB8C174E97F546D602F2FD49@xxxxxx.com>
ReceivedfromDB3PR01MB0729eurprd01prodexchangelabscom101605123byDB3PR01MB0730
eurprd01prodexchangelabscom101605124withMicrosoftSMTPServerTLSid1515118viaMa
ilboxTransportSat11Jun2016103431+0000ReceivedfromDB5PR01CA0007eurprd01prodex
changelabscom10162149145byDB3PR01MB0729eurprd01prodexchangelabscom101605123w
ithMicrosoftSMTPServerTLSid1515118Sat11Jun2016103429+0000ReceivedfromDB3FFO1
1FD045protectiongbl2a01111f4007e04176byDB5PR01CA0007outlookoffice365com2a011
11e40051b717withMicrosoftSMTPServerTLSid1515178viaFrontendTransportSat11Jun2
...
It looks to me like somehow a load of mail headers have made their way into the BASE64, hence the attachment becoming mangled. Later on in the BASE64 it looks like more normal encoded attachment.
I doubt that this is really anything to do with the initial creation from PHPMailer, as the message is fine. It seems to me that something is mangling the e-mail structure and attachments somewhere further down the line.
Has anyone seen anything like this before?
Many thanks in advance for any pointers.