[ACCEPTED]-Sending Plain text emails using PHPMailer-plaintext

Accepted answer
Score: 26

You are setting $mail->MsgHTML() to a plain text message, and 4 since whitespace formatting is ignored in 3 HTML, you're getting an inline text.

I haven't 2 used PHPMailer for a while, but from memory 1 try:

$mail->Body = file_get_contents($newFile); 
Score: 13
    $mail->ContentType = 'text/plain'; 
    $address = "test@test.com";
    $mail->AddAddress($address, "John Doe");



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

    // Very important: don't have lines for MsgHTML and AltBody 
    $mail->Body = file_get_contents($mailBodyTextFile);  
    // $mail->Body = $_POST["msg"];  //If using web mail form, use this line instead.

        return true;


Score: 1

Try below code which works fine:

        try {
            $mail->AddAddress('jitpal@domain.com', 'Jit Pal');
            $mail->SetFrom('testuser@domain.com', 'Test User');
            $mail->Subject = "All machine's tests.";
            $mail->Body = "All machine's tests working fine.";
            echo "<br/>Message sent successfully...<br/><br/>\n";
        } catch (phpmailerException $e) {
            echo $e->errorMessage();
        } catch (Exception $e) {
            echo $e->getMessage();


More Related questions