如何配置 XAMPP 从 localhost 发送邮件?
我正在尝试从本地主机发送邮件.但我无法从本地主机发送邮件所以谁能告诉我如何重新配置我的 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,那么您可以轻松地从 localhost 发送邮件.
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.ini
和 c: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-id 和 my-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.
相关文章