fabian / mandrill
Mandrill API library with Message class implementation like in Nette framework
Installs: 9 250
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 4
Forks: 7
Open Issues: 2
Requires
- php: >=5.3.0
- nette/mail: >=2.3.1
This package is not auto-updated.
Last update: 2024-12-02 08:00:21 UTC
README
Mandrill API library with Message class implementation like in Nette framework.
Requirements
- PHP 5.3
- Mandrill API key
- Nette framework
Installation
The best way to install is using Composer:
$ composer require fabian/mandrill
If you'r using older Nette with Nette\Mail version <=2.3.0, you have to use mandrill-nette version 1.1.0:
$ composer require fabian/mandrill:1.1.0
Usage
Add Mandrill API key to your parameters in your config.neon:
parameters: mandrill: apiKey: yourApiKey
Then you can use MandrillMailer:
$mail = new \Fabian\Mandrill\Message(); $mail->addTo('joe@example.com', 'John Doe') ->setSubject('First email') ->setBody("Hi,\n\nthis is first email using Mandrill.") ->setFrom('noreplay@yourdomain.com', 'Your Name') ->addTag('test-emails'); $mailer = new \Fabian\Mandrill\MandrillMailer( $this->context->parameters['mandrill']['apiKey'] ); $mailer->send($mail);
You can use \Nette\Mail\Message too:
$mail = new \Nette\Mail\Message; $mail->addTo('joe@example.com', 'John Doe') ->setSubject('First email') ->setBody("Hi,\n\nthis is first email using Mandrill.") ->setFrom('noreplay@yourdomain.com', 'Your Name') $mailer = new \Fabian\Mandrill\MandrillMailer( $this->context->parameters['mandrill']['apiKey'] ); $mailer->send($mail);
Mandrill templates
If you'r using templates, you can send email using sendTemplate() instead of send():
$mailer->sendTemplate($mail, 'template_name', array( array('name' => 'header', 'content' => 'testing header'), ));