Jump to content

Mail sending error! Please help.


ramki067

Recommended Posts

Hi,

 

I'm getting the below error while sending mail.

 

Error:

Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for [email protected] in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mail.php on line 39

 

Code:

  if (isset($_POST["submit"])) {

    $to = strip_tags($_POST["to"]);
    $sub = strip_tags($_POST["sub"]);
    $feedback = strip_tags($_POST["feedback"]);
    $from = strip_tags($_POST["from"]);	
    $to= "[email protected]";	
    $sendto = $to;
    $subject = $sub;
    $message = $feedback;
    $headers ="MIME-Version:1.0\r\n";
    $headers .="content-type:text/html; Charset=iso-8859-1\r\n";
    $headers .="From:     <" . "$from" . ">\r\n";
    $headers .="X-Sender: <" . "$sendto" . ">\r\n";
    $headers .="Return-Path: <" . "$sendto" . ">\r\n";
    $headers .="Error-To: <" . "$sendto" . ">\r\n";
    $sendto = trim($sendto);
     $themail= mail($sendto, $subject, $message, $headers) ;
     
    
  }

 

Kindly help.

Thanks,

Ramki

Link to comment
https://forums.phpfreaks.com/topic/220113-mail-sending-error-please-help/
Share on other sites

Ive not used windows in a number of years so I'm not sure what options are around. Mail servers are quite complex at the best of times so its not something I would recommend just for development purposes.

 

Instead of using php's built in mail function, you might try google'ing for a third party class such as 'PHPMailer'. This will allow you to use a remote smtp server such as that provided by your isp.

edit your php.ini

look for smtp, and fill in your smtp server and make sure that the e-mailaddress that you specify at the  send from line is an address in that maildomain.

 

==

[mail function]

; For Win32 only.

SMTP = mail.domain.com

smtp_port = 25

 

; For Win32 only.

sendmail_from = [email protected]

 

==

 

in some cases port 25 is blocked, you can then try port 25025

 

Actually, the error message indicates that you do have a mail server present, but you are not satisfying the requirements to get it to handle an email.

 

The most likely cause of that error is because you are putting the arbitrarily entered email address from the form into the From: address. You must set the From: address to be a valid mail box at the sending mail server and you need to put the arbitrarily entered email address from the form into the Reply-to: address. The second most likely cause is that your web host requires you to use SMTP Authentication unconditionally in order to send an email through the mail server.

 

You would trust a letter that had a From address of your bank but the postmark (where it was sent from) was a completely different country then where your bank is located?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.