title: Apache commons mail Exception..Recipient address rejected: User unknown in virtual alias table
body: <p>I have two emails of my own domain. One is configured in the domain and other is configured in <code>gmail</code> (admin.google.com).</p>
  
  <h2>My code</h2>
  
  <pre><code>    HtmlEmail htmlEmail = new HtmlEmail();
      htmlEmail.setHostName("mydomain.com");
      htmlEmail.setSmtpPort(587);
      htmlEmail.setAuthenticator(new DefaultAuthenticator(
              "enquiry@mydomain.com", "password"));
  
  
          htmlEmail.setFrom("enquiry@mydomain.com", " Enquiry");
          htmlEmail.setSubject("New Enquiry");
          htmlEmail.setHtmlMsg("My message");
          htmlEmail.addTo("info@mydomain.com");
  
          htmlEmail.send();
  </code></pre>
  
  <p>When I send mail from the domain configured email(enquiry@mydomain.com) to gmail configured email(info@mydomain.com) it shows the following error:</p>
  
  <blockquote>
    <p>org.apache.commons.mail.EmailException: Sending the email to the
    following server failed : mydomain.com:587<br>
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1421)<br>
    at org.apache.commons.mail.Email.send(Email.java:1448)<br>
    at com.myproject.test.HomeController.sendEmail(HomeController.java:153)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)<br>
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)<br>
    at java.lang.reflect.Method.invoke(Unknown Source)<br>
    at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
      at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
      at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)<br>
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)<br>
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
      at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
      at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
      at
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
      at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
      at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      at
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
      at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
      at
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
      at
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1086)
      at
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:659)
      at
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:147)
      at
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:279)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Unknown Source) Caused by:
    javax.mail.SendFailedException: Invalid Addresses;   nested exception
    is:   com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1
    : Recipient address rejected: User unknown in
    virtual alias table   at
    com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1949)   at
    com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1195)
      at javax.mail.Transport.send0(Transport.java:254)   at
    javax.mail.Transport.send(Transport.java:124)     at
    org.apache.commons.mail.Email.sendMimeMessage(Email.java:1411)    ... 39
    more Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550
    5.1.1 : Recipient address rejected: User unknown in virtual alias table    at
    com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1802)</p>
  </blockquote>