如何在本地 XAMPP 中设置邮件?
我正在学习 PHP,并在我的计算机上安装了 XAMPP。
但我的设置有问题,因为电子邮件选项似乎不起作用。
阅读完一些内容后,我认为这与以下内容有关,在我的服务器上的 php.ini 文件中找到了
[mail function]
; For Win32 only.
; *hp://*php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost
我需要更改的内容吗?我见过提到的 swiftmailer 之类的软件,但我不知道 XAMPP 是否已经包含了这个?
I'm learning PHP and have installed XAMPP on my computer.
But I have a problem with the setup as the email option doesn't seem to be working.
After doing some reading I think it has something to do with the below, found on my server in the php.ini file
[mail function]
; For Win32 only.
; *hp://*php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost
Is there anything I need to change? I have seen software such as swiftmailer mentioned but I don't know if XAMPP has this included already?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我最喜欢的 smtp 服务器是 hMailServer。
它有一个很好的 Windows 友好安装程序和向导。这是我设置过的最简单的邮件服务器。
它可以通过您的 gmail/yahoo/etc 帐户代理或直接发送电子邮件。
安装后,xampp 中的电子邮件即可正常使用,无需更改配置。
My favorite smtp server is hMailServer.
It has a nice windows friendly installer and wizard. Hands down the easiest mail server I've ever setup.
It can proxy through your gmail/yahoo/etc account or send email directly.
Once it is installed, email in xampp just works with no config changes.
XAMPP 应该带有一个“假”sendmail 程序。在这种情况下,您也可以使用 sendmail:
Sendmail 应该有一个
sendmail.ini
;应该这样配置:当然,将 ACCOUNTNAME_HERE 替换为任意帐户名称,将 EMAIL_HERE 替换为有效的电子邮件(例如 Gmail 或 Hotmail),并将 PASSWORD_HERE 替换为您的电子邮件的密码。现在,您应该能够发送邮件了。请记住重新启动 Apache(从控制面板或批处理文件)以使对 PHP 的更改生效。
XAMPP should have come with a "fake" sendmail program. In that case, you can use sendmail as well:
Sendmail should have a
sendmail.ini
with it; it should be configured as so:Of course, replace ACCOUNTNAME_HERE with an arbitrary account name, replace EMAIL_HERE with a valid email (such as a Gmail or Hotmail), and replace PASSWORD_HERE with the password to your email. Now, you should be able to send mail. Remember to restart Apache (from the control panel or the batch files) to allow the changes to PHP to work.
除非您在本地计算机上设置了邮件服务器,否则设置 SMTP = localhost 将不会产生任何效果。
在过去(很久以前),将 SMTP 的值设置为 ISP 的 SMTP 服务器的地址就足够了。现在这种方法很少起作用,因为大多数 ISP 坚持使用用户名和密码进行身份验证。但是,PHP mail() 函数不支持 SMTP 身份验证。它被设计为直接与本地服务器的邮件传输代理一起工作。
您需要设置本地邮件服务器或使用支持 SMTP 身份验证的 PHP 类,例如 Zend_Mail 或 PHPMailer。然而,最简单的解决方案是将邮件处理脚本上传到远程服务器。
Unless you have a mail server set up on your local computer, setting SMTP = localhost won't have any effect.
In days gone by (long ago), it was sufficient to set the value of SMTP to the address of your ISP's SMTP server. This now rarely works because most ISPs insist on authentication with a username and password. However, the PHP mail() function doesn't support SMTP authentication. It's designed to work directly with the mail transport agent of the local server.
You either need to set up a local mail server or to use a PHP classs that supports SMTP authentication, such as Zend_Mail or PHPMailer. The simplest solution, however, is to upload your mail processing script to your remote server.