如何配置 XAMPP 从本地主机发送邮件? [英] How to configure XAMPP to send mail from localhost?

查看:30
本文介绍了如何配置 XAMPP 从本地主机发送邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从本地主机发送邮件.但我无法从本地主机发送邮件那么谁能告诉我如何重新配置​​我的 xampp 以从本地主机发送邮件

I am trying to send mail from localhost. but i am unable to send the mail from localhost so can anybody tell me that how to reconfigure my xampp to send mail from localhost

推荐答案

你可以使用 sendmail 包从 localhost 发送邮件,sendmail 包内置在 XAMPP 中.因此,如果您使用的是 XAMPP,那么您可以轻松地从本地主机发送邮件.

You can send mail from localhost with sendmail package , sendmail package is inbuild in XAMPP. So if you are using XAMPP then you can easily send mail from localhost.

例如你可以配置C:xamppphpphp.inic:xamppsendmailsendmail.ini让gmail发送邮件.

for example you can configure C:xamppphpphp.ini and c:xamppsendmailsendmail.ini for gmail to send mail.

C:xamppphpphp.ini 中找到 extension=php_openssl.dll 并删除该行开头的分号以使 SSL 可用于 gmail对于本地主机.

in C:xamppphpphp.ini find extension=php_openssl.dll and remove the semicolon from the beginning of that line to make SSL working for gmail for localhost.

在php.ini文件中找到[mail function]并修改

in php.ini file find [mail function] and change

SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my-gmail-id@gmail.com
sendmail_path = ""C:xamppsendmailsendmail.exe" -t"

现在打开C:xamppsendmailsendmail.ini.将 sendmail.ini 中现有的所有代码替换为以下代码

Now Open C:xamppsendmailsendmail.ini. Replace all the existing code in sendmail.ini with following code

[sendmail]

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

现在你已经完成了!!创建带有邮件功能的php文件并从本地主机发送邮件.

Now you have done!! create php file with mail function and send mail from localhost.

PS:不要忘记替换上面代码中的my-gmail-idmy-gmail-password.另外,如果您从上面复制了设置,请不要忘记删除重复的键.例如,如果 php.ini 文件中还有另一个 sendmail_path ,请注释以下行:sendmail_path="C:xamppmailtodiskmailtodisk.exe"

PS: don't forgot to replace my-gmail-id and my-gmail-password in above code. Also, don't forget to remove duplicate keys if you copied settings from above. For example comment following line if there is another sendmail_path : sendmail_path="C:xamppmailtodiskmailtodisk.exe" in the php.ini file

还要记住使用 XAMMP 控制面板重新启动服务器,以使更改生效.

Also remember to restart the server using the XAMMP control panel so the changes take effect.

对于 Gmail,请查看 https://support.google.com/accounts/answer/6010255 允许从不太安全的应用程序访问.

For gmail please check https://support.google.com/accounts/answer/6010255 to allow access from less secure apps.

在 Linux 上通过 Gmail 发送电子邮件(使用 sendmail 包)从本地主机请检查 PHP+Ubuntu 使用 gmail 表单发送电子邮件本地主机.

To send email on Linux (with sendmail package) through Gmail from localhost please check PHP+Ubuntu Send email using gmail form localhost.

这篇关于如何配置 XAMPP 从本地主机发送邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆