Page 1 of 1

Can't send mail - bad response code

Posted: Thu Nov 30, 2006 12:44 pm
by AvramYU
Hi,
I can't send email using e.g. following code:

Code: Select all

require('./Swift.php');
require('./Swift/Connection/SMTP.php');

function mailto($to,$subject,$body,$from) {
	$mailer = new Swift(new Swift_Connection_SMTP('pcdelovi.com'));
	$mailer->setCharset("UTF-8");
	$mailer->addPart($body, "text/html");
	

//If anything goes wrong you can see what happened in the logs
if ($mailer->isConnected()) //Optional
{
	//You can call authenticate() anywhere before calling send()
	if ($mailer->authenticate('pcdelovi', 'mypassword'))
	{
		//Sends a simple email
		$mailer->send(
			$to,
			$from,
			$subject
		);
		echo "<pre>";
		print_r ($mailer); //debug
		echo "</pre>";
	}
	else return false;
	
	//Closes cleanly... works without this but it's not as polite.
	$mailer->close();
}
else return false;

return true;
	
}



$from = $_POST['email'];

$to = 'mymail@domain.com';

$subject = "Contact from website";
$body = $_POST['text'];
if ((!$from) or (!$body)) {
	header("location: err.php"); die();
} else {
	$sent = mailto($to,$subject,$body,$from);
	if (!$sent) { header("location: mailnijeposlat.php"); die(); }
		else { header("location: mailposlat.php"); die(); }
}
I get error: Send Error: Sending to 1 recipients rejected (bad response code).

What should I do?

Debug (dump log) can be found at http://www.pcdelovi.com/dump.txt

Posted: Thu Nov 30, 2006 1:33 pm
by Chris Corbyn
Your server says:
451 Temporary local problem - please try later
Do you run the server or does somebody else?

Posted: Thu Nov 30, 2006 1:37 pm
by AvramYU
Well I got it with hosting account (web site)

Posted: Thu Nov 30, 2006 1:40 pm
by John Cartwright
Please read your PM, AvramYU

Posted: Thu Nov 30, 2006 1:59 pm
by AvramYU
Don't worry 8)

Posted: Thu Nov 30, 2006 3:15 pm
by AvramYU
The error was with SMTP server. I've changed SMTP server and now it's working fine. Many thanks!

Posted: Thu Nov 30, 2006 4:29 pm
by Chris Corbyn
AvramYU wrote:The error was with SMTP server. I've changed SMTP server and now it's working fine. Many thanks!
I'd let your host know there's an issue so they can upgrade/restart the server :)

Posted: Thu Nov 30, 2006 6:44 pm
by AvramYU
I've told them but they're trying to convince me it was my fault (even after I've changed server and everything is okay).
Acctually it's not my website, it's my friend's website, so - "Who the cap fit, let them wear it"! (Bob Marley) :)