When developing applications that send out e-mails, it helps to run a local e-mail server. Java Email Server is a simple SMTP server perfect for unit testing.
Download and extract the ZIP file somewhere, say C:\Program Files\JES.
Open the file bin/ntservice.bat using Notepad. Set the JES_HOME_DIR variable to the root of the install folder.
Set JDK_HOME_DIR to the root of Java. Note: You must point to a JDK directory and not a JRE.
If you are using IBM JDK, set the JDK_MODE to classic.
From the bin directory of JES, run this command to install the service:
Open Services control panel applet. Start JavaMailServer service to start the SMTP server.
Open mail.conf from the root folder. Set the local domain name:
Any e-mail sent to the local domain will be saved by this e-mail server (and will not be forwarded to the actual SMTP server of the domain). For example, if we set this to webagesolutions.com then e-mails sent to any address with @localhost domain will be considered local to this server and it will be saved right there. This is great because, you don’t want to send test e-mails to actual users. That will only confuse the recipients.
Set the default user’s e-mail:
This comes very handy during development. You can send e-mails to any user with @localhost domain. All e-mails will be deposited to the default user’s box. This way, you can configure only one POP3 account in your mail program for the default user and pull out all e-mails using that.
Save and close mail.conf.
Open users.conf. Here, add the default user. The format is user.<username@domain>=<plain text password>. So, to add a user called "admin" with password "pass", do:
Restart the service.
Note: E-mails sent to non-local domain will be relayed by JES. Many ISPs block SMTP protocol to prevent spamming. For example, I can’t send e-mail to Gmail’s SMTP server without using my ISP’s SMTP server. Relaying might be hard to achieve. But, mails to local domain is guaranteed to work.
Configure Mail Reader
In your mail reader, configure POP3 as follows:
User ID: admin@localhost. You must enter the full domain name.
For SMTP server, enter localhost as the hostname.
Now, you will be to send e-mail to any user of the local domain. You can pick up all of those e-mails from the single POP3 user account.