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 )

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

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP