~thirdplace/mailgun

Mailgun client library using their http api
fix: typo
refactor
fix: bug in readme

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~thirdplace/mailgun
read/write
git@git.sr.ht:~thirdplace/mailgun

You can also use your local clone with git send-email.

#Mailgun client

Send email via their http api.

#Tutorial

Install:

composer require thirdplace/mailgun:dev-main

Example:

<?php
    use function Thirdplace\mailgun_message_send;

    $apiDomain = 'example.com';
    $apiKey = 'key-XXXXXXXXXXXXXXXXXXXXXX';

    $result = mailgun_message_send(
        $apiDomain,
        $apiKey,
        'noreply@example.com',
        'recipient@example.com',
        'Here is the subject',
        'Here is the email body',
    );

    var_dump($result);

Output:

array(2) {
  [0]=>
  int(200)
  [1]=>
  string(88) "{"id":"<20220423070303.1449106df60a3dbb@example.com>","message":"Queued. Thank you."}
"
}

#How-to

#Explanation

Uses the us endpoint.

#Reference

function mailgun_message_send(
    string $apiDomain,
    string $apiKey,
    string $from,
    string $to,
    string $subject,
    string $text
): array

https://documentation.mailgun.com/en/latest/index.html