设为首页收藏本站

全球主机交流论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
热搜: discuz
查看: 976|回复: 2
打印 上一主题 下一主题

运行PHPMailer的时候出现500错误

[复制链接]
  • TA的每日心情
    奋斗
    2017-4-5 18:38
  • 签到天数: 4 天

    [LV.2]偶尔看看I

    跳转到指定楼层
    楼主
    发表于 2016-1-11 19:21:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    本帖最后由 冬日暖阳 于 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错误,谁给看下?

    (为了安全起见,邮箱、用户名和密码我都是随便写的,不过我代码里面肯定是对的)


    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
    收藏收藏
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    2017-9-16 13:30
  • 签到天数: 21 天

    [LV.4]偶尔看看III

    沙发
    发表于 2016-1-12 16:09:37 | 只看该作者
    $mail->SMTPSecure = 'SSL';  
    把SSL改成小写试试
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    奋斗
    2017-4-5 18:38
  • 签到天数: 4 天

    [LV.2]偶尔看看I

    板凳
     楼主| 发表于 2016-1-13 17:08:56 | 只看该作者
    真的可以了,一个大小写居然影响这么大,谢谢。
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|小黑屋|Archiver|手机版|中国U网    

    GMT+8, 2024-4-20 16:04 , Processed in 0.067998 second(s), 20 queries .

    Powered by Discuz! X3.2

    © 2001-2013 Comsenz Inc.

    快速回复 返回顶部 返回列表