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 cys@kdkd.com 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= "xyz@gmail.com";	
    $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
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.

Link to comment
Share on other sites

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 = user@domain.com

 

==

 

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

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.