Can't send mail - bad response code

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
AvramYU
Forum Newbie
Posts: 5
Joined: Thu Nov 30, 2006 12:34 pm

Can't send mail - bad response code

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Your server says:
451 Temporary local problem - please try later
Do you run the server or does somebody else?
AvramYU
Forum Newbie
Posts: 5
Joined: Thu Nov 30, 2006 12:34 pm

Post by AvramYU »

Well I got it with hosting account (web site)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Please read your PM, AvramYU
AvramYU
Forum Newbie
Posts: 5
Joined: Thu Nov 30, 2006 12:34 pm

Post by AvramYU »

Don't worry 8)
AvramYU
Forum Newbie
Posts: 5
Joined: Thu Nov 30, 2006 12:34 pm

Post by AvramYU »

The error was with SMTP server. I've changed SMTP server and now it's working fine. Many thanks!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 :)
AvramYU
Forum Newbie
Posts: 5
Joined: Thu Nov 30, 2006 12:34 pm

Post 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) :)
Post Reply