473,761 Members | 9,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

test mail() on development machine w/o smtp server

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
Jun 17 '07 #1
17 3795
Rik
On Sun, 17 Jun 2007 17:05:43 +0200, William Gill <no*****@gcgrou p.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
Jun 17 '07 #2
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*****@gcgrou p.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
Jun 17 '07 #3
Rik
On Sun, 17 Jun 2007 18:58:34 +0200, William Gill <no*****@gcgrou p.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
Jun 17 '07 #4
William Gill 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.

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.

I have the following in my php.ini

sendmail_path = php -r
"file_put_conte nts('c:/mail.log',file_ get_contents('p hp://stdin'),FILE_AP PEND);"

this logs all emails sent via mail() to c:\mail.log
--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
Jun 17 '07 #5
That's a thought! It still means going to mail to see the result, but
using IMAP I could leave that window open while I test.

I just have to remember to always use the my_mail() wrapper instead of
mail().

Thanks,

Bill
Rik wrote:
On Sun, 17 Jun 2007 18:58:34 +0200, William Gill <no*****@gcgrou p.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 te 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
Jun 17 '07 #6
..oO(gosha bine)
>William Gill wrote:
>>
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.

I have the following in my php.ini

sendmail_pat h = php -r
"file_put_cont ents('c:/mail.log',file_ get_contents('p hp://stdin'),FILE_AP PEND);"

this logs all emails sent via mail() to c:\mail.log
Nice idea ...

Micha
Jun 17 '07 #7
Looks good, but it causes a parsing error on WinXP. I may use it on my
Linux boxes though.

Bill

gosha bine wrote:
William Gill 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.

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.


I have the following in my php.ini

sendmail_path = php -r
"file_put_conte nts('c:/mail.log',file_ get_contents('p hp://stdin'),FILE_AP PEND);"
this logs all emails sent via mail() to c:\mail.log

Jun 17 '07 #8
William Gill wrote:
Looks good, but it causes a parsing error on WinXP. I may use it on my
Linux boxes though.
Works just fine for me. Make sure you've copied it properly.
Also, please do not top-post. Post your replies below the quoted text.

>
Bill

gosha bine wrote:
>William Gill 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.

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.


I have the following in my php.ini

sendmail_pat h = php -r
"file_put_cont ents('c:/mail.log',file_ get_contents('p hp://stdin'),FILE_AP PEND);"
this logs all emails sent via mail() to c:\mail.log


--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
Jun 17 '07 #9

gosha bine wrote:
William Gill wrote:
>Looks good, but it causes a parsing error on WinXP. I may use it on
my Linux boxes though.

Works just fine for me. Make sure you've copied it properly.
Fixing the cut and paste error, and commenting out the "SMTP =" and
'smtp_port =' entries fixed the parse error. Now Xp is complaining
about php not being a recognized command when it's called from inside
Apache.

I'll keep fiddling with it.
Also, please do not top-post. Post your replies below the quoted text.
Mea culpa.
>
>>
Bill

gosha bine wrote:
>>William Gill 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.

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.
I have the following in my php.ini

sendmail_pa th = php -r
"file_put_con tents('c:/mail.log',file_ get_contents('p hp://stdin'),FILE_AP PEND);"
this logs all emails sent via mail() to c:\mail.log


Jun 18 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2256
by: Karuna | last post by:
Hi everybody, I have been trying to write a simple mail script using PHP and apache on Windows XP. Eventhough the script is saying that the mail is successfully sent, I am unable get it in my mailbox(I have given my mail address in $to). I am using the mail() function and I have made the following changes in php.ini ; For Win32 only. SMTP = localhost
2
1222
by: \Crash\ Dummy | last post by:
I would like to use a form on my web site to e-mail user comments to me. I have ASP capability to run server side scripts. The host domain has a SMTP server, but I don't know if it is on the same machine as the HTTP server. A simple reference with lots of pictures and sample scripts would be much appreciated. I was referred to this page in another newsgroup http://www.aspfaq.com/show.asp?id=2026 and I have a question about a line of code...
4
19876
by: Gerhard | last post by:
Hi, I some asp.net beta 2 code that works fine on an XP Pro machine, but on a Windows 2003 Server gets the following error: System.Net.Mail.SmtpFailedRecipientException {"Mailbox unavailable. The server response was: 5.7.1 <veachb@quixnet.net>... Relaying denied. IP name possibly forged "} System.Net.Mail.SmtpFailedRecipientException
1
2184
by: Robert V. Hanson | last post by:
Please give me some ideas on how to setup the ability to test System.Web.Mail code to send emails using just my development computer, Win2000Pro OS and IIS5.0? Thanks, Bob Hanson
5
2141
by: Pascal Cloup | last post by:
Hello, I just want to send an e-mail from my windows form application without specifying SmtpServer. On my computer, when i specify my smtpserver, SmtpMail.Send( aMail ) works fine, but without specifuing SmtpMail.SmtpServer, the message is never sent.. I tried various things like SmtpMail.SmtpServer = "" or SmtpMail.SmtpServer = "localhost" or SmtpMail.SmtpServer.Insert"0,"localhost""), ... the result was the same
1
1160
by: Tiabes | last post by:
Hi, I am using System.Web.Mail for a email feature in an Intranet Application (ASP.NET). I need to use NTLM Authentication: ms.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "2") All work fine in my development machine, but when I run this application from another client machine (my development machine is the "web server") it generates the following error:
3
5473
by: Ing. Davide Piras | last post by:
Hi there, I use Visual Studio 2005, c# projects... I like the new unit test framework very much, it helps a lot mantaining and growing up a project with the test driven paradigm, that's so good! I'm looking for a way to detect if the program is running under the TEST enviroment or running normally, let's say I need something like #if TESTING
9
2323
by: Homer | last post by:
Hi, I've posted this question before but didn't get anywhere with it. Please help me out if you know of a solution for it. I got "InnerException: Unable to connect to remote server"..."No connection could be made because the target machine actively refused it" when I attempted to send an email through my Intranet app that is written in asp.net 2.0. The smtp server is a local server and it uses Port 25. The Authentication is set to...
4
1756
by: =?Utf-8?B?UmljaA==?= | last post by:
I want to build an simple email smtp client app similar to outlook except with some custom features for a personal computer that uses comcast cable. The owner of the computer said she doesn't have a comcast email and uses gmail instead, but the internet service provider is comcast. This computer also does not have MS Office loaded - otherwise I would open Outlook and see what mail server it is using. On my development machine at my...
0
9531
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10115
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7332
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3881
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3456
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.