php xampp中的php邮件设置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4652566/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 13:52:07  来源:igfitidea点击:

php mail setup in xampp

phpemailinstallationxampp

提问by James

I'm learning PHP and have installed Xampp on my computer.

我正在学习 PHP 并在我的计算机上安装了 Xampp。

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

在做了一些阅读之后,我认为它与以下内容有关,在我的服务器上的 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   

[Please note I have changed above hp://from http:// because of a restriction on this website to post a hyperlink]

[请注意,由于本网站限制发布超链接,我已将上面的hp://更改为 http://]

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? Any tips would be greatly appreciated!

有什么我需要改变的吗?我见过提到的诸如 swiftmailer 之类的软件,但我不知道 Xampp 是否已经包含这个?任何提示将非常感谢!

Thanks James

谢谢詹姆斯

回答by Byron Whitlock

My favorite smtp server is hMailServer.

我最喜欢的 smtp 服务器是hMailServer

It has a nice windows friendly installer and wizard. Hands down the easiest mail server I've ever setup.

它有一个很好的 Windows 友好的安装程序和向导。放下我设置过的最简单的邮件服务器。

It can proxy through your gmail/yahoo/etc account or send email directly.

它可以通过您的 gmail/yahoo/etc 帐户进行代理或直接发送电子邮件。

Once it is installed, email in xampp just works with no config changes.

安装后,xampp 中的电子邮件无需更改配置即可使用。

回答by kevinji

XAMPP should have come with a "fake" sendmail program. In that case, you can use sendmail as well:

XAMPP 应该带有一个“假的”sendmail 程序。在这种情况下,您也可以使用 sendmail:

[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
; http://php.net/smtp-port
;smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = [email protected]

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "C:/xampp/sendmail/sendmail.exe -t -i"

Sendmail should have a sendmail.iniwith it; it should be configured as so:

Sendmail 应该有一个sendmail.ini;它应该这样配置:

# Example for a user configuration file

# Set default values for all following accounts.
defaults
logfile "C:\xampp\sendmail\sendmail.log"

# Mercury
#account Mercury
#host localhost
#from postmaster@localhost
#auth off

# A freemail service example
account ACCOUNTNAME_HERE
tls on
tls_certcheck off
host smtp.gmail.com
from EMAIL_HERE
auth on
user EMAIL_HERE
password PASSWORD_HERE

# Set a default account
account default : ACCOUNTNAME_HERE

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.

当然,将 ACCOUNTNAME_HERE 替换为任意帐户名,将 EMAIL_HERE 替换为有效的电子邮件(例如 Gmail 或 Hotmail),并将 PASSWORD_HERE 替换为您电子邮件的密码。现在,您应该可以发送邮件了。请记住重新启动 Apache(从控制面板或批处理文件)以允许对 PHP 的更改生效。

回答by David Powers

Unless you have a mail server set up on your local computer, setting SMTP = localhost won't have any effect.

除非您在本地计算机上设置了邮件服务器,否则设置 SMTP = localhost 不会产生任何影响。

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.

在过去(很久以前),将 SMTP 的值设置为 ISP 的 SMTP 服务器的地址就足够了。这现在很少起作用,因为大多数 ISP 坚持使用用户名和密码进行身份验证。但是,PHP mail() 函数不支持 SMTP 身份验证。它旨在直接与本地服务器的邮件传输代理一起工作。

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.

您需要设置本地邮件服务器或使用支持 SMTP 身份验证的 PHP 类,例如 Zend_Mail 或 PHPMailer。然而,最简单的解决方案是将您的邮件处理脚本上传到您的远程服务器。