美文网首页
php脚本发送邮件

php脚本发送邮件

作者: helloxiaogui | 来源:发表于2016-04-26 09:09 被阅读95次

第一天在简书写东西,就随便写点吧………(写的不是很专业,不要嫌弃………)
-----------------------------我是分割线--------------------------------
在百度上面搜索发现基本上每个人用的方法都不一样,一般github的东西会比较好用,来给你们安利!项目地址https://github.com/PHPMailer/PHPMailer 复制这个地址,然后在终端:git clone https://github.com/PHPMailer/PHPMailer 就可以把它下到当前目录

在这个PHPMailer目录下,新建一个text.php文件,内容:

<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3;                              // Enable verbose debug output
$mail->isSMTP();                                      // �使用SMTP协议
$mail->Host = 'smtp.qq.com';  // qq邮箱的服务器端地址
$mail->SMTPAuth = true;                              //SMTP 授权
$mail->Username = '要发送端邮箱@qq.com';                // 配置发送邮箱的用户
$mail->Password = '�mima';                          // 配置发送端邮箱密码
$mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465;                                    //qq邮箱的ssl的端口是465
$mail->setFrom('发送端邮箱@qq.com', 'Mailer');    //发送地址,昵称
$mail->addAddress('接收邮箱@qq.com', 'Joe User');    // 接收地址,昵称
// $mail->addAddress('ellen@example.com');              // Name is optional
// $mail->addReplyTo('info@example.com', 'Information');
// $mail->addCC('cc@example.com');
// $mail->addBCC('bcc@example.com');
// $mail->addAttachment('/var/tmp/file.tar.gz');        // Add attachments
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
$mail->isHTML(true);                                  // Set email format to HTML
// 主题
$mail->Subject = 'Here is the subject';$mail->Body    = 'This is the HTML message body**in bold!**';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';//内容
if(!$mail->send()) {    
     echo 'Message could not be sent.';    
     echo 'Mailer Error: ' . $mail->ErrorInfo;} 
else {   
      echo 'Message has been sent';
}
?>

-----------------------分割线---------------------

相关文章

  • php脚本发送邮件

    第一天在简书写东西,就随便写点吧………(写的不是很专业,不要嫌弃………)---------------------...

  • Linux cron 中脚本执行超时限定和互斥配置

    Linux cron 中脚本执行超时限定和互斥配置 场景 假设有一个 PHP 脚本用来发送邮件,使用 Linux ...

  • python发送邮件(转)

    下面的发送邮件的脚本:

  • 定时发送邮件

    描述:每五天发送一封邮件1.写定时脚本2.发送邮件1.定时脚本 2。1中发邮件脚本见https://www.jia...

  • Python3发邮件(HTML/图片/Excel)

    一、思路 使用脚本发送邮件的思路,其实和客户端发送邮件一样,过程如下: 登录 -—> 邮件 -—> 发送 思维脑图...

  • PHP发送邮件

    01 PHP发送邮件有内置函数mail,但是需要配置sendmail邮件服务器,这不是一个轻松的工作,需要你对邮件...

  • PHP发送邮件

    作为PHP入门开发者,常常有这种述求:自己的网站中需要添加一个使用自己的域名作为发件人邮件地址的自动发送邮件的方法...

  • PHP的语法

    PHP语法 PHP 脚本在服务器上执行,然后将纯 HTML 结果发送回浏览器。 基本的 PHP 语法 PHP 脚本...

  • PHP 利用QQ邮箱发送邮件「PHPMailer」

    PHPMailer PHPMailer 是一个封装好的 PHP 邮件发送类,支持发送 HTML 内容的电子邮件,以...

  • tp5 使用邮箱发送功能 PHPMailer

    PHPMailer PHPMailer 是一个封装好的 PHP 邮件发送类,支持发送 HTML 内容的电子邮件,以...

网友评论

      本文标题:php脚本发送邮件

      本文链接:https://www.haomeiwen.com/subject/dcuqrttx.html