I use the Zend Framework and quite like it, but the documentation is pretty bad sometimes. In particular, the documentation of their Zend_Mail class is too simple, and the API docs totally unhelpful. So I thought I’d write down what worked for me.
We use Sendgrid to handle our email delivery. It does all the tedious signing and things that are necessary to avoid getting caught in spam traps, which is a huge time-saver. It uses plain authentication, which is a little odd, but it works. Here’s the full code:
dirname(__FILE__) . PATH_SEPARATOR .
get_include_path() . PATH_SEPARATOR .
$autoloader = Zend_Loader_Autoloader::getInstance();
$mailConfig = array(
'host' => "smtp.sendgrid.net",
'port' => 25,
'domain' => "your.domain.name",
'authentication' => "plain",
'username' => "firstname.lastname@example.org",
'password' => "yoursendgridpassword"
$transport = new Zend_Mail_Transport_Smtp(
'port' => $mailConfig['port'],
'auth' => $mailConfig['authentication'],
'username' => $mailConfig['username'],
'password' => $mailConfig['password']
$message = new Zend_Mail();
$message->setFrom('email@example.com','The Almighty Server');
$message->addTo('firstname.lastname@example.org','John Q. Customer');
This is an email from us.
The Almighty Server.
Hopefully this is pretty self-explanatory.