我正嘗試使用php(xampp)從我的Gmail帳戶發送電子郵件。 我搜索了stackoverflow和我得到的東西,我改變了我的xampp的文件sendmail.ini和php.ini作爲,我的郵件沒有通過php函數發送郵件()
在C:\ xampp \ php \ php.ini我從行的開頭刪除了分號extension=php_openssl.dll
使SSL適用於localhost的gmail。 \ XAMPP \ sendmail的\ sendmail.ini:
我用C改變
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = [email protected]
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
然後。我替換sendmail.ini所有現有的代碼與下面的代碼
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=my-gmail-password
[email protected]
然後我寫了一個簡單的郵件功能
<?php
$to = '[email protected]';
$subject = 'Test email';
$message = "Hello World!\n\nThis is my first mail.";
$headers = "From: [email protected]\r\nReply-To: [email protected]";
$mail_sent = @mail($to, $subject, $message, $headers);
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
然後通過瀏覽器中的這個頁面上走了, 得到了呼應的郵件失敗。
我看到我的調試文件和我
14/12/03 18:24:00 ** --- MESSAGE BEGIN ---
14/12/03 18:24:00 ** To: [email protected]
14/12/03 18:24:00 ** Subject: Test email
14/12/03 18:24:00 ** From:[email protected]
14/12/03 18:24:00 ** Reply-To:[email protected]
14/12/03 18:24:00 **
14/12/03 18:24:00 ** Hello World!
14/12/03 18:24:00 **
14/12/03 18:24:00 ** This is my first mail.
14/12/03 18:24:00 ** --- MESSAGE END ---
14/12/03 18:24:01 ** Connecting to smtp.gmail.com:25
14/12/03 18:24:08 ** Connected.
14/12/03 18:24:08 << 220 mx.google.com ESMTP o17sm23150442pdn.33 - gsmtp<EOL>
14/12/03 18:24:08 >> EHLO Mukul-PC<EOL>
14/12/03 18:24:10 << 250-mx.google.com at your service, [223.186.182.29]<EOL>250-SIZE 35882577<EOL>250-8BITMIME<EOL>250-STARTTLS<EOL>250-ENHANCEDSTATUSCODES<EOL>250-PIPELINING<EOL>250-CHUNKING<EOL>250 SMTPUTF8<EOL>
14/12/03 18:24:10 ** Authenticating as [email protected]
14/12/03 18:24:10 >> STARTTLS<EOL>
14/12/03 18:24:12 << 220 2.0.0 Ready to start TLS<EOL>
14/12/03 18:24:14 >> QUIT<EOL>
lots of codes in unknown language.
14/12/03 18:21:47 ** Disconnected.
14/12/03 18:21:47 ** Disconnecting from smtp.gmail.com:25
14/12/03 18:21:47 ** Disconnected.
14/12/03 18:21:47 ** Disconnected.
14/12/03 18:21:47 ** Connection Closed Gracefully.
使'郵件'命令打印警告(在前面刪除'@'),並在'error_log'處取一個loof。 – mudasobwa 2014-12-03 12:09:29
如何檢查錯誤日誌? – MukulAgr 2014-12-03 12:10:16
找到Apache在你的系統和cat/vi上寫錯誤日誌的地方。 – mudasobwa 2014-12-03 12:11:09