Jump to content

Send_Mail Help


ronnie88

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/164706-send_mail-help/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/164706-send_mail-help/#findComment-868598
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/164706-send_mail-help/#findComment-868718
Share on other sites

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();

  }

}

?>

Link to comment
https://forums.phpfreaks.com/topic/164706-send_mail-help/#findComment-869344
Share on other sites

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.