全球主机交流论坛
标题:
运行PHPMailer的时候出现500错误
[打印本页]
作者:
冬日暖阳
时间:
2016-1-11 19:21
标题:
运行PHPMailer的时候出现500错误
本帖最后由 冬日暖阳 于 2016-1-11 19:23 编辑
前几天用mail()发送邮件的时候,发现有些邮箱收不到,不得不换一种方法,后来找到了PHPMailer。
可是运行PHPMailer的时候出现500错误,各个设置都没有问题,真是不知道哪里的问题了。
代码如下:
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // 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
$mail->Username = 'user@qq.com'; // SMTP username
$mail->Password = '123456'; // SMTP password
$mail->SMTPSecure = 'SSL'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom('user@qq.com', 'Mailer');
$mail->addAddress('jack@qq.com', 'Jack'); // 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';
}
复制代码
上面的设置都是根据QQ邮箱设置的,但是运行就出现500 Internal Server Error错误,谁给看下?
(为了安全起见,邮箱、用户名和密码我都是随便写的,不过我代码里面肯定是对的)
作者:
yoyo
时间:
2016-1-12 16:09
$mail->SMTPSecure = 'SSL';
把SSL改成小写试试
作者:
冬日暖阳
时间:
2016-1-13 17:08
真的可以了,一个大小写居然影响这么大,谢谢。
欢迎光临 全球主机交流论坛 (http://bbs.cuwww.com/)
Powered by Discuz! X3.2