Debug a Javamail Program

From CodeCodex



Set the Javamail DEBUG mode "on" :

Session mailSession = Session.getDefaultInstance(props, null);

This setting puts the Javamail classes in verbose mode to System.out. Verify connectivity to the MailServer with Telnet :

telnet mymailserver 25

for example, you can detect if your firewall is blocking your connection. Use a Javamail server mock-up to act as "in-memory" mail server : See and These mock-ups are designed to act a mail server but the actual email is not delivered to the mail recipient which can be useful in a testing stage.