【问题标题】:how to configure XAMPP to send email from localhost php [duplicate]如何配置 XAMPP 以从 localhost php 发送电子邮件 [重复]
【发布时间】:2017-01-25 07:11:01
【问题描述】:

我正在尝试使用 php 从本地主机发送电子邮件,但失败了 像这样的代码

<?php
$to= "fahmie.art98@gmail.com";
$subject = "this is test";
$messages= "this is message test, congrats, your success"

if( mail($to, $subject, $messages) ) {
echo "success guys";
}
else{
echo "failed guys";
};

?>

如何解决问题?我正在使用Linux。以及如何配置我的 XAMPP 以在 localhost 上发送电子邮件?

【问题讨论】:

标签: php linux email xampp localhost


【解决方案1】:

你可以配置C:\xampp\php\php.ini 和c:\xampp\sendmail\sendmail.ini 让gmail发送邮件。

在 C:\xampp\php\php.ini 中找到 extension=php_openssl.dll 并从该行的开头删除分号,以使 SSL 适用于本地主机的 gmail。

在php.ini文件中找到【邮件功能】并修改

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 中的所有现有代码替换为以下代码

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=your-gmail@gmail.com
auth_password=your-gmail-password
force_sender=your-mail-gmail-id@gmail.com

现在你已经完成了!输入您的 gmail 帐户

【讨论】:

  • 我用的是linux,send email的文件夹在哪里?
  • 绝对不能回答问题的错误答案。
猜你喜欢
  • 2016-05-13
  • 2018-03-08
  • 2014-08-28
  • 1970-01-01
  • 2015-08-11
  • 1970-01-01
  • 2012-05-07
  • 2018-03-13
  • 2012-01-27
相关资源
最近更新 更多