2017 © Pedro Peláez
 

library laravel-mailgun

Send emails from multiple domains with mailgun

image

data33/laravel-mailgun

Send emails from multiple domains with mailgun

  • Wednesday, November 9, 2016
  • by Data33
  • Repository
  • 1 Watchers
  • 0 Stars
  • 688 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 7 % Grown

The README.md

Data33/Laravel-Mailgun

A package for sending emails using the Mailgun HTTP API. One of the main advantages is that you can send emails from any domains connected to your Mailgun API key., (*1)

Installation

Open your composer.json file and add the following to the require key:, (*2)

"data33/laravel-mailgun": "^2"

After adding the key, run composer update from the command line to install the package, (*3)

composer update

Configuration

Before you can start using the package we need to set some configurations. To do so you must first publish the config file, you can do this with the following artisan command., (*4)

php artisan vendor:publish --provider="Data33\LaravelMailgun\Providers\MailgunServiceProvider" --tag="config"

After the config file has been published you can find it at: config/mailgun.php, (*5)

In it you must specify your Mailgun API key., (*6)

Usage with Laravel

Mailgun::send('MAILGUN-URL', 'view', ['viewVariable' => 'value'], function(\Data33\LaravelMailgun\Message $msg){
    $msg->setFromAddress('sender@YOUR-DOMAIN', 'Sender Name')
        ->addToRecipient('RECIPIENT-EMAIL', 'Recipient Name')
        ->setSubject('Test subject');
});

Usage without Laravel

The easiest way to use this package without Laravel is to directly instantiate a Transporter of your choice. For example:, (*7)

$mg = new Data33\LaravelMailgun\Transporters\AnlutroCurlTransporter('YOUR-MAILGUN-API-KEY');

$result = $mg->send('MAILGUN-URL', ['html' => '<b>Test</b>', 'text' => 'Test'], function(\Data33\LaravelMailgun\Message $msg){
    $msg->setFromAddress('sender@YOUR-DOMAIN', 'Sender Name')
        ->addToRecipient('RECIPIENT-EMAIL', 'Recipient Name')
        ->setSubject('Test subject');
});

Upgrade from 1.3.0

Since EU domains need calls to a different API URL it seemed fitting to not keep it hardcoded within this package. To upgrade your old code base, change the first argument from domain name to the full URL to Mailgun's Messages API for your domain For example:, (*8)

$mg = new Data33\LaravelMailgun\Transporters\AnlutroCurlTransporter('YOUR-MAILGUN-API-KEY');

-$result = $mg->send('mydomain.com', ['html' => '<b>Test</b>', 'text' => 'Test'], function(\Data33\LaravelMailgun\Message $msg){
+$result = $mg->send('https://api.mailgun.net/v3/mydomain.com/messages', ['html' => '<b>Test</b>', 'text' => 'Test'], function(\Data33\LaravelMailgun\Message $msg){
    $msg->setFromAddress('sender@YOUR-DOMAIN', 'Sender Name')
        ->addToRecipient('RECIPIENT-EMAIL', 'Recipient Name')
        ->setSubject('Test subject');
});

The Versions

09/11 2016

dev-master

9999999-dev https://github.com/Data33/laravel-mailgun

Send emails from multiple domains with mailgun

  Sources   Download

MIT

The Requires

 

laravel mailgun

09/11 2016

1.0.2

1.0.2.0 https://github.com/Data33/laravel-mailgun

Send emails from multiple domains with mailgun

  Sources   Download

MIT

The Requires

 

laravel mailgun

15/08 2016

1.0.1

1.0.1.0 https://github.com/Data33/laravel-mailgun

Send emails from multiple domains with mailgun

  Sources   Download

MIT

The Requires

 

laravel mailgun

15/08 2016

1.0.0

1.0.0.0 https://github.com/Data33/laravel-mailgun

Send emails from multiple domains with mailgun

  Sources   Download

MIT

The Requires

 

laravel mailgun