1、环境说明
阿里云centos7
thinkphp5.0.11
swoole2.0.8
2、tp实现邮件发送
在项目下建立如下的文件目录:
其中SendMail.php是我们实际调用的发送邮件的文件。以下是主要代码:
namespace app\library\utils\mail;
use app\library\utils\mail\PhpMailer;
use app\library\utils\mail\Smtp;
use think\Log;
error_reporting(E_STRICT);
date_default_timezone_set('Asia/Shanghai');
class SendMail
{
static function postmail($to,$subject = '',$body = ''){
$mail = new PhpMailer();
$mail->CharSet = config('mail.CharSet');
$mail->IsSMTP();
$mail->SMTPDebug = config('mail.SMTPDebug');
$mail->SMTPAuth = config('mail.SMTPAuth');
$mail->SMTPSecure = config('mail.SMTPSecure');