【问题标题】:sending mail using XAMPP, sendmail, and gmail smtp server [duplicate]使用 XAMPP、sendmail 和 gmail smtp 服务器发送邮件 [重复]
【发布时间】:2012-06-08 04:17:45
【问题描述】:

这看起来很简单,我的 php 脚本能够执行。但是我从来没有收到邮件。以下是相关代码:

php.ini

[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
; http://php.net/smtp-port
;smtp_port = 25

sendmail_path = "C:\xampplite\sendmail\sendmail.exe -t -i"

sendmail.ini

smtp_server=smtp.gmail.com

smtp_port=587
smtp_ssl=auto
default_domain=mydomain.com
error_logfile=error.log
debug_logfile=debug.log
auth_username=username50@gmail.com
auth_password=passpass

force_sender=myemail@gmail.com
hostname=smtp.gmail.com

这里有什么我遗漏的吗?我的脚本正在向自己发送电子邮件。那应该不是问题吧?

<?php
$to = "blah@gmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

【问题讨论】:

  • 你烧水银了吗?
  • 我没有打开水银。我的印象是,如果您以使用 gmail 的方式使用外部 smtp 服务器,则没有必要
  • 你有正确的端口吗? SSL 端口:465
  • smtp_server=smtp.gmail.com smtp_port=465 smtp_ssl=auto default_domain=gmail.com auth_username=user50@gmail.com auth_password=pass force_sender=myemail@gmail.com hostname=gmail.com 这行得通
  • “这行得通”是什么意思?您是否解决了整个问题(可以接收电子邮件)或者只是能够按照建议设置端口 465?在第一种情况下,对您自己的问题给出正式的答案,以便其他人可以看到并使用它。

标签: php smtp xampp sendmail.exe


【解决方案1】:

试试这个

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

【讨论】:

    猜你喜欢
    • 2011-10-21
    • 2011-05-13
    • 2016-09-07
    • 2020-11-19
    • 2015-04-23
    • 2011-10-25
    • 2011-03-17
    • 2011-08-01
    • 2018-11-14
    相关资源
    最近更新 更多