如何配置XAMPP从本地主机发送邮件? [英] How to configure XAMPP to send mail from localhost?
问题描述
我正在尝试从本地主机发送邮件. 但我无法从本地主机发送邮件 所以有人能告诉我如何重新配置我的xampp以从localhost发送邮件
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.
例如,您可以为gmail配置C:\xampp\php\php.ini
和c:\xampp\sendmail\sendmail.ini
以发送邮件.
for example you can configure C:\xampp\php\php.ini
and c:\xampp\sendmail\sendmail.ini
for gmail to send mail.
找到extension=php_openssl.dll
并从该行的开头删除分号,以使SSL适用于localhost的gmail.
in C:\xampp\php\php.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:\xampp\sendmail\sendmail.exe\" -t"
现在打开C:\xampp\sendmail\sendmail.ini
.用以下代码替换sendmail.ini中所有现有的代码
Now Open C:\xampp\sendmail\sendmail.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-id 和 my-gmail-password .
另外,如果您从上方复制设置,请不要忘记删除重复的键.例如,如果在php.ini文件中还有另一个 sendmail_path :sendmail_path="C:\xampp\mailtodisk\mailtodisk.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:\xampp\mailtodisk\mailtodisk.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通过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屋!