hamaryuginh / mandrillbundle
A Symfony2 Bundle for Mandrill
Installs: 25
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 2
Type:symfony-bundle
Requires
- mandrill/mandrill: 1.0.*
- symfony/config: >=2.1,<2.7-dev
- symfony/http-foundation: >=2.1,<2.7-dev
This package is not auto-updated.
Last update: 2020-02-13 23:21:47 UTC
README
Work still in progress
A Symfony2 Bundle for Mandrill
This project is a fork of https://github.com/Hipaway-Travel/HipMandrillBundle
Prerequisites
Before you're able to use this bundle you must sign up with Mandrill.
Mandrill is a great way to send your transactional emails and provides detailed advances reports.
Mandrill is free for limited number of email per day, please read through pricing section on the website for more information:
Installation
Add the bundle to your composer.json
{ "require": { "...", "hamaryuginh/mandrillbundle": "dev-master" } }
Run composer install
php composer.phar install
Enable the bundle in the kernel
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Hamaryuginh\MandrillBundle\HamaryuginhMandrillBundle(),
);
}
Configuration
Add configuration to config.yml.
Log in to Mandrill and go to "Settings" -> "SMTP & API Info". Create an API Key and use it in your Symfony2 Configuration.
# config.yml hamaryuginh_mandrill: api_key: xxxxx disable_delivery: true # useful for dev/test environment. Default value is 'false' default: sender: info@example.com sender_name: John Doe subaccount: Project # Optionally define a subaccount to use
Now you're all set, send your first transactional mails:
Use
Send an email from a Controller:
/* Prepare the Message */ $mandrillMessage = new Message(); $mandrillMessage ->setSubject('Message subject') ->setHtml('<html><body>HTML content goes here</body></html>') ->setText('Text content goes here') ->setFromEmail('from.me@foo.bar') ->setFromName('From Me') ->addTo('john.doe@foo.bar') ... ; /* Get the Mandrill Manager */ $mandrillManager = $this->get('hamaryuginh.mandrill_manager'); /* Get Mandrill Message Service */ $mandrillMessage = $mandrillManager->get('message'); /* Send the Message : this method return a MessageResponse */ $messageResponse = $mandrillMessage->send($mandrillMessage);
The send method has the following signature:
/** * Send a new transactional message through Mandrill * @param Message $message * @param boolean $async * @param string $ipPool * @param string $sendAt * @return MessageResponse|false - Return false if the parameter disable_delivery (in the config) is set to true */ public function send(Message $message, $async = false, $ipPool = null, $sendAt = null)