Question

I want to test JavaMail locally, so I need a mail server. Are there any free mail servers I can use?

Was it helpful?

Solution

Sign up for a Gmail account and then use the settings there. See this page for more details:

http://mail.google.com/support/bin/answer.py?hl=en&answer=13287

That gives you an SMTP server.

OTHER TIPS

There is also very simple in use GreenMail which was designed as a mail server for automatic unit (self-integration?) tests.

From projects web page (maybe there are some others tools with that functionality nowadays):

GreenMail is an open source, intuitive and easy-to-use test suite of email servers for testing purposes. Supports SMTP, POP3, IMAP with SSL socket support. GreenMail also provides a JBoss GreenMail Service.

GreenMail is the fist and only library that offers a test framework for both receiving and retrieving emails from Java.

Have you looked at Apache James ? This is a Java mail server, which means you may be able to run it up temporarily as part of your unit test setup (and obviously take it down afterwards)

I'm after a 'real' test endpoint so will have a look at James, but could do with something a bit more lightweight.

Previously I have used 'Mock JavaMail' which you drop into your classpath and it works as an in-memory mail store for all accounts & message. https://mock-javamail.dev.java.net/

Does your ISP provide you a free mail service? One which only allows sending from one of their IPs?

Don't know what SMTP Auth support is like in JavaMail but you might be able to use gmail's smtp if you have an account.

I like "test mail server tool". It runs on your pc as a mailserver, writes emails out to a folder somewhere and you can set it to popup a window when an email comes in.

http://www.toolheap.com/test-mail-server-tool/

You can try JavaMail Mock2 https://github.com/salyh/javamail-mock2

Its primarily focused on IMAP/POP3 but SMTP Mock is also available. Its available in maven central.

Features

  • Support imap, imaps, pop3, pop3s, smtp, smtps
  • Supported for POP3: cast to POP3Folder, Folder.getUID(Message msg)
  • Supported for IMAP: cast to IMAPFolder, cast to UIDFolder, Subfolders, -Folder.getMessagesByUID(...), delete/rename folders, append messages
  • Support for SMTP: Mock Transport.send()
  • Unsupported for the moment: IMAP extensions like IDLE, CONDSTORE, ... and casts to POP3Message/IMAPMessage, store listeners
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top