swiftmailer/swiftmailer
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
egulias/email-validator | 3.2.6 | - | MIT | prod | |
symfony/polyfill-iconv | v1.28.0 | 454.46 kB | MIT | prod | |
symfony/polyfill-intl-idn | v1.28.0 | 59.31 kB | MIT | prod | |
symfony/polyfill-mbstring | v1.28.0 | 29.41 kB | MIT | prod |
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('john@doe.com' => 'John Doe'))
->setTo(array('receiver@domain.org', 'other@domain.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.