duanchui1251 2015-07-19 10:50
浏览 495
已采纳

无法通过phpmailer发送邮件

I'm trying to send E-Mails over SMTP using the PHPMailer library I just downloaded from GitHub. I followed a tutorial but it doesn't want to send its E-Mail.

My HTTPD error log returns the following entry:

[Sun Jul 19 12:44:08.067906 2015] [proxy_fcgi:error] [pid 12127:tid 140673456404224] [client -] AH01071: Got error 'PHP message: PHP Notice: Undefined index: mailtest.php in /home/mick/domains/mcgamerzone.com/public_html/header.php on line 56 PHP message: PHP Fatal error: Class 'SMTP' not found in /home/mick/domains/mcgamerzone.com/public_html/assets/sources/PHPMailer-master/class.phpmailer.php on line 1291 ', referer: https://www.mcgamerzone.com/mailtest.php

My code is as follows:

require_once("assets/sources/PHPMailer-master/class.phpmailer.php");
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tsl";
$mail->Host = "mail.mcgamerzone.com";
$mail->Port = 25;
$mail->IsHTML(true);
$mail->Username = "do_not_reply@mcgamerzone.com";
$mail->Password = "Pass";
$mail->From = "do_not_reply@mcgamerzone.com";
$mail->FromName = "McGamerZone.com";
$mail->Subject = "Test mail";
$mail->Body = "Testing this awesome mail";
$mail->AddAddress("test@mcgamerzone.com");
if(!$mail->Send()){
    echo "Mailer Error: ". $mail->ErrorInfo;
} else {
    echo "Message was send.";
}

Please help me resolve this issue, thanks.

Edit: I now get the following output:

2015-07-19 11:05:24 CLIENT -> SERVER: EHLO www.mcgamerzone.com 2015-07-19 11:05:24 CLIENT -> SERVER: STARTTLS 2015-07-19 11:05:24 SMTP Error: Could not connect to SMTP host. 2015-07-19 11:05:24 CLIENT -> SERVER: QUIT 2015-07-19 11:05:25 SMTP ERROR: QUIT command failed: ���~�#������Y�� d�h;�ѵK��
u���ZVۯ�<@{���=h�0���Zt��m?�R�j��7����M����U�9Kzշж�"����4��ƺ,��'�j࠹ė���1p��6�(a0�����A]�0'�s��1��s�ՠt�}�� Hm��:�D2��1]u���A��͆���������(���!r�.�#���cɵ=�K� )��s�k�u�~�c���qϝ�8Nq� ����O�@2�O-����\���Pl޾{����t�j���㦂JN���ݒ�J��s�wR�}�|b �R�^���j��vi�J��''Z�4���b�RɊ�G"�� ��T�t͵�ƲPq|����4���R�E��4Vn0%��0��w�o�[��(����
�7�����љc���c�w��j�_/���9��@��Vj���l�������i��r��j��{Zq��L����y��*pe�����+���;b����&A7T�@>x�\��C�W����Iw&L_4b�q�(���A��:/}��\l����$��,�y}�\�?&F��y���=eP�3�Q�&Z�,����k���(̛m~Ç_��S�o �-"����@�����a���r��^&�\23 ���l]J&�^�#n�w�Q�BJ����>��rwG�� LÂ�zo۸�G7��e-��d�q cvV$�Sn�o�V��r ��m��k{�D�d��B)\ +��nN��w��%A ?��������b`0s�����0����9��M��� ##�����B���Xi�+C���;3m�q��/>?��n��k��� ����T�t��hD�W'>����8��w�ܶԪ(��&ɻ�?8Ȋ�221 mgz05.mgzsys.net closing connection 2015-07-19 11:05:25 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Any idea why the connection fails? Both the credentials as the host info and encryption type are valid.

  • 写回答

1条回答 默认 最新

  • dougou2937 2015-07-19 10:56
    关注

    I suspect you are doing this:

    require 'class.phpmailer.class.php';
    $mail = new PHPMailer;
    

    What you should be doing is:

    require 'PHPMailerAutoload.php';
    $mail = new PHPMailer;
    

    The autoloader does not autoload itself, and it's not the PHPMailer class' job to load it.

    (source: https://github.com/PHPMailer/PHPMailer/issues/113 )

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效