php 使用composer phpmailer发送qq邮件
2017-11-08 14:51
567 查看
原文很详尽
参考:http://blog.csdn.net/baidu_30000217/article/details/51550259
使用composer安装phpmailer
composer require phpmailer/phpmailer
php代码,使用的phpmailer官方demo
参考:http://blog.csdn.net/baidu_30000217/article/details/51550259
使用composer安装phpmailer
composer require phpmailer/phpmailer
php代码,使用的phpmailer官方demo
<?php // Import PHPMailer classes into the global namespace // These must be at the top of your script, not inside a function use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; //Load composer's autoloader require 'vendor/autoload.php'; $mail = new PHPMailer(true); // Passing `true` enables exceptions try { //Server settings $mail->SMTPDebug = 2; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.qq.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication //smtp登录的账号 这里填入字符串格式的qq号即可 $mail->Username = '123@qq.com'; // SMTP username //smtp登录的密码 使用生成的授权码(通过qq邮箱活得的授权码) $mail->Password = 'xxxxxxxxi'; // SMTP password //设置使用ssl加密方式登录鉴权 $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted //设置ssl连接smtp服务器的远程服务器端口号,以前的默认是25,但是现在新的好像已经不可用了 可选465或587 $mail->Port = 465; // TCP port to connect to //Recipients $mail->setFrom('123@qq.com', 'Mailer'); //设置收件人邮箱地址 该方法有两个参数 第一个参数为收件人邮箱地址 // 第二参数为给该地址设置的昵称 不同的邮箱系统会自动进行处理变动 这里第二个参数的意义不大 $mail->addAddress('123@qq.com', 'Joe User'); // Add a recipient //$mail->addAddress('ellen@example.com'); // Name is optional //答复 $mail->addReplyTo('123@qq.com', 'Information'); //$mail->addCC('cc@example.com'); //$mail->addBCC('bcc@example.com'); //Attachments 附件 //$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name //Content $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'Here is the subject'; $mail->Body = 'This is the HTML message body <b>in bold!</b>'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; }
相关文章推荐
- PHPMailer使用教程(PHPMailer发送邮件实例分析)
- PHP程序使用PHPMailer发送邮件和附件
- php使用PHPMailer邮件类发送邮件
- PHP使用PHPmailer发送邮件方法
- PHP_thinkphp框架使用PHPMailer实现发送邮件的功能,以及各种问题解析
- PHP使用PHPMailer发送邮件的简单使用方法
- Wordpress无法发送邮件,基于插件“Contact Form 7”,修改class-phpmailer.php使用SMTP解决。
- PHP使用PHPMailer实现发送邮件
- [转帖]在PHP中使用phpmailer组建发送邮件
- PHP 实现 注册等的邮箱验证 (二)—— 使用 PHPMailer 发送邮件
- php使用phpmailer发邮件,在window可以使用,linux无法发送邮件,出现could not connect to smtp host错误
- 使用PHP邮件库swiftmailer发送邮件时,QQ,163邮箱的配置
- PHP使用PHPMailer发送邮件
- PHP:在Yii Framework中扩展使用PHPMailer发送邮件
- [PHP]使用PHPMailer发送带附件并支持HTML内容的邮件
- PHP使用PHPMailer发送邮件的简单使用方法
- PHP发送邮件类库PHPMailer的简单使用
- php使用phpmailer发送邮件实例解析
- PHP发送邮件类库PHPMailer的简单使用