PHP Multipart Email Getting Cut Off
By sending multipart emails we can send two versions of the same email at the same time; One sexy HTML version containing all the bells and whistles for modern email clients, and a fallback plain text version for older email clients or users who have HTML formatting disabled.
Without the use of a class or framework I’ve always found sending multipart emails with the PHP mail() function a bit fiddly and hard to debug if something is wrong. This was confirmed earlier today when a script I was writing to perform this function resulted in emails having the first section cut off.
After nearly going bald through pulling my hair out over this (that’s a lot of hair!) it turns out the issue was caused by using a mixture of both ‘\n’ and ‘\r\n’ as new line characters in the email headers. Changing them all to read ‘\r\n’ resolved the issue right away and the full email was now coming through.