[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'; 
    $mail->IsHTML(false);
    $address = "test@test.com";
    $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;  

    // 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.


    if($mail->Send()){
        return true;
    }

0

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.";
            $mail->Send();
            echo "<br/>Message sent successfully...<br/><br/>\n";
        } catch (phpmailerException $e) {
            echo $e->errorMessage();
        } catch (Exception $e) {
            echo $e->getMessage();
        }

0

More Related questions