Swift_ConnectionException Error Message and unknown issue

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
soarchrist
Forum Newbie
Posts: 4
Joined: Wed Sep 20, 2006 11:25 pm

Swift_ConnectionException Error Message and unknown issue

Post by soarchrist »

OK,

We have an intranet that sends out reminder emails once a day and uses a remote SMTP server since the local server doesn't handle email. I switched to Swift Mailer b/c I like it's ease of use and such, but I'm having some problems getting it to work. My test script is the following and the error I get is just after that. Can anyone tell me what is wrong? I'm sorry, but I removed some variables that are private... but you get the idea. The email addresses/passwords are all valid... no facades.

Code: Select all

require_once "inc/mail/Swift.php";
require_once "inc/mail/Swift/Connection/SMTP.php";
 
$smtp =& new Swift_Connection_SMTP("69.64.68.138");
$smtp->setUsername("ValidFromAddress");
$smtp->setpassword("********");
 
$swift =& new Swift($smtp);
 
$message =& new Swift_Message("Some subject", "Your message <u>here</u>", "text/html");
 
if ($swift->send($message, "ValidToAddress", "ValidFromAddress"))
{
    echo "Message sent";
}
else
{
    echo "Message failed to send";
}
 
//It's polite to do this when you're finished
$swift->disconnect();
And the error message is...

Code: Select all

Fatal error: Uncaught exception 'Swift_ConnectionException' with message 'The SMTP connection did not allow the command 'EHLO [192.168.1.110]' to be sent. (fsockopen: #0) ' in C:\xampplite\htdocs\inc\mail\Swift\Connection\SMTP.php:270 Stack trace: #0 C:\xampplite\htdocs\inc\mail\Swift.php(299): Swift_Connection_SMTP->write('EHLO [192.168.1...', '??') #1 C:\xampplite\htdocs\inc\mail\Swift.php(261): Swift->command('EHLO [192.168.1...', 250) #2 C:\xampplite\htdocs\inc\mail\Swift.php(220): Swift->handshake(Object(Swift_Events_ResponseEvent)) #3 C:\xampplite\htdocs\inc\mail\Swift.php(101): Swift->connect() #4 C:\xampplite\htdocs\test.php(11): Swift->__construct(Object(Swift_Connection_SMTP)) #5 {main} thrown in C:\xampplite\htdocs\inc\mail\Swift\Connection\SMTP.php on line 270
The error message appears quite quickly... enough to make me think it's not really trying. I'm running Xampplite which is a great Apache server environment on a Windows pc... and of course it's updated as of last week with PHP 5.2.5.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Swift_ConnectionException Error Message and unknown issue

Post by Chris Corbyn »

Something is causing fgets() or fwrite() to return FALSE when reading or writing to the socket. Could there be a firewall rule blocking it? The reason it happen so fast is that this is the very first step in the process and Swift is being stopped dead before it can even start ;)
soarchrist
Forum Newbie
Posts: 4
Joined: Wed Sep 20, 2006 11:25 pm

Re: Swift_ConnectionException Error Message and unknown issue

Post by soarchrist »

Thanks... and like I expected it to be some kind of firewall b/c of the speed at which it was quitting, a firewall was the problem. However, it wasn't the MS Firewall, it was my version of Avast Antivirus... and after updating the program, the problem went away... so go figure. It appears emails are sending just fine.
Post Reply