最近在写一个网页的时候,需要用到PHPmailer来发送邮件,按照官网上给出的demo写出一个例子,却报错Extension missing: openssl

   最后发现需要修改php.ini中的配置:

   将其中的

      extension=php_openssl.dll

   打开即可。

   

   demo代码添加如下:

 <?php
require 'PHPMailerAutoload.php'; $mail = new PHPMailer; //$mail->SMTPDebug = 3; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user@example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to $mail->setFrom('from@example.com', 'Mailer');
$mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
$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 <b>in bold!</b>';
$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';
}

   

最新文章

  1. mongoDB简介
  2. $().index() 两种用法
  3. 【JS】两种计时器/定时器
  4. Head First 设计模式 --5 单例模式
  5. ADAS技术应用
  6. scrum 4.0
  7. webpages框架中使用Html.TextArea()在前台显示多行信息时,如何进行大小、样式的设置
  8. Android 获取信号强度
  9. java修改远程服务器密码
  10. MySQL常用数值函数
  11. 网络编程-Python高级语法-property属性
  12. oracle 中如何查看某个表所涉及的存储过程
  13. uniGUI试用笔记(七)
  14. [Chrome_Error] (failed) net::ERR_INCOMPLETE_CHUNKED_ENCODING 与 nginx 502 bad gateway
  15. Python虚拟环境工具-Virtualenv 介绍及部署记录
  16. idea 错误: -source 1.6 中不支持 diamond 运算符的解决办法
  17. 使用wmic.exe绕过应用程序白名单(多种方法)
  18. OC开发_Storyboard——绘制和视图
  19. Django错误大汇总
  20. Go语言打印调用堆栈

热门文章

  1. Linux网络编程-tcp缓存设置
  2. Struts2+Spring+Hibernate框架整合总结详细教程
  3. BootStrap_04之jQuery插件(导航、轮播)、以及Less
  4. MongoDB下载安装与简单增删改查
  5. Android消息传递之EventBus 3.0使用详解
  6. ASP.NET MVC Html.BeginForm 设置 timeout
  7. ZFPlayer 源码解读
  8. ASP.NET Core 中文文档 第二章 指南(4.8)添加新的字段
  9. .Net 序列化(去除默认命名空间,添加编码)
  10. Apworks框架实战(五):EasyMemo的领域模型设计