Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

symfony/mailer v7.0.3

Helps sending emails
Package summary
Share
0
issues
0
licenses
Package created
30 Mar 2019
Version published
29 Jan 2024
Maintainers
1
Total deps
0
Direct deps
0
License
MIT
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does symfony/mailer do?

Symfony/Mailer is a powerful email solution for PHP that simplifies email handling. This Mailer component aims to make sending emails easier and more efficient. It helps build clean, re-usable and testable emails, while handling the low-level infrastructure parts for you.

How do you use symfony/mailer?

To use Symfony/Mailer, first, you need to install it via Composer using the command $ composer require symfony/mailer. Once installed, you can use it in your application.

Here is an example of creating a new email and sending it:

use Symfony\Component\Mailer\Transport;
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mime\Email;

$transport = Transport::fromDsn('smtp://localhost');
$mailer = new Mailer($transport);

$email = (new Email())
    ->from('hello@example.com')
    ->to('you@example.com')
    ->subject('Time for Symfony Mailer!')
    ->text('Sending emails is fun again!')
    ->html('<p>See Twig integration for better HTML integration!</p>');

$mailer->send($email);

In this example, an SMTP server is used as a transport layer to actually send the emails. The Mailer object is then initiated to work with this transport layer. An email object is created with sender, recipient, subject, text and HTML content. Finally, this email is sent through the Mailer.

If you want to use Twig integration you need to install symfony/twig-bridge, after that, you can use it in the way that's presented in the readme.

Where are the symfony/mailer docs?

Symfony/Mailer's documentation can be found on the Symfony website. You can access it by visiting the Symfony Mailer Documentation. You will find there more in-depth information about the usage, configuration and extensive capabilities of the Symfony/Mailer component.