定制 renzojohnson/mailgun-api 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

renzojohnson/mailgun-api

最新稳定版本:v0.26.03.16

Composer 安装命令:

composer require renzojohnson/mailgun-api

包简介

Lightweight PHP wrapper for Mailgun API. Send emails, validate addresses, manage domains. Zero dependencies beyond ext-curl.

README 文档

README

Latest Version PHP Version License

Lightweight PHP wrapper for Mailgun API. Send emails, validate addresses, manage domains. Zero dependencies beyond ext-curl.

Author: Renzo Johnson

Requirements

  • PHP 8.4 or higher
  • ext-curl
  • ext-json

Installation

composer require renzojohnson/mailgun-api

Quick Start

use RenzoJohnson\Mailgun\Mailgun;

$mailgun = new Mailgun('key-your-api-key', 'mg.yourdomain.com');

// Send a simple text email
$mailgun->sendText(
    'sender@mg.yourdomain.com',
    'recipient@example.com',
    'Hello from Mailgun',
    'This is the email body.'
);

Send HTML Email

$mailgun->sendHtml(
    'sender@mg.yourdomain.com',
    'recipient@example.com',
    'Welcome!',
    '<h1>Welcome</h1><p>Thanks for signing up.</p>',
    'Welcome! Thanks for signing up.' // optional plain text fallback
);

Advanced Email Builder

use RenzoJohnson\Mailgun\Message\Email;

$email = new Email(
    'sender@mg.yourdomain.com',
    'recipient@example.com',
    'Order Confirmation',
    text: 'Your order has been confirmed.',
    html: '<h1>Order Confirmed</h1>'
);

$email->cc('manager@example.com')
    ->bcc('archive@example.com')
    ->replyTo('support@example.com')
    ->header('X-Campaign', 'welcome-series')
    ->variable('order_id', '12345')
    ->tag('transactional');

$mailgun->send($email);

Domain Info

// Get domain details
$info = $mailgun->getDomainInfo();

// List all domains
$domains = $mailgun->listDomains();

Events & Stats

// Get sending events
$events = $mailgun->getEvents(['event' => 'delivered', 'limit' => 10]);

// Get delivery stats (last 7 days)
$stats = $mailgun->getStats('delivered', 7);

Email Validation

// Validate an email address (requires validation API key)
$result = $mailgun->validateEmail('user@example.com');

Error Handling

use RenzoJohnson\Mailgun\Exception\ApiException;

try {
    $mailgun->sendText('from@mg.example.com', 'to@example.com', 'Test', 'Body');
} catch (ApiException $e) {
    echo $e->getMessage(); // "Mailgun API error (401): Forbidden"
}

Links

License

MIT License. Copyright (c) 2026 Renzo Johnson.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固