Is my mailbox set up correctly?

Is the following "From" header included?

    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    // Additional headers
    $headers .= 'From: Mail Master <mail@mailmaster.com>' . "\r\n";
if(sendEmailNow($email, $subject, $body, $headers)){

      

I am getting an error from my mail server. It says "Mail from error: Syntax error".

Thanks everyone for any help.

Update

I have disabled SendEmailNow feature until below and I am getting the same error:

//send an email
function sendEmailNow($email, $subject, $body, $headers){

    if (mail($email, $subject, $body, $headers)) {
      ##check email
      ##code to say email sent - compare with the number registered
      return true;
     }

     else {
      ##code to report an error 
      return false;
     }

 }

      

Update 2

The problem has been resolved. I am running this on a Windows machine using PHP 5. Like the correct answer and comments have been made. Some mail servers have problems understanding what I had earlier. But what worked for me was this:

$headers .= 'From: mail@mailmaster.com' . "\r\n";

      

0


source to share


5 answers


A Google search for the error message suggests that some SMTP servers are unable to parse your header syntax From

. Can you try the following syntax to eliminate this possibility?



From: mail@mailmaster.com

      

+4


source


If the body is empty, you may need additional CRLFs to complete the headers. Without knowing the API, I can't say much more.



+1


source


Not sure if it helps, but this is what the output headers look like in my Python application in plain text:

Content-Type: multipart / alternative;
    boundary = "10.254.26.130.1.1364.1241389770.060.1"
From: User1 < user1@domain1.com >
To: User2 < user2@domain1.com >, User3 < user3@domain.com >
Subject: Actual subject
MIME-Version: 1.0


--10.254.26.130.1.1364.1241389770.060.1
Content-Type: text / plain;
    charset = "us-ascii"
Content-Transfer-Encoding: quoted-printable

actual text content starting here ...

Again, not knowing all the content / headers is hard to tell, but I would assume either a) you left out the CRLF before the content, or b) one of the previous headers missed its CRLF.

Sorry if this takes you in a wildly wrong direction. :)

0


source


From: "User1" <user1@domain1.com>

      

The From header requires quotation marks for the name part.

0


source


If you set the $ userEmail variable on your form, you can get it from them and respond. $ Email_id is your email address it was sent to.

        $to=$email_id;
        $headers = "From: " . strip_tags($userEmail) . "\r\n";
        $headers .= "Reply-To: ". strip_tags($userEmail) . "\r\n";

      

0


source







All Articles