I'm struggling with PHP's mail() function...
This code sends $strMessage as the body of the email to me@mail.com, with the subject 'Test Message' and email headers of $strHeaders. $strMessage and $strFrom are set appropriately before this code runs...
$strMessage = chunk_split( base64_encode($strMessage) ) ;
$strHeaders .= "MIME-Version: 1.0\n";
$strHeaders .= "Content-type: text/plain; charset=iso-8859-1\n";
$strHeaders .= "Content-Transfer-Encoding: base64\n";
$strHeaders .= "X-Priority: 1\n";
$strHeaders .= "X-MSMail-Priority: High\n";
$strHeaders .= "From: $strFrom\n";
$strHeaders .= "X-Mailer: PHP/".phpversion()."\n";
$strHeaders .= "X-Sender: webmaster@".$SERVER["HTTP_HOST"]."\n";
$strHeaders .= "Return-Path: -f webmaster@".$SERVER["HTTP_HOST"]."\n";
mail('me@mail.com', 'Test Message', $strMessage, $strHeaders);
The mail is delivered OK but the body of the message is split after every 2,048 characters, at which point the text "Test message.ems" is inserted into the body of the message.
It happens on Windows XP platform and Linux/Apache platform.
I just want to sent simple, plain text messages without attachments - thought it would be easy! I've tried various snippets of code that people have posted on the site but nothing gets round this problem.😕
Has anyone experienced anything similar and, if so, how did you get round it?
Cheers
Jeremy