Laravel 4 Package to integrate with multiple Cloud Email Providers
503
21
3
Package Data
Maintainer Username: abishekrsrikaanth
Maintainer Contact: abishek@technicaliti.me (Abishek R Srikaanth)
Package Create Date: 2013-08-01
Package Last Update: 2014-06-11
Home Page: http://abishek.me/docs/mail-to
Language: PHP
License: BSD-3-Clause
Last Refreshed: 2024-11-19 03:03:14
Package Statistics
Total Downloads: 503
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 21
Total Watchers: 3
Total Forks: 3
Total Open Issues: 1

####Email Providers Supported

###Installation Add abishekrsrikaanth/mailto as a requirement to composer.json:

{
    ...
    "require": {
        ...
        "abishekrsrikaanth/mailto": "1.*"
        ...
    },
}

Update composer:

$ php composer.phar update

Add the provider to your app/config/app.php:

'providers' => array(
    ...
    'Abishekrsrikaanth\Mailto\MailtoServiceProvider',
),

and the Facade info on app/config/app.php

'aliases'   => array(
    ...
	'MailTo'      => 'Abishekrsrikaanth\Mailto\Facades\Mailto',
),

Publish the Configuration and setup the config with the credentials of the different email providers

php artisan config:publish abishekrsrikaanth/mailto

###Mandrill #####Sending Email using Mandrill

$mandrill = MailTo::Mandrill();
$mandrill->addRecipient($email, $name)
         ->setFrom($email, $name)
         ->setHtml($html)
         ->setText($text)
         ->setSubject($subject)
         ->send();

#####Queuing Email using Mandrill

$mandrill = MailTo::Mandrill();
$mandrill->addRecipient($email, $name)
         ->setFrom($email, $name)
         ->setHtml($html)
         ->setText($text)
         ->setSubject($subject)
         ->queue();

#####Sending Email at a given Time

$timestamp = new DateTime('+1 hour');

$mandrill = MailTo::Mandrill();
$mandrill->addRecipient($email, $name)
         ->setFrom($email, $name)
         ->setHtml($html)
         ->setText($text)
         ->setSubject($subject)
         ->send($timestamp);

#####Sending Email to a Batch of recipients

$mandrill = MailTo::Mandrill();
$mandrill->addRecipient($email, $name)
         ->setFrom($email, $name)
         ->setHtml($html)
         ->setText($text)
         ->setSubject($subject)
         ->sendBatch();

#####Sending Email to a Batch of recipients at a given time

$timestamp = new DateTime('+1 hour');

$mandrill = MailTo::Mandrill();
$mandrill->addRecipient($email, $name)
         ->setFrom($email, $name)
         ->setHtml($html)
         ->setText($text)
         ->setSubject($subject)
         ->sendBatch($timestamp);

#####Passing the credentials dynamically for Mandrill

$mandrill = MailTo::Mandrill(array('apikey'=>'MADRILL_API_KEY'));
$mandrill->addRecipient($email, $name)
         ->setFrom($email, $name)
         ->setHtml($html)
         ->setText($text)
         ->setSubject($subject)
         ->send();

#####Example Response from Mandrill - Success

[
    {
        "email": "recipient.email@example.com",
        "status": "sent",
        "reject_reason": "hard-bounce",
        "_id": "abc123abc123abc123abc123abc123"
    }
]

#####Example Response from Mandrill - Error

{
    "status": "error",
    "code": 10,
    "name": "PaymentRequired",
    "message": "This feature is only available for accounts with a positive balance."
}

#####Managing Webhooks The configuration of this package allows you to configure the webhooks that have been created on the mandrill control panel. When enabled and configured, the necessary routes for the web hooks are automatically created and is ready to implement. The details of enabling and configuring the web hooks are mentioned below.

'mandrill' => array(
		'apikey'    => 'MANDRILL_API_TOKEN',
		'web_hooks' => array(
			'enabled' => false,
			'routes'  => array(
				array(
					'route_url'   => '/mandrill/send',
					'route_types' => array('send'),
					'webhook_key' => 'API_WEBHOOK_KEY',
					'listener'    => array(
						'type' => 'event',
						'name' => ''
					),
					'verify_hook' => false
				),
				array(
					'route_url'   => '/mandrill/bounce',
					'route_types' => array(''),
					'webhook_key' => '',
					'listener'    => array(
						'type' => 'queue',
						'name' => ''
					),
					'verify_hook' => false
				)
			)
		)
	)

Lets look at detail the route configurations.

</td>

###PostMarkApp

#####Sending Email

$postMark = MailTo::PostMark();
$message  = $postMark->getMessageInstance();
$message->addRecipient("RECIPIENT_EMAIL")
	->setFrom("FROM_EMAIL", "FROM_NAME")
	->setSubject("EMAIL_SUBJECT")
	->setHtml("HTML_CONTENT_GOES_HERE")
	->setText("TEXT_CONTENT_GOES_HERE");
$postMark->send($message);

#####Example Response from Postmark for Send Method if Message sent successfully

{
  "ErrorCode" : 0,
  "Message" : "OK",
  "MessageID" : "b7bc2f4a-e38e-4336-af7d-e6c392c2f817",
  "SubmittedAt" : "2010-11-26T12:01:05.1794748-05:00",
  "To" : "receiver@example.com"
}

#####Sending Batch Email

$postMark = MailTo::PostMark();
$message  = $postMark->getMessageInstance();
$message->addRecipient("RECIPIENT_EMAIL")
    ->setFrom("FROM_EMAIL", "FROM_NAME")
	->setSubject("EMAIL_SUBJECT")
	->setHtml("HTML_CONTENT_GOES_HERE")
	->setText("TEXT_CONTENT_GOES_HERE");
$postMark->send($message);

#####Example Response from Postmark for Send Method if Message sent successfully

[
    {
      "ErrorCode" : 0,
      "Message" : "OK",
      "MessageID" : "b7bc2f4a-e38e-4336-af7d-e6c392c2f817",
      "SubmittedAt" : "2010-11-26T12:01:05.1794748-05:00",
      "To" : "receiver1@example.com"
    },
    {
      "ErrorCode" : 0,
      "Message" : "OK",
      "MessageID" : "e2ecbbfc-fe12-463d-b933-9fe22915106d",
      "SubmittedAt" : "2010-11-26T12:01:05.1794748-05:00",
      "To" : "receiver2@example.com"
    }
]

#####Work in progress

  • ElasticMail

#####Implementations coming soon

  • MailGun

  • PostageApp

  • Mad Mimi

  • Alpha Mail

endorse Bitdeli Badge