aslamhus/mailgun-email-wrapper
最新稳定版本:v1.0.1
Composer 安装命令:
composer require aslamhus/mailgun-email-wrapper
包简介
a fluent interface for sending Mailgun emails
README 文档
README
Overview
A PHP package to simplify the Mailgun PHP API and make its methods conform to Sengrid API.
Installation
composer require aslamhus/mailgun-email-wrapper
Usage
Send basic email
$email = new Email('your-sendgrid-api-key') ->setFrom('sender@example.com', 'Sender Name') ->addTo('recipient@example.com', 'Recipient Name') ->setSubject('Test email') ->addContent('text/plain', 'Hello world!') ->send();
Send Email with dynamic template data
Dynamic template data variables can be set using handlebars {{my_var}}.
For more info see https://docs.sendgrid.com/for-developers/sending-email/using-handlebars
$email = new Email('your-sendgrid-api-key') ->setFrom('sender@example.com', 'Sender Name') ->addTo('recipient@example.com', 'Recipient Name') ->setSubject('Test email') ->setTemplateId('your-template-id') ->addDynamicTemplateDatas([ 'subject' => 'My dynamic template email' 'name' => '2020-01-01', 'link' => 'https://www.example.com', ]) ->send();
Additional Features
-
Add Attachments:
$email->addAttachment('path/to/file.pdf', 'application/pdf', 'document.pdf');
-
Add Content:
$email->addContent('text/plain', 'This is the plain text content'); $email->addContent('text/html', '<p>This is the HTML content</p>');
-
Get email response:
// retrieve the response body, headers and status code after sending $response = $email->getResponse();
Testing
To run tests on this library, follow these steps:
- Set your sample.env file with the require fields, then rename sample.env to .env
- Run tests
composer run test
License
This class is open-source and released under the MIT License. Feel free to use, modify, and distribute it according to your project's needs.
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-06