PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?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);
?>
Don't just copy and paste those examples and use them in production code. They are merely there to illustrate how Swift works. It may be a good idea to look at the examples and break them down whilst consulting the documentation
Has it been blocked by a Spam filter? The details you posted show that the SMTP server happily accepted your message and sent it off.
Reasons that it may be blocked as Spam are Blacklisting of your host, using a dynamic IP address to relay mail and the other obvious things like selling <span style='color:red;text-decoration:blink' title='Alert a moderator!'>grilled spam</span> or offering millions of dollars.
You wanna send one to chris AT w3style DOT co DOT uk ?
I have a spam checker installed on the server. If your mail is blocked as SPAM I'll have a copy in a MySQL database I've set up as my spam bin. I'll send you the spam report either way (even if the score is zero). Just give it the subject "SWIFT TESTING" so I can spot it easily.
Have you checked the obvious and made sure that your server is actually running delivery attempts? You may need to flush the queue.
NiGHTFiRE wrote:Did you get an email?
But i've forwarded port 25 :/
Edit: seems like i didn't do it correctly. It's port 25 on what protocol, tcp right?
TCP/25 yes. No I don't have an email, it's not in my spam bin neither. Does the SMTP server work correctly? Have you tested it with anything else? Try running `/usr/sbin/postfix -q' since it may not be doing it's mail runs.
EDIT | If you have a software firewall running on your PC make sure port 25 is open on that as well as on the router.