我在Stack Overflow上看到了许多问题和答案,并尝试了许多问题和答案,从XAMPP中的localhost发送邮件,但所有的尝试都是徒劳的。 这是我的semdmail.ini文件:
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 ('abcd@gmail.com', 'asdf', 'asdf', 'From: vh@gmail.com'))
{
echo 'success';
}else
{
echo 'sorry';
}
?>
虽然我在网上看到,但我找不到合适的解决方案。
答案 0 :(得分:0)
尝试:
_
[mail function]
SMTP = smtp.gmail.com
SMTP = smtp.gmail.com
smtp_port = 587
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost
; 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"
希望有所帮助