Search by

bonsaicode / mailgun

ahdavis

MailGun API Wrapper to easily send messages using MailGun's API including support for attachments and inline/embedded images.

Package info

bitbucket.org/bonsaicode/mailgun

pkg:composer/bonsaicode/mailgun

Statistics

Installs: 29

Dependents: 0

Suggesters: 0

1.1.0 2026-11-14 17:18 UTC

This package is auto-updated.

Last update: 2026-11-14 17:22:58 UTC


README

MailGun API Wrapper. Provides wrapper to easily send messages using MailGun's API including support for attachments and inline/embedded images.

Dependencies:

You must have a mailgun account.

This class assumes a MAILGUN associative array constant is defined:

const MAILGUN = [
	'API_KEY'             => 'your mailgun api key',
	'BASE_URL'            => 'https://api.mailgun.net/v3/',  # or https://api.eu.mailgun.net/v3/
	'DEFAULT_DOMAIN'      => 'your domain name',  # your default domain to send from, which can be overridden per message with 'domain'
	'WEBHOOK_SIGNING_KEY' => 'your HTTP webhook signing key'  # optional, used by verifyWebhookSignature(); falls back to API_KEY

];

Requirements

  • PHP 7.1 or higher, with the curl, fileinfo and json extensions

Installation

To install the package, run the following command in the console:

$ composer require "bonsaicode/mailgun"

Usage

see examples/MailGunTest.php

# Verify a webhook; reject ones older than 5 minutes to limit replays
if( BonsaiCode\MailGun::verifyWebhookSignature( $_POST['token'], $_POST['timestamp'], $_POST['signature'], 300 ) ) { ... }

sendMessage() waits at most 10 seconds to connect and 60 seconds in total (override with options connectTimeout and timeout).