gylaandrij/swiftmailer-mailgun-bundle
最新稳定版本:2.0.0
Composer 安装命令:
composer require gylaandrij/swiftmailer-mailgun-bundle
包简介
Swiftmailer Mailgun bundle
README 文档
README
This bundle adds an extra transport to the swiftmailer service that uses the mailgun http interface for sending messages.
Installation
composer require gylaandrij/swiftmailer-mailgun-bundle php-http/guzzle5-adapter
Note: You can use any of these adapters
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" http_client: 'httplug.client' # Optional. Defaults to null and uses discovery to find client. # 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);
Choose HTTP client
Mailgun 2.0 is no longer coupled to Guzzle5. Thanks to Httplug you can now use any library to transport HTTP messages. You can rely on discovery to automatically find an installed client or you can use HttplugBundle and provide a client service name to the mailgun configuration.
// app/config/config.yml: cspoo_swiftmailer_mailgun: http_client: 'httplug.client'
统计信息
- 总下载量: 2.64k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-22