Warning: mail() [function.mail]: SMTP server response: 553 We do not relay non-local mail, sorry

Resolvendo: In Xampp menu,
Go to mercury admin-->Configuration menu-->MercuryS SMTP Server-->Connection control. In that window, remove the check on the checkbox. See below:

enter image description here

Then in php.ini file:

[mail function] SMTP=127.0.0.1 <------------------change localhost to ip local

smtp_port=25


Warning: mail() [function.mail]: SMTP server response: 553 We do not relay non-local mail, sorry. in E:\xampp\htdocs\feedback.php on line 19 mail sent successfully

That means your server is not properly configured. It should be able to send mails through some smarthost which allows relaying from your system. On a real server this is likely to be the MTA running on localhost.

Also tell why we have to write $subject , $message i.e with the $ sign in the mail argument , since we have declared $email , $message etc. , just above. Why can't we just write message , email , .. without the dollar sign?

That's because variables are prefixed with $ in PHP.


  1. You're using XAMPP which by default comes with Mercury, which is not configured to send mail to a different server by default. It is basically there for debugging. Instructions do exist to configure it to do so, but Windows + Apache is generally best only as a debugging environment in my experience.

  2. PHP variables all have the $ before them. It's called a sigil. It is what distinguishes them from, say, constants, class definitions, and functions. If you want to assign a value and then send it into a function, you need to use variables. You can use define to set a constant if it is important enough, but trust me, those situations are rare and you should generally avoid them.

You can also do this, however:

mail("[email protected]" , 
      $_REQUEST['subject'] , 
      $_REQUEST['message'] , 
      "From:".$_REQUEST['email'] );

Tags:

Php

Email