PHP发送邮件---phpmailer
2010-03-13 23:42
441 查看
最近弄PHP邮件发送时,从网上载了段代码,总是有些问题,所以对这些问题的解决作一个记录,方便以后查阅。
PHP发送邮件:
1、class.phpmailer.php 类包的官网下载最新版的phpmailer类,要注册的哦。
2、注意看你的发送邮箱是不是开通的SMTP服务。登录邮箱 -> 设置, 查看是否支持SMTP或是否开启。
3、问题:it is not safe to rely on the system's timezone settings.
方法一:有人说,修改php.ini里的date.timezone ="Asia/Shanghai",改变时区为系统时区。但我试验不行。
方法二:Add the following before the first function:
4、SMTP Error: Could not authenticate. 这个是因为smtp验证没通过,就是smtp server 的用户名和密码不正确了。所以确认你的用户名和密码,如果试过了不行,不妨把你的$mail->From改为跟发送邮件地址一致,就是跟用户名一致。这样它应该就觉得这是个安全的了。
5、如果你安装了OUT LOOK之类的软件,可以先用这些软件配置,检验成功了,再把配置搬到代码上来,如端口之类的。
如果还有其它问题可以参考一下:http://www.javaeye.com/topic/367249
可能又帮助
下载phpmailer类。到http://download.csdn.net/source/2125530
PHP发送邮件:
1、class.phpmailer.php 类包的官网下载最新版的phpmailer类,要注册的哦。
2、注意看你的发送邮箱是不是开通的SMTP服务。登录邮箱 -> 设置, 查看是否支持SMTP或是否开启。
3、问题:it is not safe to rely on the system's timezone settings.
方法一:有人说,修改php.ini里的date.timezone ="Asia/Shanghai",改变时区为系统时区。但我试验不行。
方法二:Add the following before the first function:
date_default_timezone_set('UTC');我是采用这个方法的。
4、SMTP Error: Could not authenticate. 这个是因为smtp验证没通过,就是smtp server 的用户名和密码不正确了。所以确认你的用户名和密码,如果试过了不行,不妨把你的$mail->From改为跟发送邮件地址一致,就是跟用户名一致。这样它应该就觉得这是个安全的了。
5、如果你安装了OUT LOOK之类的软件,可以先用这些软件配置,检验成功了,再把配置搬到代码上来,如端口之类的。
<?php // 请求 PHPmailer类 文件 require_once("class.phpmailer.php"); date_default_timezone_set('UTC'); $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = "smtp.126.com"; // SMTP servers $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "php_test@126.com"; // SMTP username $mail->Password = "your_password"; // SMTP password $mail->From = "php_test@126.com"; $mail->FromName = "Paul Deng"; $mail->AddAddress("php_receive@qq.com","Paul Deng"); //$mail->AddAddress("ellen@site.com"); // optional name //$mail->AddReplyTo("info@site.com","Information"); $mail->WordWrap = 50; // set word wrap //$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment //$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); $mail->IsHTML(true); // send as HTML $mail->Subject = "Flash Problem"; $mail->Body = "Hello, this is the content."; $mail->AltBody = "This is the text-only body"; if(!$mail->Send()) { echo "Message was not sent <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } echo "Message has been sent"; ?>
如果还有其它问题可以参考一下:http://www.javaeye.com/topic/367249
可能又帮助
下载phpmailer类。到http://download.csdn.net/source/2125530
相关文章推荐
- php邮件发送 phpmailer
- phpmailer邮件发送
- PHP下利用PHPMailer配合QQ邮箱下的域名邮箱发送邮件(转)
- PHPMailer ThinkPHP实现自动发送邮件功能
- 通过phpmailer发送邮件问题
- PHPmailer发送邮件SMTP Error:Could not authenticate
- 发送邮件php utf 8 乱码 phpmailer
- phpmailer在服务器上不能正常发送邮件的解决办法
- yahoo邮件用phpmailer发送的示例
- PHPMailer使用教程(PHPMailer发送邮件实例分析)
- php发送邮件教程,支持发送有附件的电子邮件-PHPMailer使用教程
- 用phpMailer发送邮件
- phpMailer在CentOS 6.5下无法发送邮件的解决办法
- PHPMailer使用教程(PHPMailer发送邮件实例分析)
- PHPMailer使用教程(PHPMailer发送邮件实例分析)
- PHPmailer发送邮件成功,对方收不到邮件
- PHPmailer发送邮件
- phpmailer发送邮件
- PHPMailer发送邮件失败:SMTP connect failed
- PHPMailer发送邮件出现Permission denied的解决办法