dugandzic / swiftmailer-mailgun-bundle
Swiftmailer Mailgun bundle
Installs: 389
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 49
Type:symfony-bundle
Requires
- php: >=5.3
- mailgun/mailgun-php: ~1.7
- swiftmailer/swiftmailer: ~5.0, >=4.0
Suggests
- azine/mailgunwebhooks-bundle: Allows to handle Mailgun event webhooks
This package is not auto-updated.
Last update: 2025-01-18 20:35:41 UTC
README
This bundle adds an extra transport to the swiftmailer service that uses the mailgun http interface for sending messages.
Installation
composer require dugandzic/swiftmailer-mailgun-bundle
Also add to your AppKernel:
new cspoo\Swiftmailer\MailgunBundle\cspooSwiftmailerMailgunBundle(),
Configure your application with the credentials you find on the domain overview on the Mailgun.com dashboard.
// app/config/config.yml: cspoo_swiftmailer_mailgun: key: "key-xxxxxxxxxx" domain: "mydomain.com" # Swiftmailer Configuration swiftmailer: transport: "mailgun" spool: { type: memory } # This will start sending emails on kernel.terminate event
Note that the swiftmailer configuration is the same as the standard one - you just change the mailer_transport parameter.
Usage
First craft a message:
$message = \Swift_Message::newInstance() ->setSubject('Hello Email') ->setFrom('send@example.com') ->setTo('recipient@example.com') ->setBody( $this->renderView( 'HelloBundle:Hello:email.txt.twig', array('name' => $name) ) ) ;
Then send it as you normally would with the mailer
service. Your configuration ensures that you will be using the Mailgun transport.
$this->container->get('mailer')->send($message);
Todo:
- Add mailgun as a separate transport to the normal Swiftmailer service
- Tests