views:

1347

answers:

1

I have a problem sending plain text emails using PHPMailer.

I have text that I read from a text file and mail it to mail recipient via PHPMailer

When the recipient gets the actual email, the formatting of the mail is not like in the text file, everything is in one line, no new lines and tabs are included in the email that I send. Text wrapping is totally off.

Code:

        $mail->ContentType = 'text/plain'; 
        $mail->IsHTML(false);
        $address = "[email protected]";
        $mail->AddAddress($address, "John Doe");

        $mail->SetFrom(EMAIL_TEST_FROM);

        $mail->AddReplyTo(EMAIL_TEST_REPLY);



        $mail->Subject = $action." REGISTRATION ".$formName.$tld;
        $mail->From = EMAIL_TEST;  

        $mail->MsgHTML(file_get_contents($newFile));


        if($mail->Send()){
            return true;
        }
+3  A: 

you are setting msghtml to a plain text message. html ingores whitespace formatting

i haven't used it for a while, but from memory try

$mail->Body    = file_get_contents($newFile);
bumperbox
Yip, this did the trick
Roland