yng / yng-mailer
📧 YNG Mail: Easy and fast PHP email creation and transfer library, supporting text and HTML compatibility.
dev-main
2023-06-02 09:29 UTC
Requires
- php: >=5.5.0
- ext-ctype: *
- ext-filter: *
- ext-hash: *
Suggests
- ext-mbstring: Needed to send email in multibyte encoding charset or decode encoded addresses
- ext-openssl: Needed for secure SMTP sending and DKIM signing
- greew/oauth2-azure-provider: Needed for Microsoft Azure XOAUTH2 authentication
- hayageek/oauth2-yahoo: Needed for Yahoo XOAUTH2 authentication
- league/oauth2-google: Needed for Google XOAUTH2 authentication
- psr/log: For optional PSR-3 debug logging
- symfony/polyfill-mbstring: To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)
- thenetworg/oauth2-azure: Needed for Microsoft XOAUTH2 authentication
This package is auto-updated.
Last update: 2024-12-31 00:19:15 UTC
README
基于phpmailer进行了简单封装 支持PHP5.5+
安装
composer require yng/mailer
发送SMTP邮件
$mail = new Yng\Mailer\YNGMailer; $mail->send([ 'to' => 'Yng1@example.com', // 'to' => ['Yng1@example.com' => 'yng'],// 邮件 => 发件人名 'cc' => 'Yng2@example.com',//抄送 // 'cc' => ['Yng2@example.com' => 'yng',...], 'bcc' => 'Yng3@example.com',//密送 // ... ], 'this is subject',//主题 [ 'content' => "Hello, Welcome to use Yng-Mailer body",//内容 'altbody' => '如果邮件客户端不支持HTML则显示此内容',//提示语 // 'attachment' => ['/www/wwwroot/blog/public/aaa.txt'],//附件 绝对路径 'attachment' => ['/www/wwwroot/blog/public/aaa.txt' => 'aaa.txt'],//附件 绝对路径 => 文件名 ], );
配置
需在env
文件配置或者config/mailer.php
里配置
return [ // 邮件驱动 支持smtp,mail,sendmail,qmail,默认SMTP 'mail_mailer' => 'SMTP', // 是否调试,0无输出,1输出客户端信息,2输出客户端和服务端信息,3显示连接状态,客户端 -> 服务器和服务器 -> 客户端消息,4显示所有消息 'mail_debug' => env('mail_debug',0), // 主机地址:例如smtp.qq.com, smtp.163.com等 'mail_host' => env('mail_host','smtp.qq.com'), // 是否启用smtp认证,true/false 'mail_smtpauth' => env('mail_smtpauth',true), // 发件人邮箱 'mail_username' => env('mail_username','yng@example.com'), // 授权码 'mail_password' => env('mail_password',''), // 端口号 常用有465, 25;具体看官方设置 'mail_port' => env('mail_port',25), // 协议,支持ssl, tls 'mail_smtpsecure' => 'ssl', // 发件人名称 'mail_from_name' => '野牛哥', // 是否输出异常信息 'mail_is_error' => true, // 超时时间,默认5分钟,单位秒 'mail_timeout' => env('mail_timeout',300), // 日志存放路径,为空默认不存,绝对路径 'mail_log_path' => '', // 邮件编码,默认utf-8 'mail_charset' => env('mail_charset','utf-8'), ];