\MailgunMailer
A {@link Mailer} subclass to handle sending emails through the Mailgun webservice API rather than send_mail(). Uses the official Mailgun PHP library.
Synopsis
class MailgunMailer
extends Mailer
{
- // members
- private static bool $test_mode = false;
- private static bool $fallback_to_mailer = true;
- private static string $api_key = '';
- private static string $api_endpoint = 'api.mailgun.net';
- private static string $api_domain = '';
- private static bool $track_opens = false;
- private static bool $track_clicks = false;
- private static bool $inline_images = true;
- // methods
- public static void getApiClient()
- public static void getApiEndpoint()
- public static void getApiDomain()
- public static void getApiKey()
- public bool sendPlain()
- public array sendHTML()
- private message-ID createMessageId()
- private emulateMailgunFeedback()
- private bool sendMailgunEmail()
Hierarchy
Extends
- Mailer
Tasks
Line | Task |
---|---|
184+ | : not sure about returning a http_code/_body, as we're in fact making these up... |
Members
private
- $api_domain
—
string
List of confirmed domains. Set them up at https://mailgun.com/ - $api_endpoint
—
string
Mailgun API endpoint to use, depends on region - $api_key
—
string
Your Mailgun App API Key. Get one at https://mailgun.com/ - $fallback_to_mailer
—
bool
Fallback to default Mailer in case of Mailgun API/other errors - $inline_images
—
bool
Try to 'inline' images (include images in the mail body instead of linking to them) - $test_mode
—
bool
Test mode, dont actually send out mails - $track_clicks — bool
- $track_opens — bool
Methods
private
- createMessageId() — Add a generated message ID to the customheaders array
- emulateMailgunFeedback() — Return a Mailgun-compatible result object for fallbackMailer results (php mail()'s boolean result)
- sendMailgunEmail() — Send email through Mailgun's REST API
public
- getApiClient()
- getApiDomain()
- getApiEndpoint()
- getApiKey()
- sendHTML() — Send an email as both HTML and plaintext
- sendPlain() — Send a plain-text email.