Data33 / laravel-mailgun by Data33

Send emails from multiple domains with mailgun
14,370
0
1
Package Data
Maintainer Username: Data33
Maintainer Contact: datae33@gmail.com (Mattias Ottosson)
Package Create Date: 2016-08-15
Package Last Update: 2024-02-07
Language: PHP
License: MIT
Last Refreshed: 2024-11-19 03:04:07
Package Statistics
Total Downloads: 14,370
Monthly Downloads: 5
Daily Downloads: 0
Total Stars: 0
Total Watchers: 1
Total Forks: 3
Total Open Issues: 0

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.

Installation

Open your composer.json file and add the following to the require key:

"data33/laravel-mailgun": "1.0.*"

After adding the key, run composer update from the command line to install the package

composer update

Add the service provider to the providers array in your config/app.php file.

Data33\LaravelMailgun\Providers\MailgunServiceProvider::class,

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.

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

In it you must specify your Mailgun API key.

Usage with Laravel

Mailgun::send('YOUR-DOMAIN', '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:

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

$result = $mg->send('YOUR-DOMAIN', ['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');
});

Todo

  • Implement more Transporters (raw curl, for example)
  • Actually pass along recipient variables
  • Refine documentation