Swiftmail error in establishing connection
Posted: Tue May 22, 2007 7:30 am
feyd | Please use
Regards,
Rajesh.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi friends,
I'm new to swiftmail.
I tried in many ways to send emails, using smtp and sendmail, both failed.
My server is Linux, PhP5
following are the errors, please help.
[b]Error while using smtp.gmail.com :
[/b]Fatal error: Uncaught exception 'Swift_Connection_Exception' with message 'The SMTP connection failed to start [tls://smtp.gmail.com:465]: fsockopen returned Error Number 111 and Error String 'Connection refused'' in /home/heeragroup/swiftmail/lib/Swift/Connection/SMTP.php:277 Stack trace:
#0 /home/heeragroup/swiftmail/lib/Swift/Connection/SMTP.php(277): Swift_Connection_SMTP::start()
#1 /home/heeragroup/swiftmail/lib/Swift.php(220): Swift_Connection_SMTP->start()
#2 /home/heeragroup/swiftmail/lib/Swift.php(97): Swift->connect()
#3 /home/heeragroup/swiftmail/test1.php(12): Swift->__construct(Object(Swift_Connection_SMTP))
#4 {main} thrown in /home/heeragroup/swiftmail/lib/Swift/Connection/SMTP.php on line 277
[b]Error while using my own smtp server :[/b]
Fatal error: Uncaught exception 'Swift_Connection_Exception' with message 'The SMTP connection failed to start [tls://mail.smcsindia.com:465]: fsockopen returned Error Number 110 and Error String 'Connection timed out'' in /home/heeragroup/swiftmail/lib/Swift/Connection/SMTP.php:277 Stack trace:
#0 /home/heeragroup/swiftmail/lib/Swift/Connection/SMTP.php(277): Swift_Connection_SMTP::start()
#1 /home/heeragroup/swiftmail/lib/Swift.php(220): Swift_Connection_SMTP->start()
#2 /home/heeragroup/swiftmail/lib/Swift.php(97): Swift->connect()
#3 /home/heeragroup/swiftmail/testsendmail.php(13): Swift->__construct(Object(Swift_Connection_SMTP))
#4 {main} thrown in /home/heeragroup/swiftmail/lib/Swift/Connection/SMTP.php on line 277
[b]Error while using sendmail option :[/b]
Fatal error: Uncaught exception 'Swift_Connection_Exception' with message 'There was a problem reading line 1 of a sendmail SMTP response. The response so far was:
[]. It appears the process has died.' in /home/heeragroup/swiftmail/lib/Swift/Connection/Sendmail.php:203 Stack trace:
#0 /home/heeragroup/swiftmail/lib/Swift/Connection/Sendmail.php(203): Swift_Connection_Sendmail::pipeOut()
#1 /home/heeragroup/swiftmail/lib/Swift/Connection/Sendmail.php(237): Swift_Connection_Sendmail->pipeOut()
#2 /home/heeragroup/swiftmail/lib/Swift.php(307): Swift_Connection_Sendmail->read()
#3 /home/heeragroup/swiftmail/lib/Swift.php(221): Swift->command('', 220)
#4 /home/heeragroup/swiftmail/lib/Swift.php(97): Swift->connect()
#5 /home/heeragroup/swiftmail/testsendmail.php(14): Swift->__construct(Object(Swift_Connection_Sendmail))
#6 {main} thrown in /home/heeragroup/swiftmail/lib/Swift/Connection/Sendmail.php on line 203
and the code is;Code: Select all
$subj = "Testing Email";
$body = @file_get_contents("h.html") or die("Error : Couldnt get html file h.html");
require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";
require_once "lib/Swift/Connection/Sendmail.php";
[b]My SMTP : [/b]$smtp = new Swift_Connection_SMTP("mail.<my domain name>.com"
[b]Gmail : [/b]$smtp = new Swift_Connection_SMTP("smtp.gmail.com", Swift_Connection_SMTP::PORT_SECURE, Swift_Connection_SMTP::ENC_TLS);
$smtp->setUsername("<emailid>");
$smtp->setpassword("<password>");
$swift =& new Swift($smtp);
[b]Sendmail : [/b]$swift =& new Swift(new Swift_Connection_Sendmail(Swift_Connection_Sendmail::AUTO_DETECT));
$message =& new Swift_Message("My subject", "My body");
$recipients =& new Swift_RecipientList();
$recipients->addTo("<my email id 1>");
$recipients->addTo("<my email id 2>");
$num_sent=$swift->batchSend($message, $recipients, new Swift_Address("<from email>", "<from name>"));
if($num_sent) echo "Success"; else echo "Failed";Rajesh.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]