【发布时间】:2014-09-12 01:49:22
【问题描述】:
我需要从 XAMPP 安装的 localhost 发送电子邮件。 正如许多教程所示,我不想将 Sendmail 与 Gmail 一起使用。
有什么方法可以在 localhost 上工作 PHP mail() 函数?
【问题讨论】:
-
即使您不需要 Gmail,您也需要一个正常工作的 SMTP 服务器。你必须租一个,或者在 VPS 上设置自己的。
我需要从 XAMPP 安装的 localhost 发送电子邮件。 正如许多教程所示,我不想将 Sendmail 与 Gmail 一起使用。
有什么方法可以在 localhost 上工作 PHP mail() 函数?
【问题讨论】:
如果您像这样配置 C:\xampp\php\php.ini 和 c:\xampp\sendmail\sendmail.ini 让 gmail 发送邮件。
现在在C:\xampp\php\php.ini 找到extension=php_openssl.dll 并从该行的开头删除分号,以使SSL 为本地主机的gmail 工作。
文件在php.ini中找到[mail function]并更改
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my-gmail-id@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
然后打开它C:\xampp\sendmail\sendmail.ini。将sendmail.ini中的所有现有代码替换为以下代码
[发送邮件]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=my-gmail-id@gmail.com
auth_password=my-gmail-password
force_sender=my-gmail-id@gmail.com
【讨论】: