发送邮件从本地主机在XAMPP与PHP
问题描述:
我看到了堆栈溢出的许多问题和答案,并尝试了很多从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';
}
?>
虽然我净看见了,我无法找到工作解决方案。
答
尝试:
- 取消注释 “延长= 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
'sendmail_path =“C:\ xampp \ sendmail \ sendmail.exe -t”'看看是否有所作为。在打开' 2014-11-03 18:46:20
没有显示错误。而且它仍然提供相同的输出。 “对不起” – bulbasaur 2014-11-03 19:04:48
http://*.com/questions/712392/send-email-using-the-gmail-smtp-server-from-a-php-page – mkaatman 2014-11-03 19:22:02