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 MATLAB动图问题
  • ¥15 有段代码不知道怎么理解,const isToken = (config.headers || {}).isToken === false
  • ¥100 采用栈和深度优先算法对我的代码进行修改显示路径
  • ¥15 pointnet2包安装
  • ¥20 射频功率问题,解答者有酬谢!
  • ¥80 构建降雨和积水的预测模型
  • ¥15 #Qt Transform setTransform()在鼠标拖动移动视角是一致在原地不动,无法变换视角(细微观察似乎视图有在原地抖动),无法变换视角(细微观察似乎视图有在原地抖动)
  • ¥50 如何利用无人机拍摄的数码照片测量鸟卵的长短径
  • ¥100 github贡献者给与奖励
  • ¥15 使用DS18B20+ESP8266获取温度数据返回-127.00