title: Using Greenmail as a devlopment smtp server
body: <p>I am using greenmail as development Mail server. My use case is to 1) send an email on the mail server and 2) another process will keep looking that mail server using IMAP and notify if there is any new email.</p>
  
  <p>To achieve first step 1) send an email 
  I set up the smtp server using below command of Greenmail</p>
  
  <pre><code>java -Dgreenmail.setup.test.all -Dgreenmail.users=test1:pwd1,test2:pwd2@example.com \
       -jar greenmail-standalone.jar
  </code></pre>
  
  <p>Now when I used normal API of java to send an email using SMTP. It says that the email send successfully but I am not receiving any email on the "to" address where I sent an email. Below is the source code to send email</p>
  
  <pre><code>public static void main(String [] args) {    
        // Recipient's email ID needs to be mentioned.
        String to = "abcd@gmail.com";
  
        // Sender's email ID needs to be mentioned
        String from = "web@gmail.com";
  
        // Assuming you are sending email from localhost
        String host = "localhost";
  
        // Get system properties
        Properties properties=new Properties();
  
        // Setup mail server
        properties.setProperty("mail.smtp.host", host);
        props.put("mail.smtp.port", "3025"); //TLS Port
         props.put("mail.smtp.auth", "true"); //enable authentication
         props.put("mail.smtp.starttls.enable", "true");
  
        // Get the default Session object.
        Authenticator auth = new Authenticator() {
          //override the getPasswordAuthentication method
          protected PasswordAuthentication getPasswordAuthentication() {
              return new PasswordAuthentication(fromEmail, password);
          }
      };
  Session session = Session.getInstance(props, auth);
  
        try {
           // Create a default MimeMessage object.
           MimeMessage message = new MimeMessage(session);
  
           // Set From: header field of the header.
           message.setFrom(new InternetAddress(from));
  
           // Set To: header field of the header.
           message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
  
           // Set Subject: header field
           message.setSubject("This is the Subject Line!");
  
           // Now set the actual message
           message.setText("This is actual message");
  
           // Send message
           Transport.send(message);
           System.out.println("Sent message successfully....");
        }catch (MessagingException mex) {
           mex.printStackTrace();
        }
     }
  </code></pre>
  
  <p>Could you please help me in finding out what I am doing wrong?
  1) Can we really send an email using greenmail?</p>
  
  <p>This is my Debug output</p>
  
  <pre><code>DEBUG: JavaMail version 1.4.7
  DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
  DEBUG: Tables of loaded providers
  DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle]}
  DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]}
  DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
  DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
  DEBUG SMTP: useEhlo true, useAuth true
  DEBUG SMTP: useEhlo true, useAuth true
  DEBUG SMTP: trying to connect to host "localhost", port 3025, isSSL false
  220 /127.0.0.1 GreenMail SMTP Service v1.6.0-SNAPSHOT ready
  DEBUG SMTP: connected to host "localhost", port: 3025
  
  EHLO 127.0.0.1
  250 /127.0.0.1
  DEBUG SMTP: use8bit false
  MAIL FROM:&lt;test1@localhost&gt;
  250 OK
  RCPT TO:&lt;abcd@gmail.com&gt;
  250 OK
  DEBUG SMTP: Verified Addresses
  DEBUG SMTP:   abcd@gmail.com
  DATA
  354 Start mail input; end with &lt;CRLF&gt;.&lt;CRLF&gt;
  From: test1@localhost
  To: abcd@gmail.com
  Message-ID: &lt;1296064247.0.1509389569017.JavaMail.s0065311@IRV-DU10507&gt;
  Subject: Email From my Greenmail
  MIME-Version: 1.0
  Content-Type: text/plain; charset=us-ascii
  Content-Transfer-Encoding: 7bit
  
  Test Mail sent from My Greenmail!!
  .
  250 OK
  QUIT
  221 /127.0.0.1 Service closing transmission channel
  Email sent successfully from greenmail
  </code></pre>
  
  <p>Though it says everything is OK and status is 250 OK, i didn't receive the email.</p>
  
  <p>Regards
  Maulik</p>