php发送邮件 (phpmailer)

1.首先下载phpMailer文件官方文件https://sourceforge.net/projects/phpmailer/;

还有class.smtp.php.

2.去配置一下发送邮件的服务器,如果没有可以去第三方配置;

sendMial.php

<?php
    require_once("inc/phpmailer/class.phpmailer.php");
    require_once("inc/phpmailer/class.smtp.php");

    $mail=new PHPMailer();

//调试
    $mail->SMTPDebug=1;
//鉴权
    $mail->SMTPAuth=true;
//发送服务器为smtp
    $mail->IsSMTP();

//发送邮件编码
    $mail->CharSet='utf-8';
//发送服务器地址
    $mail->Host='smtp.qq.com';
//发送邮件端口
    $mail->Port=465;
//加密登录ssl
    $mail->SMTPSecure='ssl';
//发送服务器账号
    $mail->Username='[email protected]';
//密码登录
    $mail->Password='asdasdfasfmasdmioq';(这个是开启smtp之后给你发送的授权码)

//发送地址
    $mail->From='[email protected]';

//发送用户()
    $mail->FromName='1234567';

//发送主题
    $mail->Subject="this is a email send program";
    $mail->Body="<h1>hello world</h1>";
    $mail->IsHTML(true);

//收件地址
    $mail->AddAddress('[email protected]');
    for($i=0;$i<5;$i++){
            $mail->Send();

    }

猜你喜欢

转载自www.cnblogs.com/isFinite-rs/p/9252770.html