Posted: Thu Jun 15, 2006 5:40 pm
I forgot to add the right ip to the smtp server (dumb me) but now when i added localhost i got:
Script:
Code: Select all
Array ( [0] => Array ( [command] => [time] => 0.10498700 1150411519 [response] => 220 linux.site ESMTP Postfix ) [1] => Array ( [command] => EHLO wmegn.mine.nu [time] => 0.56513900 1150411519 [response] => 250-linux.site 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250 8BITMIME ) [2] => Array ( [command] => MAIL FROM: [time] => 0.60940200 1150411519 [response] => 250 Ok ) [3] => Array ( [command] => RCPT TO: [time] => 0.67469300 1150411519 [response] => 250 Ok ) [4] => Array ( [command] => DATA [time] => 0.75026400 1150411519 [response] => 354 End data with . ) [5] => Array ( [command] => To: "david.wibergh@gmail.com" From: "david.wibergh@gmail.com" Reply-To: Subject: Some Subject Date: Fri, 16 Jun 2006 00:45:19 +0200 X-Mailer: Swift by Chris Corbyn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Hello Joe it's only me! . [time] => 0.75058000 1150411519 [response] => 250 Ok: queued as B6F834DD83 ) [6] => Array ( [command] => QUIT [time] => 0.76919400 1150411519 [response] => 221 Bye ) )Code: Select all
<?php
require('/srv/www/htdocs/Swift/Swift.php');
require('/srv/www/htdocs/Swift/Swift/Swift_SMTP_Connection.php');
//This sets up our connection object
$connection = new Swift_SMTP_Connection('localhost');
//The mailer will now establish a connection with the server
$mailer = new Swift($connection);
//If anything goes wrong you can see what happened in the logs
if (!$mailer->hasFailed()) //Optional
{
//Sends a simple email
$mailer->send(
'"david.wibergh@gmail.com" <david.wibergh@gmail.com>',
'"david.wibergh@gmail.com" <david.wibergh@gmail.com>',
'Some Subject',
"Hello Joe it's only me!"
);
//Closes cleanly... works without this but it's not as polite.
$mailer->close();
}
else echo "The mailer failed to connect. Errors: ".print_r($mailer->errors, 1).". Log: ".print_r($mailer->transactions, 1);
print_r($mailer->transactions);
?>