I tried close(), but got this error:
So I changed the close to disconnect() and got this:Fatal error: Call to undefined method Swift::close() in /bay/html/baynet-dev/tests/swift-test.php on line 27
What am I doing wrong? As it relates to my issue, the mail is being sent as expected. I am using this test code.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
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();
?>