Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Capturing Email During Testing

by mcdave (Beadle)
on Jan 31, 2012 at 17:21 UTC ( [id://951021]=note: print w/replies, xml ) Need Help??


in reply to Capturing Email During Testing

About a different method for capturing email in a test framework... I've had great success (and fun) with "fakemail" http://www.lastcraft.com/fakemail.php. It sets up an SMTP server on localhost and anything that gets "mailed" to it ends up in a separate file in a directory of your choosing.

I just have the following two line in my code and I toggle the comment depending on whether I'm testing or not:

MIME::Lite->send( smtp => 'real.smtp.server.net' ) ; # MIME::Lite->send( smtp => 'localhost:10025' ) ;
If you can't toggle the comments, you can change the network. Add an entry in /etc/hosts (or whatever your equivalent is) so "real.smtp.server.net" resolves to localhost and use fakemail running on port 25.

Although that might just confirm: "There's more than one way to do it" doesn't always mean there's more than one way you should do it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://951021]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-24 09:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found