title: Configure Email in JBoss - JNDI Resouce not getting correct configuration
body: <p>I am trying to configure my application to send emails in JBoss 7.10.GA.  Everything looks to be configured properly but when I test my code it throw an error:</p>
  
  <p>javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;</p>
  
  <p>It appears that it is not finding the correct email configuration in my standalone.xml file because it just defaults to localhost port 25.  From all the forms I have read this is all the configuration that needs to be done but I must be missing something.</p>
  
  <pre><code>  &lt;subsystem xmlns="urn:jboss:domain:mail:1.1"&gt;
          &lt;mail-session jndi-name="java:jboss/mail/Gmail"&gt;
              &lt;smtp-server ssl="true" outbound-socket-binding-ref="mail-gmail-smtp"&gt;
                  &lt;login name="email@gmail.com" password="password"/&gt;
              &lt;/smtp-server&gt;
          &lt;/mail-session&gt;
      &lt;/subsystem&gt;
    &lt;socket-binding-group...
        &lt;outbound-socket-binding name="mail-gmail-smtp"&gt;
            &lt;remote-destination host="smtp.gmail.com" port="465"/&gt;
        &lt;/outbound-socket-binding&gt;
    &lt;/socket-binding-group&gt;
  </code></pre>
  
  <p>and I have this in my class:</p>
  
  <pre><code>import javax.annotation.Resource;
  import javax.mail.Address;
  import javax.mail.Message;
  import javax.mail.Session;
  import javax.mail.Transport;
  import javax.mail.internet.InternetAddress;
  import javax.mail.internet.MimeMessage;
  import javax.servlet.http.HttpServlet;
  
  public class SendEmail extends HttpServlet {       
      @Resource(lookup = "java:jboss/mail/Gmail")
      private Session mailSession;
  
      public SendEmail() {
          try {
              MimeMessage m = new MimeMessage(mailSession);
              Address from = new InternetAddress("email@gmail.com");
              Address[] to = new InternetAddress[] { new InternetAddress(
                  "email@gmail.com") };
              m.setFrom(from);
              m.setRecipients(Message.RecipientType.TO, to);
              m.setSubject("Google JavaMail Test");
              m.setContent("Test from inside JBoss AS7 Server", "text/plain");
              Transport.send(m);           
          } catch (javax.mail.MessagingException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>