swiftmailer/swiftmailer's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
Swiftmailer is a comprehensive and feature-rich PHP mailer, designed to be highly object-oriented, making it ideal for use in complex web applications where flexibility is critical. It is a component-based mailing solution that encompasses robust mailing functions. However, as of the end of November 2021, the maintenance for Swiftmailer is discontinued and it is recommended to shift to Symfony Mailer. Symfony Mailer, like Swiftmailer, offers high adaptability for modern PHP code and bolsters third-party provider support.
To utilize Swiftmailer in your PHP projects, you must first install it. Swiftmailer can be easily installed via Composer. Here's a basic example of sending an email using Swiftmailer:
// Make sure to require the Composer autoload file require_once 'vendor/autoload.php'; // Create the Transport $transport = (new Swift_SmtpTransport('smtp.example.com', 25)) ->setUsername('your username') ->setPassword('your password'); // Create the Mailer using your created Transport $mailer = new Swift_Mailer($transport); // The message creation $message = Swift_Message::newInstance() ->setSubject('Hello') ->setFrom(array('firstname.lastname@example.org' => 'John Doe')) ->setTo(array('email@example.com', 'firstname.lastname@example.org' => 'A name')) ->setBody('Here is the message itself'); // Send the message $result = $mailer->send($message);
This code will connect to an SMTP server, form an email with a subject, from/to addresses, and a body text, and then send the email.
Detailed documentation on Swiftmailer usage can be found on the official Swiftmailer website at https://swiftmailer.symfony.com/docs/introduction.html. The documentation provides comprehensive insights into the functionalities, integrations, and complex use-cases of the mailer.