2014-11-03 130 views
0

我看到了堆棧溢出的許多問題和答案,並嘗試了很多從XAMPP本地主機發送郵件,但所有的嘗試都是徒勞的。 這裏是我的semdmail.ini文件:發送郵件從本地主機在XAMPP與PHP

smtp_server=smtp.gmail.com 
smtp_port=587 
error_logfile=error.log 
debug_logfile=debug.log 
auth_username=******@gmail.com 
auth_password=*** 
force_sender= *****@gmail.com 

我的php.ini文件中包含此

sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 
mail.add_x_header = Off 

我的PHP文件如下

<?php 
if(mail ('[email protected]', 'asdf', 'asdf', 'From: [email protected]')) 
{ 
    echo 'success'; 
}else 
{ 
    echo 'sorry'; 
} 
?> 

雖然我淨看見了,我無法找到工作解決方案。

+2

'sendmail_path =「C:\ xampp \ sendmail \ sendmail.exe -t」'看看是否有所作爲。在打開'<?php'標籤後立即在文件頂部添加錯誤報告 'error_reporting(E_ALL); ini_set('display_errors',1);'看看它是否產生任何東西。 – 2014-11-03 18:46:20

+0

沒有顯示錯誤。而且它仍然提供相同的輸出。 「對不起」 – bulbasaur 2014-11-03 19:04:48

+0

http://stackoverflow.com/questions/712392/send-email-using-the-gmail-smtp-server-from-a-php-page – mkaatman 2014-11-03 19:22:02

回答

0

嘗試:

  • 取消註釋 「延長= php_openssl.dll」 在php.ini中(C:\ XAMPP \ PHP \ php.ini中)
  • 註釋,然後在php.ini配置節「 [郵件功能]「:

_

[mail function] 
SMTP = smtp.gmail.com 
SMTP = smtp.gmail.com 
smtp_port = 587 
; For Win32 only. 
; http://php.net/sendmail-from 
;sendmail_from = [email protected] 

; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesC:\xampp) fakemail and mailtodisk do not work correctly. 
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path. 
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder) 
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" 

; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder 
sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe" 

希望它能幫助

+0

它取得成功,但郵件無法在收件箱或垃圾郵件。感謝您的幫助......(我用我的個人電子郵件地址代替[email protected]) – bulbasaur 2014-11-04 05:01:28

+0

您使用PHPMailer庫嗎? https://github.com/PHPMailer/PHPMailer – 2014-11-05 16:48:44

相關問題