kraag22 / mandrill-nette

Mandrill API library with Message class implementation like in Nette framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mandrill API library with Message class implementation like in Nette framework.

Requirements

Installation

The best way to install is using Composer:

$ composer require fabian/mandrill:@dev

Usage

Add Mandrill API key to your parameters in your config.neon:

parameters:
  mandrill:
    apiKey: yourApiKey

Register new service in your config.neon:

services:
	mandrill:
		class: Fabian\Mandrill\Mandrill(%mandrill.apiKey%)

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);

About

Mandrill API library with Message class implementation like in Nette framework


Languages

Language:PHP 97.5%Language:JavaScript 2.5%