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
AvramYU
Forum Newbie
Posts: 5 Joined: Thu Nov 30, 2006 12:34 pm
Post
by AvramYU » Thu Nov 30, 2006 12:44 pm
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
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Thu Nov 30, 2006 1:33 pm
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 » Thu Nov 30, 2006 1:37 pm
Well I got it with hosting account (web site)
AvramYU
Forum Newbie
Posts: 5 Joined: Thu Nov 30, 2006 12:34 pm
Post
by AvramYU » Thu Nov 30, 2006 1:59 pm
Don't worry
AvramYU
Forum Newbie
Posts: 5 Joined: Thu Nov 30, 2006 12:34 pm
Post
by AvramYU » Thu Nov 30, 2006 3:15 pm
The error was with SMTP server. I've changed SMTP server and now it's working fine. Many thanks!
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Thu Nov 30, 2006 4:29 pm
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 » Thu Nov 30, 2006 6:44 pm
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)