簡體   English   中英

從本地服務器xampp / sendmail發送電子郵件

[英]Sending email from localhost server xampp/sendmail

我已經建立了一個將在本地托管的PHP網站。 一種功能是發送包含購物車中物品的電子郵件。 在線托管(用於測試)時,email()函數可以完美地發送電子郵件。

我現在正在將該站點轉移到本地計算機,並且無法發送電子郵件。

最初,這些電子郵件來自servername@hostname.co.uk,盡管我很樂意設置一個gmail或類似的東西來處理發送,但效果很好。

我已經閱讀了一些有關設置的教程,並且首先嘗試使用sendmail和gmail地址。

我想知道是否在設置ini文件時錯過了一些簡單的事情。

我按如下方式編輯了php.ini文件:

[mail function]
 XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
 SMTP = smtp.gmail.com
 smtp_port = 587

 For Win32 only.
 http://php.net/sendmail-from
sendmail_from = shipimageemail@gmail.com

; 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"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header=Off

; Log all mail() calls including the full path of the script, line #, to address and headers
mail.log = "C:\xampp\php\logs\php_mail.log"

然后我的sendmail.ini文件如下:

[sendmail]

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

嘗試這個

sendmail.ini

[發送郵件]

smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=ssl
error_logfile=error.log
debug_logfile=debug.log
auth_username=[email]@gmail.com
auth_password=[email password]
pop3_server=
pop3_username=
pop3_password=
force_sender=[email]@gmail.com
force_recipient=
hostname=smtp.gmail.com

php.ini中

[郵件功能]

SMTP = smtp.gmail.com
smtp_port = 465
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header=Off

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM