Swift Mailer Bundle, by Taylor Otwell
A Laravel Swift Mailer bundle, installable via the Artisan CLI:, (*1)
php artisan bundle:install swiftmailer
You must then auto-load the bundle in bundles.php:, (*2)
return array(
'swiftmailer' => array('auto'=>true)
);
In your code, you need to get a Swift_Mailer instance:, (*3)
$mailer = IoC::resolve('mailer');
You will also need a message instance that will allow you to construct your message and later send:, (*4)
$message = Swift_Message::newInstance('Subject Of Email');
Ultimately the final code to construct a message will look something like this:, (*5)
// If you do not want to auto-load the bundle, you can use this
Bundle::start('swiftmailer');
// Get the Swift Mailer instance
$mailer = IoC::resolve('mailer');
// Construct the message
$message = Swift_Message::newInstance('Message From Website')
->setFrom(array('example@example.com'=>'Mr Example'))
->setTo(array('example@example.com'=>'Mr Example'))
->addPart('My Plain Text Message','text/plain')
->setBody('<p>My HTML Message</p>','text/html');
// Send the email
$mailer->send($message);
Or, since your controllers have dynamic access to the IoC container:, (*6)
$this->mailer->send($message);
Swift Mailer, by Chris Corbyn
Swift Mailer is a component based mailing solution for PHP 5.
It is released under the LGPL license., (*7)
- Homepage: http://swiftmailer.org
- Documentation: http://swiftmailer.org/docs
- Mailing List: http://groups.google.com/group/swiftmailer
- Bugs: https://github.com/swiftmailer/swiftmailer/issues
- Repository: https://github.com/swiftmailer/swiftmailer
Swift Mailer is highly object-oriented by design and lends itself
to use in complex web application with a great deal of flexibility., (*8)
For full details on usage, see the documentation., (*9)
IMPORTANT
Users upgrading from version 3.x or earlier absolutely MUST read the documentation. In short, the API is considerably different so your old code won't "just work"., (*10)
Donations
If you'd like to make a donation, we are working on a system where
donations are taken on a per-feature-request basis via the website
with target amounts for each feature. In the meantime however you
may donate directly to the author via PayPal:, (*11)
PayPal: chris@w3style.co.uk, (*12)
Donations are certainly voluntary, but seriously, you donors are
complete legends and drive this project! :), (*13)