我試圖通過SMTP發送電子郵件,使用從GitHub下載的PHPMailer庫。我跟着一個教程,但它不想發送它的電子郵件。無法通過phpmailer發送郵件
我的httpd錯誤日誌返回以下條目:
[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\nPHP 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\n', referer: https://www.mcgamerzone.com/mailtest.php
我的代碼如下:
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 = "[email protected]";
$mail->Password = "Pass";
$mail->From = "[email protected]";
$mail->FromName = "McGamerZone.com";
$mail->Subject = "Test mail";
$mail->Body = "Testing this awesome mail";
$mail->AddAddress("[email protected]");
if(!$mail->Send()){
echo "Mailer Error: ". $mail->ErrorInfo;
} else {
echo "Message was send.";
}
請幫我解決這個問題,謝謝。
編輯:我現在得到以下輸出:
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
任何想法,爲什麼連接失敗?作爲主機信息和加密類型的憑證都是有效的。
請不要使用答案補充更多的內容/代碼/錯誤,使用編輯重新編輯您的問題,並與更新的代碼更新。 – Shehary
該輸出包含鏈接,您是否閱讀並理解它,以及那裏的信息與您的案例有關?另外,不需要將編輯僞裝成單獨的段落。在這種情況下,它甚至使事情變得不那麼清晰,因爲你說「現在我得到......」,而沒有任何信息你改變了! –