Where is close (V3 rc1)?

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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Where is close (V3 rc1)?

Post 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();
?>
Last edited by RobertGonzalez on Mon Jan 15, 2007 6:04 pm, edited 1 time in total.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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();
?>
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 :)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 :)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Cool cool. I will download V2 from SVN in a bit.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Everah wrote:Cool cool. I will download V2 from SVN in a bit.
/tags/php5/2.1.17

Just FYI ;)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Thanks d.
Post Reply