在没有smtp服务器的开发机器上测试mail() [英] test mail() on development machine w/o smtp server

查看:154
本文介绍了在没有smtp服务器的开发机器上测试mail()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的开发机器(WinXP,Apache 2.2.4)没有smtp

服务器,如果我能提供帮助,我真的不想安装它。


有没有人知道一种简单的测试php脚本的方法,它通过模拟smtp服务器并将输出定向到文本文件来使用

mail()

或安装的文本编辑器。


现在我可以修改脚本使用的东西而不是mail(),

然后当我改变它投入生产,但我真的很想用b * b测试生产形式的脚本,而不必实际发送电子邮件。

Bill

解决方案

On Sun,2007年6月17日17:05:43 +0200,William Gill< no ***** @ gcgroup.net>

写道:


我的开发机器(WinXP,Apache 2.2.4)没有smtp

服务器,我不知道如果我能帮忙,我真的想安装一个。



不需要,只需使用你喜欢的任何SMTP服务器,它就像在UNIX上使用套接字一样工作

。本地,ISP,没关系。


有没有人知道一个简单的方法来测试使用

mail()的php脚本通过模拟smtp服务器并将输出定向到文本文件

或安装的文本编辑器。


现在我可以修改脚本来改用邮件(),

然后在我投入生产时更改它,但我真的想要

以生产形式测试脚本,无需实际发送电子邮件。



为什么要去模拟SMTP服务器呢?定义一个函数

my_mail(),让它在测试时登录到文件,让它在

生成上调用mail(),然后你就设置了。只需一点点改动(或者甚至可以使得函数行为取决于一些环境变量,所以它会自动选择正确的行为。

- -

Rik Wasmus


这有效,但后来我需要去取电子邮件(假设我在
$ b) $ b原始分发)并验证一切都如预期。如果我

可以模拟smtp服务器我可以检查格式和内容

无论它实际上是谁发送给。


比尔


Rik写道:


在Sun上, 2007年6月17日17:05:43 +0200,William Gill< no ***** @ gcgroup.net>

写道:


>我的开发机器(WinXP,Apache 2.2.4)没有smtp
服务器,如果我能提供帮助,我真的不想安装它。


不需要,只需使用任何SMTP服务呃,你喜欢,这不像在UNIX上用套接字工作

。本地,ISP,没关系。


>有没有人知道通过模拟测试使用
mail()的php脚本的简单方法一个smtp服务器并将输出定向到文本文件或安装的文本编辑器。

现在我可以修改脚本使用的东西而不是mail(),
然后我投入生产时更改它,但我真的想在生产表单中测试脚本,而不必实际发送电子邮件。



为什么要去模拟SMTP服务器呢?定义一个函数

my_mail(),让它在测试时登录到文件,让它在

生成上调用mail(),然后你就设置了。只需一点点改动(或者甚至可以使得函数行为取决于一些环境变量,所以它会自动选择正确的行为。

- -Rik Wasmus


On Sun,2007年6月17日18:58:34 +0200,William Gill< no ***** @ gcgroup.net> ;

写道:


这是有效的,但后来我需要去拉电子邮件(假设我在

原始发行版)并验证一切都符合预期。如果我可以模拟smtp服务器,我可以检查格式和内容

无论是谁实际发送到。



或者你可以覆盖''到''(CC / BCC)字段在你身上

my_mail() - 函数,所以它总是被发送给你,可能还有另一个标题/内容中的

原始电子邮件地址。

-

Rik Wasmus

My development machine (WinXP, Apache 2.2.4) does not have an smtp
server, and I don''t really want to install one if I can help it.

Does anyone know of a simple method of testing php scripts that employ
mail() by simulating an smtp server and directing output to a text file
or to an installed text editor.

Right now I can modify the script to use something instead of mail(),
then change it when I put into production, but I would really like to
test the script in its production form w/o having to actually send email.
Bill

解决方案

On Sun, 17 Jun 2007 17:05:43 +0200, William Gill <no*****@gcgroup.net>
wrote:

My development machine (WinXP, Apache 2.2.4) does not have an smtp
server, and I don''t really want to install one if I can help it.

Don''t need to, just use any SMTP server you like, it''s not like working
with sockets on UNIX. Local, ISP, doesn''t matter.

Does anyone know of a simple method of testing php scripts that employ
mail() by simulating an smtp server and directing output to a text file
or to an installed text editor.

Right now I can modify the script to use something instead of mail(),
then change it when I put into production, but I would really like to
test the script in its production form w/o having to actually send email.

Why go to the trouble of simulating an SMTP server? Define a function
my_mail(), let it log to a file while testing, let it call mail() on
production, and you''re set. Just one little change ( or pehaps even make
the function behaviour dependend on some enivronmental variables so it
automatically chooses the right action.
--
Rik Wasmus


That works, but then I need to go pull the email (assuming I was on the
original distribution) and verify everything was as expected. If I
could simulate the smtp server I could check the format and content
regardless of who it''s actually sent to.

Bill

Rik wrote:

On Sun, 17 Jun 2007 17:05:43 +0200, William Gill <no*****@gcgroup.net>
wrote:

>My development machine (WinXP, Apache 2.2.4) does not have an smtp
server, and I don''t really want to install one if I can help it.


Don''t need to, just use any SMTP server you like, it''s not like working
with sockets on UNIX. Local, ISP, doesn''t matter.

>Does anyone know of a simple method of testing php scripts that employ
mail() by simulating an smtp server and directing output to a text
file or to an installed text editor.

Right now I can modify the script to use something instead of mail(),
then change it when I put into production, but I would really like to
test the script in its production form w/o having to actually send email.


Why go to the trouble of simulating an SMTP server? Define a function
my_mail(), let it log to a file while testing, let it call mail() on
production, and you''re set. Just one little change ( or pehaps even make
the function behaviour dependend on some enivronmental variables so it
automatically chooses the right action.
--Rik Wasmus


On Sun, 17 Jun 2007 18:58:34 +0200, William Gill <no*****@gcgroup.net>
wrote:

That works, but then I need to go pull the email (assuming I was on the
original distribution) and verify everything was as expected. If I
could simulate the smtp server I could check the format and content
regardless of who it''s actually sent to.

Or you could ''override'' the ''to'' (CC/BCC) fields in you
my_mail()-function, so it''ll always be sent to you, possibly with the
original emailadresses in another header/in the content.
--
Rik Wasmus


这篇关于在没有smtp服务器的开发机器上测试mail()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆