Skip to content

chenbool/mail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

PHP Mail SDK

PHP 原生实现的 SMTP 邮件发送工具,无需 PHP 扩展支持。

功能特性

  • SMTP 协议邮件发送
  • 支持普通文本和 HTML 格式
  • 兼容主流邮箱服务(网易、QQ、Gmail 等)

项目结构

mail/
├── mail.php    # 邮件发送类
└── README.md   # 项目说明

快速开始

include 'mail.php';

$config = [
    'smtp_host' => 'smtp.163.com',
    'smtp_port' => 25,
    'smtp_user' => 'bool1993@163.com',
    'smtp_pass' => 'your_password',
    'smtp_name' => 'bool',
    'html'      => true,
];

$mail = new Mail($config);
$mail->send('bool1993@qq.com', 'Subject', '<h1>Content</h1>');

配置参数

参数 类型 说明 必填
smtp_host string SMTP 服务器地址
smtp_port int SMTP 端口(25/465/587)
smtp_user string 发送账号
smtp_pass string 发送密码
smtp_name string 发件人昵称
html bool 是否支持 HTML 格式

常用邮箱配置

网易 163

$config = [
    'smtp_host' => 'smtp.163.com',
    'smtp_port' => 25,
    'smtp_user' => 'your_email@163.com',
    'smtp_pass' => 'password',
    'smtp_name' => '发件人昵称',
    'html'      => true,
];

腾讯 QQ

$config = [
    'smtp_host' => 'smtp.qq.com',
    'smtp_port' => 587,
    'smtp_user' => 'your_email@qq.com',
    'smtp_pass' => 'password',
    'smtp_name' => '发件人昵称',
    'html'      => true,
];

Gmail

$config = [
    'smtp_host' => 'smtp.gmail.com',
    'smtp_port' => 587,
    'smtp_user' => 'your_email@gmail.com',
    'smtp_pass' => 'password',
    'smtp_name' => '发件人昵称',
    'html'      => true,
];

方法说明

方法 说明
send($to_user, $subject, $content) 发送邮件

注意事项

  1. 部分邮箱需要开启 SMTP 服务
  2. QQ 邮箱需使用授权码而非登录密码
  3. Gmail 需开启"低安全性应用访问"

About

php发送邮件sdk

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages