Including Swift Mailer (Autoloading)

Swift Mailer uses an auto-loader so the only file you need to include is the lib/swift_required.php file.

To use Swift Mailer's autoloader:


  1. Put Swift Mailer somewhere accessible to your PHP scripts (this does not need to be in the web root).
  2. Include, or require the lib/swift_required.php file.
  3. Follow the remainder of the documentation for using the available components.
Note: While Swift Mailer's autoloader is designed to play nicely with other autoloaders, sometimes you may have a need to avoid using Swift Mailer's autoloader and use your own instead. Include the swift_init.php instead of the swift_required.php if you need to do this. The very minimum include is the swift_init.php file since Swift Mailer will not work without the dependency injection this file sets up.
<?php

require_once '/path/to/swift-mailer/lib/swift_required.php';

/* rest of code goes here */

NOTE: Documentation for version 3 is in the wiki.