0

I need an mail server in java that can handle incoming and outgoing mails (POP3- IMAP- SMTP protocols).

I thought about trying to use mock-javamail.

I downloaded the:

svn co https://svn.java.net/svn/mock-javamail~svn

I want to import the project in eclipse and start configure it and test it.

I didn't find any informations about how to build this project in order to open it in eclipse. I don't know anything about the license. Can someone please help?

I already have the smtp-pop3-imap clients done using JavaMail api.

Now I need to implement a mail server in java that can handle incoming - outgoing emails.

Kevin
  • 53,822
  • 15
  • 101
  • 132
just ME
  • 1,817
  • 6
  • 32
  • 53
  • it is a maven project, just copy the src and .pom file, install [Maven Eclipse Plugin](http://maven.apache.org/plugins/maven-eclipse-plugin/) and you are good to go. A previous post http://stackoverflow.com/questions/2061094/importing-maven-project-into-eclipse also talks about that. – AurA Apr 03 '13 at 12:41
  • Thank you. I managed to import the project in eclipse, but when I run the project i get an error saying there is no main.::| – just ME Apr 03 '13 at 12:52
  • these is no main method in projects, you need to write your own main method or execute their test suite. – AurA Apr 03 '13 at 12:59
  • can you help me with an example of a main method? I need to enable smtp and both imap and pop3 protocols. Thank you!:) – just ME Apr 03 '13 at 13:18

2 Answers2

5

Have a look at JavaMail Mock2 https://github.com/salyh/javamail-mock2 ,this is designed for doing unittests with JavaMail and does not need a real system.

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

To download and import in eclipse install maven and git and type:

  • git clone https://github.com/salyh/javamail-mock2.git
  • cd javamail-mock2
  • mvn eclipse:eclipse
  • Then import as an existing project in eclipse
salyh
  • 2,095
  • 1
  • 17
  • 31
0

Here is a simple way you can test the mail api.

import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

public class MyMailSender {

    public void sendMail(String to, String from, String subject, String msg) throws EmailException {
       Email email = new SimpleEmail();
       email.addTo(to);
       email.setFrom(from);
       email.setSubject(subject);   
       email.setMsg(msg);
       email.setHostName("testmail.com");   
       email.send();  
    }

}
AurA
  • 12,135
  • 7
  • 46
  • 63