当前位置: 移动技术网 > IT编程>开发语言>PHP > 【淘宝客】PHPMailer-v6.0.5版 发送邮件dome

【淘宝客】PHPMailer-v6.0.5版 发送邮件dome

2018年08月20日  | 移动技术网IT编程  | 我要评论

话不多说,根据官方dome修改下,官方更新地址:https://github.com/phpmailer/phpmailer

<?php

use phpmailer\phpmailer\phpmailer;
use phpmailer\phpmailer\exception;

require 'phpmailer/exception.php';
require 'phpmailer/phpmailer.php';
require 'phpmailer/smtp.php';
date_default_timezone_set('prc');//设置邮件发送的时间,如果不设置,则会显示其他区的时间

$mail = new phpmailer(true);                              // passing `true` enables exceptions
try {
    //服务器设置
	// 0 = off (for production use)
	// 1 = client messages
	// 2 = client and server messages
	// 是否启用smtp的debug进行调试 开发环境建议开启 生产环境注释掉即可 默认关闭debug调试模式
    $mail->smtpdebug = 2;                                 
    $mail->issmtp();                                      // 使用smtp协议进行发送
    $mail->host = 'smtp.exmail.qq.com';  // smtp 邮箱服务器
    $mail->smtpauth = true;                               // smtp验证开启
    $mail->username = 'service@ibang114.com';                 // 用户名,一般填发件箱
    $mail->password = '';                           // 邮箱密码
    $mail->smtpsecure = 'ssl';                            // enable tls encryption, `ssl` also accepted
    $mail->port = 25;                                    // smtp端口

    //收件人
    $mail->setfrom('service@ibang114.com', '南昌大学圈');	 // 设置发件人邮箱地址
    $mail->addaddress('123456789@qq.com', '尊敬的客户');     // 设置收件人邮箱地址

    //内容
    $mail->ishtml(true);                       // 将电子邮件格式设置为 html
	$mail->charset = 'utf-8';
    $mail->subject = '静夜思';				  //邮件的主题
    $mail->body    = '床前明月光<br />疑是地上霜<br />举头望明月<br />低头思故乡<br />';//邮件的内容


    $mail->send();
    echo '邮件已发送';
	} catch (exception $e) {
		echo '无法发送邮件。邮件错误: ', $mail->errorinfo;
	}
?>

  

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网