定制 leafs/mail 二次开发

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

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

leafs/mail

最新稳定版本:v2.2

Composer 安装命令:

composer require leafs/mail

包简介

Leaf PHP bareui templating engine

README 文档

README



Leaf Mail Module



Leaf Mail v2

Latest Stable Version Total Downloads License

Mailing in PHP apps has always been seen as a daunting task. Leaf Mail provides a simple, straightforward and efficient email API that is built on the widely used PHPMailer Library component.

With Leaf Mail, you can easily send emails using various drivers and services such as SMTP, Mailgun, SendGrid, Amazon SES, and sendmail. This flexibility enables you to swiftly begin sending emails through a preferred local or cloud-based service.

Installation

You can install leaf mail using the leaf cli:

leaf install mail

or with composer:

composer require leafs/mail

Basic Usage

Leaf Mail provides a Mailer class that is responsible for validating and sending emails. This class handles the connection to your mail server, the configuration for how to send your emails and the actual sending of emails.

It also provides a mailer() method that is responsible for creating and formatting emails. Most of the time, you'll be using the mailer() method to create and send emails.

Note that you need to setup the connection to your mail server using the Leaf\Mail\Mailer class before sending your emails.

Configure your mailer

use Leaf\Mail\Mailer;
use PHPMailer\PHPMailer\PHPMailer;

...

Mailer::connect([
  'host' => 'smtp.mailtrap.io',
  'port' => 2525,
  'charSet' => PHPMailer::CHARSET_UTF8,
  'security' => PHPMailer::ENCRYPTION_STARTTLS,
  'auth' => [
    'username' => 'MAILTRAP_USERNAME',
    'password' => 'MAILTRAP_PASSWORD'
  ]
]);

Send your mails

mailer()
  ->create([
    'subject' => 'Leaf Mail Test',
    'body' => 'This is a test mail from Leaf Mail using gmail',

    // next couple of lines can be skipped if you
    // set defaults in the Mailer config
    'recipientEmail' => 'name@mail.com',
    'recipientName' => 'First Last',
    'senderName' => 'Leaf Mail',
    'senderEmail' => 'mychi@leafphp.dev',
  ])
  ->send();

统计信息

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

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-20