Why am I getting exception 'Swift_Connection_Exception'?
Posted: Wed Jul 11, 2007 6:54 pm
I am using Swift-3.0.3-php5
I am trying to send an email--a pretty simple one... and for some reason, no matter what I do, I get this exception thrown when I send()
My code:
I am trying to send an email--a pretty simple one... and for some reason, no matter what I do, I get this exception thrown when I send()
Code: Select all
exception 'Swift_Connection_Exception' with message 'Expected response code(s) [250] but got response []' in /vservers/chicorotaryc/phplib/Swift-3.0.3-php5/lib/Swift.php:252 Stack trace: #0 /vservers/chicorotaryc/phplib/Swift-3.0.3-php5/lib/Swift.php(305): Swift->assertCorrectResponse(Object(Swift_Events_ResponseEvent), 250) #1 /vservers/chicorotaryc/phplib/Swift-3.0.3-php5/lib/Swift.php(314): Swift->command('RSET', 250) #2 /vservers/chicorotaryc/phplib/Swift-3.0.3-php5/lib/Swift.php(395): Swift->reset() #3 /vservers/chicorotaryc/htdocs/members/library/Rotary/Controller/Action.php(288): Swift->send(Object(Swift_Message), Object(Swift_RecipientList), Object(Swift_Address)) #4 /vservers/chicorotaryc/htdocs/members/application/controllers/PasswordController.php(65): Rotary_Controller_Action->_sendMail(Array, 'Password Reset', Array, NULL) #5 /vservers/chicorotaryc/htdocs/members/application/controllers/PasswordController.php(44): PasswordController->sendEmail(Object(Table_User)) #6 /vservers/chicorotaryc/htdocs/members/application/controllers/PasswordController.php(7): PasswordController->processPasswordReset() #7 /vservers/chicorotaryc/phplib/ZendFramework-0.6.0/library/Zend/Controller/Dispatcher.php(436): PasswordController->indexAction() #8 /vservers/chicorotaryc/phplib/ZendFramework-0.6.0/library/Zend/Controller/Front.php(725): Zend_Controller_Dispatcher->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #9 /vservers/chicorotaryc/htdocs/members/index.php(149): Zend_Controller_Front->dispatch() #10 {main}Code: Select all
require_once 'Swift.php';
require_once 'Swift/Connection/SMTP.php';
require_once 'Swift/Authenticator/LOGIN.php';
if (!$config = new Zend_Config_Ini('./config/config.ini', 'mail'))
{
throw new Rotary_Exception('Cannot read from ./config/config.ini - please ensure it is there and has the proper [mail] section');
}
if (!is_a($this->_mailserver, 'Swift_Connection'))
{
$this->_mailserver = new Swift_Connection_SMTP($config->server);
}
$swift = new Swift($this->_mailserver);
$this->_mailserver->setUsername($config->user);
$this->_mailserver->setPassword($config->pass);
$this->_mailserver->attachAuthenticator(new Swift_Authenticator_LOGIN());
$recipients = new Swift_RecipientList();
foreach ($recips as $name => $email)
{
$recipients->addTo($email, $name);
}
if (empty($from))
{
$from = new Swift_Address($this->_config->email_from_address, $this->_config->email_from_name);
}
else
{
$from = new Swift_Address($from['email'], $from['name']);
}
$message = new Swift_Message($subject . " - " . $this->_config->site_name);
$message->attach(new Swift_Message_Part($emailBody['plain']));
if (array_key_exists('html', $emailBody))
{
$message->attach(new Swift_Message_Part($emailBody['html'], "text/html"));
}
try
{
if ($batch)
{
$numSent = $swift->batchSend(
$message,
$recipients,
$from
);
}
else
{
$numSent = $swift->send(
$message,
$recipients,
$from
);
}
} catch (Swift_Connection_Exception $e) {
echo $e;
}