Given an email as raw text, how can I send it using PHP?

I had the same problem but found a solution that seams to work. Open a socket in PHP and “telnetting” the raw emaildata. Something like this: $lSmtpTalk = array( array(‘220’, ‘HELO my.hostname.com’.chr(10)), array(‘250’, ‘MAIL FROM: [email protected]’.chr(10)), array(‘250’, ‘RCPT TO: [email protected]’.chr(10)), array(‘250’, ‘DATA’.chr(10)), array(‘354′, $lTheRawEmailStringWithHeadersAndBody.chr(10).’.’.chr(10)), array(‘250’, ‘QUIT’.chr(10)), array(‘221’, ”)); $lConnection = fsockopen(‘mail.anotherhost.dk’, 25, $errno, $errstr, 1); … Read more

Email from PHP has broken Subject header encoding

Update   For a more practical and up-to-date answer, have a look at Palec’s answer. The specified character encoding in Content-Type does only describe the character encoding of the message body but not the header. You need to use the encoded-word syntax with either the quoted-printable encoding or the Base64 encoding: encoded-word = “=?” charset “?” encoding … Read more