文章标题
来源:互联网 发布:撕开照片衣服的软件 编辑:程序博客网 时间:2024/06/17 14:21
php 邮件函数
1,使用到插件phpmailer网上可以下载
注意:发送邮件的邮箱需要将POP3/SMTP服务等必要的服务开启,否则会失败
<?php/*** 函数用途描述* @date: 2016-4-8 下午3:44:52* @author: LEO* @param: $to 接收该邮件的地址 $subject 邮件的标题 $body 邮件的主题内容* @return:*/require_once('class.phpmailer.php');include('class.smtp.php');function postmail($to,$subject = '',$body = ''){ //$to 表示收件人地址 $subject 表示邮件标题 $body表示邮件正文 error_reporting(E_STRICT); date_default_timezone_set('Asia/Shanghai');//时区设置小心未来的邮件 $mail=new PHPMailer(); //new一个PHPMailer对象出来 $body=eregi_replace("[\]",'',$body); //对邮件内容进行必要的过滤 $mail->CharSet ="utf8";//设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码 $mail->IsSMTP(); // 设定使用SMTP服务 $mail->SMTPDebug = 1; // 启用SMTP调试功能 // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true;// 启用 SMTP 验证功能如果是false就会出现SMTP server error: Error: need EHLO and AUTH first ! $mail->SMTPSecure = "ssl";// 安全协议,可以注释掉如果启用smtp验证功能必须使用ssl $mail->Host= 'smtp.qq.com';// SMTP 服务器 $mail->Port= 465; // SMTP服务器的端口号ssl qq邮件服务器的端口号 $mail->Username= 'yyyyyy@qq.com';// SMTP服务器用户名,PS:我乱打的 $mail->Password= 'dfdxs'; //qq邮箱的授权密码不是真正的邮箱密码 $mail->SetFrom('yyyyyy@qq.com', 'yyyyyy'); //填写发送邮件的邮件地址 // $mail->AddReplyTo('xxx@xxx.xxx','who'); $mail->Subject = $subject; $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional, comment out and test $mail->MsgHTML($body); $address = $to; $mail->AddAddress($address, ''); //$mail->AddAttachment("images/phpmailer.gif"); // attachment //$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment if(!$mail->Send()) { echo 'Mailer Error: ' . $mail->ErrorInfo; } else { header("Content-type:text/html; charset=utf-8"); echo "Message sent!恭喜,邮件发送成功!"; }}postmail('yyyyyy@aliyun.com','My subject','哗啦啦'); ?>
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 设计模式笔记-单例模式
- Linux系统参数配置简介
- 百度之星2016初赛第二场(Astar Round 2B)
- 触发器的操作
- iOS开发之二维码扫描
- 文章标题
- LeetCode 141. Linked List Cycle
- 前端架构组件化开发系列一(Grid)
- 视频播放
- SharedPreferences详解
- LightOJ 1010 Knights in Chessboard
- jsp生成html
- Android WebView与JS的交互
- LeetCode 208: Implement Trie (Prefix Tree)