Blogger Information
Blog 8
fans 0
comment 1
visits 10292
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
利用phpmailer发送邮件
Moments的博客
Original
1203 people have browsed it
  1. 先下载phpmailer

  2. 将下载下来的phpmailer放到vendor文件夹下

    无标题.png

  3. 在需要发送邮件的php代码中引入phpmailer,具体实现代码如下

use phpmailer\PHPMailer;    


    vendor("phpmailer.\phpmailer");  //具体方法中引入phpmailer

    $mail = new PHPMailer();

    $mail->IsSMTP();  // 启用SMTP

    $mail->Host = 'smtp.163.com';  //SMTP服务器 qq:smtp.qq.com 163:smtp.163.com

    $mail->CharSet = 'UTF-8';

    $mail->Port = 25;  //邮件发送端口

    $mail->SMTPAuth = true;  //启用SMTP认证

    $mail->CharSet = "UTF-8"; //字符集

    $mail->Username = 'fajianren@163.com';  //发件人邮箱

    $mail->Password = fajianrenmima;  //发件人邮箱密码,第三登录需要授权码

    $mail->SetFrom('fajianren@163.com','zxx');

    $mail->AddAddress("594003618@qq.com", "亲"); //添加收件人(地址,昵称) 

    $mail->IsHTML(true); //支持html格式内容

    $mail->Subject = '标题'; //邮件标题

    $mail->Body = "内容"; //邮件主体内容

    $res = $mail->Send();

4.有时候发送不成功,因为是第三方登录邮件服务器,所以不能直接输入密码,在开启POP3/SMTP服务时,邮箱会自动分配一个动态密码,也就是授权码,用这个授权码才可以使得php连接上邮件服务器

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post