Mail Server Response - 551 User not Local Cannot Relay

Hello friends,

I am new here and hope I am posting this in the correct section. I am experiencing a problem with sending email using PHP.

I have Apache, PHP and Argosoft installed on my computer.

The error I get when I try to send an email via a web form is:

Warning: mail(): SMTP server response: 551 User not local. We don't relay in C:\Users\samijo.people\Documents\Programs\USB Webserver\root\index_reply.php on line 14

The code on line 14 is:

mail($to,$subject,$txt,$headers);

I kindly seek your guidance on how to work around this.

Now days, for a mail server to send an email, either (or both) the To: email address or the From: email address must be hosted at the sending mail server (email address has the same domain name as the hosting/mail server) or the sending mail server must has an SPF dns record that indicates the sending mail server is authorized to send email for the domain in the From: email address, otherwise the sending mail server thinks you are trying to relay email through it without proper authorization.

You can get a mail server to accept and send an email when both the To: and From: email addresses don’t meet the conditions mentioned above, by using SMTP authentication, and essentially ‘login’ to your account at the mail server, which the php mail() function doesn’t support. To use SMTP authentication, you will either need to exchange smtp commands directly with the mail server (requires that you write and test a bunch of code) or more simply use one of the php mailer classes - phpmailer or swiftmailer, which will do this for you.

Depending on what your application is trying to accomplish with these emails, you can either make sure that one (or both) of the To: or From: email addresses is hosted at the sending mail server or you have a properly set up SPF dns record or you need to use SMTP authentication.

So, what exactly are these emails for?

Note: A common mistake is to use an email address that is entered in a ‘contact us’ form as the From: email address. This is not correct. These emails are NOT being sent from the email addresses that someone entered in a form and this doesn’t satisfy the conditions I have listed above and can cause the error you are receiving.

Thank you very much.

I changed the emailed under $from to one registered on the localhost and it worked.

The purpose of the email was just to test and for learning purposes, nothing more.

Sponsor our Newsletter | Privacy Policy | Terms of Service