thirdplace/mailgun

Mailgun 客户端 - 通过他们的 http api 发送邮件

dev-main 2022-04-24 07:06 UTC

This package is not auto-updated.

Last update: 2024-09-22 18:27:24 UTC


README

通过他们的 http api 发送邮件。

教程

安装

composer require thirdplace/mailgun:dev-main

示例

<?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);

输出

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

如何做

解释

使用美国端点。

参考

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