邮件发送支持两种驱动,Fsock 和 phpMailer,配置信息在 `extra/mail.php` 中:
##配置
`extra/mail.php`
return [
'driver'=> 'fsock', //驱动 fsock|phpmailer
'smtp_pc' => '', //发信计算机名 可随意填写
'smtp_host' => 'smtp.mxhichina.com', //发信SMTP服务器地址
'smtp_port' => 25, //发信SMTP服务器端口号
'smtp_addr' => '', //发信帐号名
'smtp_pass' => '', //发信帐号密码
'smtp_name' => '', //发信用户名
'content_type' => 'text/html', //文本类型 text/html 或 text/plain
'charset' => 'utf-8', //字符编码
'line_break' => "rn",
];
##方法
`Mail::instance()->mail($receive, $content, $subject = 'No Subject')`
>[info] 邮件发送失败返回 `false`,成功返回 `true`,可以通过 `getError()` 方法获取错误信息
##参数
| 名称 | 类型 | 说明 |
| --- | --- | --- |
| receive | string | 收件人邮箱地址 |
| content | string | 邮件内容,配置里 `content_type` 为 `text/html` 时 `content` 为 `html`,为 `text/plain` 时为纯文本 |
| subject | string | 邮件主题,默认为无主题 |
##使用示例
```
$receive = $this->request->post("receiver");
$result = $this->validate(
['receiver' => $receive],
['receiver|收件人' => 'require|email']
);
if ($result !== true) {
return ajax_return_adv_error($result);
}
$html = "这是一封来自tpadmin的测试邮件,请勿回复
该邮件由访问发送,本站不承担任何责任,如有骚扰请屏蔽此邮件地址
";
$result = Mail::instance()->mail($receive, $html, "测试邮件");
if ($result !== true) {
return ajax_return_adv_error(Mail::instance()->getError());
} else {
return ajax_return_adv("邮件发送成功,请注意查收");
}
```



