Laravel API mailer

Sending e-mail from different mail service API is a painful task because they use their own payload structure which is different according to the e-mail service provider. In this situation, the API mailer package for Laravel will give a clean syntax generalize payload structure for sending e-mail from a different e-mail service provider like SendGrid, Mailgun etc. Let's explore the API mailer package.

GitHub repository:



composer require haruncpi/laravel-api-mailer



Now publish the api-mailer.php configuration file to your project config directory by following this command.

php artisan vendor:publish --provider="Haruncpi\LaravelApiMailer\ApiMailerServiceProvider" --tag="config"


.env file configarations

Currently, API mailer supports SendGrid and Mailgun. The default driver is mailgunYou can change it by putting APIMAILER_DEFAULT into .env file. There are env file entities you can configure.






Single e-mail

$payload = ['to' => '', 'subject' => 'Hello Friend', 'body' => 'How are you'];
$response = apiMailer()->send($payload);


Multiple e-mails

$receivers = ['','', ...]
$payload = ['to' => $receivers, 'subject' => 'Hello Friends', 'body' => 'Your HTML body'];
$response = apiMailer()->send($payload);


You can use ApiMailer facade

use Haruncpi\LaravelApiMailer\Facades\ApiMailer;

$response = ApiMailer::send($payload);


Response format

  success: true,
  message: "successfully send"

  success: false,
  message: "reason for failure"


Hope the Laravel API mailer package will help you to send e-mail using different e-mail services with simple & clean generalize syntax. If you find this package helpful then support it on GitHub API mailer repository and don't forget to share it with others.

Share on

Social Links

Related Post - Latest Post

Laravel Barcode generation tutorial

Laravel Jetstream tutorial

Laravel User Activity

Laravel Breeze - Starting with Laravel has been easy!

Laravel H package

Laravel Simple Filemanager