Page 1 of 1

Where is close (V3 rc1)?

Posted: Mon Jan 15, 2007 5:46 pm
by RobertGonzalez
Ok, I am certain I am just not looking closely enough. Can someone point me in the direction of how to close the connection?

I tried close(), but got this error:
Fatal error: Call to undefined method Swift::close() in /bay/html/baynet-dev/tests/swift-test.php on line 27
So I changed the close to disconnect() and got this:
Fatal error: Uncaught exception 'Swift_Connection_Exception' with message 'Expected response code(s) [250] but got response 221' in /path/to/swift/Swift/Swift.php:261 Stack trace: #0 /path/to/swift/Swift/Swift.php(312): Swift->assertCorrectResponse(Object(Swift_Events_ResponseEvent), 250) #1 /path/to/swift/Swift/Swift.php(244): Swift->command('QUIT', 250) #2 /path/to/testfiles/tests/swift-test.php(27): Swift->disconnect() #3 {main} thrown in /path/to/swift/Swift/Swift.php on line 261
What am I doing wrong? As it relates to my issue, the mail is being sent as expected. I am using this test code.

Code: Select all

<?php

$message_subject = 'Please activate your account';

$message_body = 'this is a test mail using swift and I added a disconnector.' . "\n\n" . 'And now a new line';

//Load in the components
require_once '../libraries/Swift/Swift.php';
require_once '../libraries/Swift/Swift/Connection/Sendmail.php';

//Instantiate swift
$swift = new Swift(new Swift_Connection_Sendmail);

// Make a message
$message = new Swift_Message($message_subject, $message_body);
//Send the email
if ($swift->send($message, 'me@mymail.com', 'from@frommail.com'))
{
	echo 'Success';
}
else
{
	echo 'Disaster';
}

//Terminate the connection because it's just polite
$swift->disconnect();
?>

Posted: Mon Jan 15, 2007 6:04 pm
by RobertGonzalez
Nevermind, I used the EasySwift wrapper class and the errors seemed to go away.

Code: Select all

<?php

$message_subject = 'Please activate your account';

$message_body = 'this is a test mail using swift and I added a disconnector.' . "\n\n" . 'And now a new line';

//Load in the components
require_once '../libraries/Swift/EasySwift.php';
require_once '../libraries/Swift/Swift/Connection/Sendmail.php';

//Instantiate swift
$swift = new EasySwift(new Swift_Connection_Sendmail);

// Make a message
if ($swift->send('me@mymail.com', 'from@frommail.com', $message_subject, $message_body))
{
	echo 'Success';
}
else
{
	echo 'Disaster';
}

//Terminate the connection because it's just polite
$swift->close();
?>

Posted: Mon Jan 15, 2007 6:11 pm
by Chris Corbyn
There are some known bugs in the RC just FYI:

* Port number not automagically set
* Response code should be 221 on QUIT, not 250 as you've witnessed :oops:
* EasySwift already "includes" Sendmail and SMTP connectio classes which breaks people's code who didn't use "require_once" or "include_once"

I'll bring out RC2 tomorrow since they're the only things brought to my attention :)

Posted: Mon Jan 15, 2007 8:00 pm
by RobertGonzalez
All is well at the moment. Should I be using V3RC1 yet? This is my first jaunt into Swift and I am actually very happy with its performance so far. But if I should be using 2 instead of three, I will do that.

PS I have no problem testing V3RC1 out for you, but it will be smaller scale and must be able to be pushed into production within the next two to three weeks.

Posted: Tue Jan 16, 2007 12:45 am
by Chris Corbyn
Oh yeah, definitely use version 2 in production until I release a version 3 which is no longer RC. Version 3 is still RC at the moment basically because I rewrote the whole library and saw the inevitable possibility that I may have overlooked a few things and introduced one or two bugs, so I had hoped these would come to light in the RC :)

Posted: Tue Jan 16, 2007 10:14 am
by RobertGonzalez
Cool cool. I will download V2 from SVN in a bit.

Posted: Tue Jan 16, 2007 2:30 pm
by Chris Corbyn
Everah wrote:Cool cool. I will download V2 from SVN in a bit.
/tags/php5/2.1.17

Just FYI ;)

Posted: Tue Jan 16, 2007 3:35 pm
by RobertGonzalez
Thanks d.