应用程序想要从本地主机发送电子邮件

发布于 2024-09-18 13:24:03 字数 264 浏览 12 评论 0原文

我正在开发一个php应用程序,需要测试发送电子邮件的功能。问题是我正在使用开发环境(Windows 上的 wamp),所以我猜我无法访问 smtp 或邮件服务器。

看起来我可能需要安装一个单独的应用程序来充当我的邮件服务器。最简单的方法是什么(我在 Windows 上工作 wamp),是否有另一种替代方案,例如供开发人员用于测试的公共服务器(请免费,因为我可能只会使用它 10 次,直到电子邮件功能已调整)。那么我想我的开发环境本身需要更改一些设置?任何人都可以阐明这一点。

谢谢

I'm developing a php application and need to test the functionality of sending emails. Problem is I'm using a development environment (wamp on windows) so I'm guessing I don't have access to smtp or a mail server.

It looks like I may need to install a separate application that would act as my mail server. What's the easiest way to do this (I'm on windows working on wamp), and is there another alternative like a public server to be used for testing by developers (free please because I'll probably use it just 10 times until the email functionality is tweaked). Then I guess there are settings that I need to change to my development environment itself? Anyone can shed some light on this please.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

路还长,别太狂 2024-09-25 13:24:03

XAMPP 附带 Mercury 处理电子邮件。如有必要,它可以通过 SSL 与 SMTP 服务器通信,并且对我来说效果很好。

XAMPP comes with Mercury to handle E-Mails. It can talk to SMTP servers through SSL if necessary, and works well for me.

却一份温柔 2024-09-25 13:24:03

您需要一个 SMTP 服务器。我使用 PostCast Server,它是免费的并且可以满足需要。

You need an SMTP Server. I use PostCast Server, which is free and does the needful.

☆獨立☆ 2024-09-25 13:24:03

您是否尝试过创建虚假的 GMail 帐户,然后通过其 SMTP 服务器发送电子邮件?这是例子 - 对我来说效果很好。

http://phpmailer.worxware.com/index.php?pg=exampleagmail

Have you tried creating fake GMail account and then sending emails through its SMTP server? Here is the example - for me works fine.

http://phpmailer.worxware.com/index.php?pg=exampleagmail

剩一世无双 2024-09-25 13:24:03

您是否尝试过 PHP 函数

mail($to, $subject, $body, $headers)

http://php.net/manual/en/function.mail .php

Have you tried PHP function

mail($to, $subject, $body, $headers)

http://php.net/manual/en/function.mail.php

咿呀咿呀哟 2024-09-25 13:24:03

XAMPP 附带了一个“假”sendmail 程序。如果您使用 XAMPP,则可以按如下方式使用 sendmail:(忽略“仅适用于 Unix”警告;它在 Windows 上工作正常)

[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 应该有一个 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

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

XAMPP comes with a "fake" sendmail program. If you use XAMPP, you can use sendmail as so: (ignore the "For Unix only" warning; it works fine on Windows)

[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.ini with it; it should be configured as so:

# 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文