In some of my projects I send out email — sometimes using Core Drupal Email APIs, sometimes just using PHP’s native mail() function. But, usually I take a few minutes and integrate (somehow) my project with Swiftmailer.
Swift Mailer integrates into any web app written in PHP 5, offering a flexible and elegant object-oriented approach to sending emails with a multitude of features.
Send emails using SMTP, sendmail, postfix or a custom Transport implementation of your own
Support servers that require username & password and/or encryption
Protect from header injection attacks without stripping request data content
Send MIME compliant HTML/multipart emails
Use event-driven plugins to customize the library
Handle large attachments and inline/embedded images with low memory use
In this laundry list of features is the extensible Plugin architecture of Swiftmailer. When configuring our Transport layer we can tell swiftmailer to make use of a plugin:
$transport = Swift_SendmailTransport::newInstance($custom_sendmail_command); $mailer = Swift_Mailer::newInstance($transport); $mailer->registerPlugin( new Swift_Plugins_ThrottlerPlugin( mycustom_outgoing_throttle_rate(), Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE ));
In my above code mycustom_outgoing_throttle_rate() is a function that examines the length of an outgoing email list and figures out how many emails it can send per minute to send the whole list in say … about 1.5 hours.
Usage of these types of plugins in your webapp system can help to keep your (email) server from being blacklisted as a Spam system.
Looking for quality web hosting? Look no further than Arvixe Web Hosting!