Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

email

The following script sends email using mail function . But i am unable to send an email.Upon clicking submit this gets displayed :

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

SCRIPT

<?php 
if( isset( $_REQUEST['email'] ) ) {
    $email = $_REQUEST['email'];
    $subject = $_REQUEST['subject'];
    $message = $_REQUEST['message'];
    mail("[email protected]" , $subject , $message , "From:".$email );
    echo "mail sent successfully";
}  else {
     echo "<form method = 'post' action = 'feedback.php'>
     Email of sender : <input name = 'email' type = 'text' /> <br/>
     Subject : <input name = 'subject' type = 'text'/> <br/>
     Enter your feedback here : <textarea name = 'message' rows = 15 cols = 40 > </textarea> <br/>
     <input type = 'submit'/>
     </form>";
   }
?>

I am using Apache as php server

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?

like image 967
Suhail Gupta Avatar asked Jul 24 '11 20:07

Suhail Gupta


People also ask

How do I fix 550 relaying denied?

It's likely that the email server isn't correctly set up to receive and relay messages from your organization. To fix this issue, forward this non-delivery report (NDR) to your email admin. The sender's message was routed to an email server outside Microsoft 365 that returned an error that it can't relay the message.

What is relaying in email?

Email relay is the process of transmitting an email message from one server to another. In the picture above, the local post offices would be the SMTP servers and the email transfer that happens between them is what we call 'relaying'.

How does SMTP relay work?

SMTP relay services work in a similar way. The sender's message is sent to an SMTP server and placed in a virtual envelope. The SMTP server identifies that the recipient's domain is not the sender's domain, so relay services send it off to the recipient's main email server that handles incoming messages.


2 Answers

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

like image 51
Filipe Souza Avatar answered Oct 13 '22 04:10

Filipe Souza


  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'] );
like image 5
cwallenpoole Avatar answered Oct 13 '22 05:10

cwallenpoole