ramki067 Posted November 29, 2010 Share Posted November 29, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/220113-mail-sending-error-please-help/ Share on other sites More sharing options...
trq Posted November 29, 2010 Share Posted November 29, 2010 Do you have a mail server installed on the machine the code is executing on? Quote Link to comment https://forums.phpfreaks.com/topic/220113-mail-sending-error-please-help/#findComment-1140808 Share on other sites More sharing options...
ramki067 Posted November 29, 2010 Author Share Posted November 29, 2010 How do i install it? I've PHP.info displaying the below variables and there values: sendmail_from no value no value sendmail_path no value no value serialize_precision 100 100 short_open_tag On On SMTP localhost localhost smtp_port 25 25 Quote Link to comment https://forums.phpfreaks.com/topic/220113-mail-sending-error-please-help/#findComment-1140810 Share on other sites More sharing options...
trq Posted November 29, 2010 Share Posted November 29, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/220113-mail-sending-error-please-help/#findComment-1140822 Share on other sites More sharing options...
mdgeus Posted November 29, 2010 Share Posted November 29, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/220113-mail-sending-error-please-help/#findComment-1140829 Share on other sites More sharing options...
PFMaBiSmAd Posted November 29, 2010 Share Posted November 29, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/220113-mail-sending-error-please-help/#findComment-1140862 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.