ronnie88 Posted July 3, 2009 Share Posted July 3, 2009 I'm having a problem When I try to register and it sends mail I get this error: Warning: mail() [function.mail]: SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in D:\Hosting\4599506\html\support\inc\functions.php on line 695 and here is that area of that file. function send_mail($from, $to, $subject, $body_mail, $headers) { require_once 'smtp.php'; $query = "SELECT * FROM support_config WHERE ID = '1'"; $req = mysql_query($query) or die("<B>Error ".mysql_errno()." :</B> ".mysql_error().""); $row = mysql_fetch_array($req); $to = stripslashes($to); $smail = $row['smail']; $host = $row['smtp_host']; $port = $row['smtp_port']; $user = $row['smtp_user']; $pass = $row['smtp_pass']; $auth = $row['smtp_auth']; $subject = stripslashes($subject); $body_mail = stripslashes($body_mail); if ($smail==1){ mail($to, $subject, $body_mail, $headers); } else { $headers = $headers."To: $to\nSubject: ".$subject."\n"; if (! ($smtp = new Net_SMTP($host,$port))) { die("Unable to instantiate Net_SMTP object\n"); } if (PEAR::isError($e = $smtp->connect())) { die($e->getMessage() . "\n"); } if ($auth==1){ if (PEAR::isError($ea = $smtp->auth($user, $pass ))) { die($ea->getMessage() . "\n"); } } if (PEAR::isError($smtp->mailFrom($from))) { die("Unable to set sender to <$from>\n"); } if (PEAR::isError($res = $smtp->rcptTo($to))) { die("Unable to add recipient <$to>: " . $res->getMessage() . "\n"); } if (PEAR::isError($smtp->data($headers . "\r\n" . $body_mail))) { die("Unable to send data\n"); } $smtp->disconnect(); } } ?> Thanks, Ronnie Quote Link to comment Share on other sites More sharing options...
mattal999 Posted July 3, 2009 Share Posted July 3, 2009 Erm, its kinda self explanatory. http://cr.yp.to/docs/smtplf.html Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 3, 2009 Author Share Posted July 3, 2009 went there it shouldn't have to upgrade I'm using godaddy.. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 3, 2009 Share Posted July 3, 2009 What is a bare LF, anyway? It is an ASCII linefeed (LF) character not preceded by an ASCII carriage-return (CR) character. You are using just \n in a few places (the header for one). You need to use \r\n to meet the specification for what you are doing. Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 4, 2009 Author Share Posted July 4, 2009 So you mean like this?: function send_mail($from, $to, $subject, $body_mail, $headers) { require_once 'smtp.php'; $query = "SELECT * FROM support_config WHERE ID = '1'"; $req = mysql_query($query) or die("<B>Error ".mysql_errno()." :</B> ".mysql_error().""); $row = mysql_fetch_array($req); $to = stripslashes($to); $smail = $row['smail']; $host = $row['smtp_host']; $port = $row['smtp_port']; $user = $row['smtp_user']; $pass = $row['smtp_pass']; $auth = $row['smtp_auth']; $subject = stripslashes($subject); $body_mail = stripslashes($body_mail); if ($smail==1){ mail($to, $subject, $body_mail, $headers); } else { $headers = $headers."To: $to\r\nSubject: ".$subject."\r\n"; if (! ($smtp = new Net_SMTP($host,$port))) { die("Unable to instantiate Net_SMTP object\r\n"); } if (PEAR::isError($e = $smtp->connect())) { die($e->getMessage() . "\r\n"); } if ($auth==1){ if (PEAR::isError($ea = $smtp->auth($user, $pass ))) { die($ea->getMessage() . "\r\n"); } } if (PEAR::isError($smtp->mailFrom($from))) { die("Unable to set sender to <$from>\r\n"); } if (PEAR::isError($res = $smtp->rcptTo($to))) { die("Unable to add recipient <$to>: " . $res->getMessage() . "\r\n"); } if (PEAR::isError($smtp->data($headers . "\r\n" . $body_mail))) { die("Unable to send data\r\n"); } $smtp->disconnect(); } } ?> It still doesnt work like this Thanks, Ronnie Quote Link to comment Share on other sites More sharing options...
ronnie88 Posted July 5, 2009 Author Share Posted July 5, 2009 it still gives me the error: function send_mail($from, $to, $subject, $body_mail, $headers) { require_once 'smtp.php'; $query = "SELECT * FROM support_config WHERE ID = '1'"; $req = mysql_query($query) or die("<B>Error ".mysql_errno()." :</B> ".mysql_error().""); $row = mysql_fetch_array($req); $to = stripslashes($to); $smail = $row['smail']; $host = $row['smtp_host']; $port = $row['smtp_port']; $user = $row['smtp_user']; $pass = $row['smtp_pass']; $auth = $row['smtp_auth']; $subject = stripslashes($subject); $body_mail = stripslashes($body_mail); if ($smail==1){ mail($to, $subject, $body_mail, $headers); } else { $headers = $headers."To: $to\r\nSubject: ".$subject."\r\n"; if (! ($smtp = new Net_SMTP($host,$port))) { die("Unable to instantiate Net_SMTP object\r\n"); } if (PEAR::isError($e = $smtp->connect())) { die($e->getMessage() . "\r\n"); } if ($auth==1){ if (PEAR::isError($ea = $smtp->auth($user, $pass ))) { die($ea->getMessage() . "\r\n"); } } if (PEAR::isError($smtp->mailFrom($from))) { die("Unable to set sender to <$from>\r\n"); } if (PEAR::isError($res = $smtp->rcptTo($to))) { die("Unable to add recipient <$to>: " . $res->getMessage() . "\r\n"); } if (PEAR::isError($smtp->data($headers . "\r\n" . $body_mail))) { die("Unable to send data\r\n"); } $smtp->disconnect(); } } ?> Quote Link to comment 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.