Skip to content

Instantly share code, notes, and snippets.

@romainnorberg
Last active April 21, 2020 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romainnorberg/037dd9860079354954e10606d09b429b to your computer and use it in GitHub Desktop.
Save romainnorberg/037dd9860079354954e10606d09b429b to your computer and use it in GitHub Desktop.
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mailer\Transport;
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
use Symfony\Component\Mime\Email;
// not work
/*
$mailer = new Mailer(
Transport::fromDsn(
'smtp://127.0.0.1:2525?encryption=tls&auth_mode=login&username=Mailbox-Name&password=dqsqds'
)
);
*/
// work
$transport = new EsmtpTransport('127.0.0.1', 2525);
$transport->setUsername('Mailbox-Name');
$transport->setPassword('');
$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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment