全球主机交流论坛

标题: 运行PHPMailer的时候出现500错误 [打印本页]

作者: 冬日暖阳    时间: 2016-1-11 19:21
标题: 运行PHPMailer的时候出现500错误
本帖最后由 冬日暖阳 于 2016-1-11 19:23 编辑

前几天用mail()发送邮件的时候,发现有些邮箱收不到,不得不换一种方法,后来找到了PHPMailer。

可是运行PHPMailer的时候出现500错误,各个设置都没有问题,真是不知道哪里的问题了。

代码如下:
  1. <?php
  2. require 'PHPMailerAutoload.php';

  3. $mail = new PHPMailer;

  4. //$mail->SMTPDebug = 3;                               // Enable verbose debug output

  5. $mail->isSMTP();                                      // Set mailer to use SMTP
  6. $mail->Host = 'smtp.qq.com';  // Specify main and backup SMTP servers
  7. $mail->SMTPAuth = true;                               // Enable SMTP authentication
  8. $mail->Username = 'user@qq.com';                 // SMTP username
  9. $mail->Password = '123456';                           // SMTP password
  10. $mail->SMTPSecure = 'SSL';                            // Enable TLS encryption, `ssl` also accepted
  11. $mail->Port = 465;                                    // TCP port to connect to

  12. $mail->setFrom('user@qq.com', 'Mailer');
  13. $mail->addAddress('jack@qq.com', 'Jack');     // Add a recipient
  14. //$mail->addAddress('ellen@example.com');               // Name is optional
  15. //$mail->addReplyTo('info@example.com', 'Information');
  16. //$mail->addCC('cc@example.com');
  17. //$mail->addBCC('bcc@example.com');

  18. //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
  19. //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
  20. $mail->isHTML(true);                                  // Set email format to HTML

  21. $mail->Subject = 'Here is the subject';
  22. $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
  23. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

  24. if(!$mail->send()) {
  25.     echo 'Message could not be sent.';
  26.     echo 'Mailer Error: ' . $mail->ErrorInfo;
  27. } else {
  28.     echo 'Message has been sent';
  29. }
复制代码
上面的设置都是根据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