title: Can't send mail using mail-service.xml of jboss 5.0 runtime server in spring MVC
body: <p>I am trying to send a mail using mail-service.xml.But I didn't get any exception from the code.But no message is send.I attach my code with this.I am using spring with hibernate.So I have serviceconfig xml file and servlet xml file .</p>
  
  <p>index.jsp</p>
  
  <pre><code>&lt;body&gt;
  &lt;h1&gt;Mail&lt;/h1&gt;
  &lt;form name="mailsend" method="post" action="mailsend.do" id="employeeCreation"&gt;
  &lt;input type="submit" name="mailbutton" value="SEND" id="mailbutton"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>servlet.xml</p>
  
  <pre><code>&lt;bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;
      &lt;property name="mappings"&gt;
      &lt;props&gt;
      &lt;prop key="mailsend.do"&gt;MailController&lt;/prop&gt;                   
      &lt;/props&gt;
      &lt;/property&gt;     
  &lt;/bean&gt;
  &lt;bean id="MailController" class="com.sample.web.MailController"&gt;
      &lt;property name="successView"&gt;&lt;value&gt;Home&lt;/value&gt;&lt;/property&gt;
      &lt;property name="failedView"&gt;&lt;value&gt;../../index&lt;/value&gt;&lt;/property&gt;       
      &lt;property name="mailservice" ref="mailservice"&gt;&lt;/property&gt;          
      &lt;property name="dao" ref="dao"&gt;&lt;/property&gt;
  &lt;/bean&gt;
      &lt;bean id="mailSender"
          class="org.springframework.mail.javamail.JavaMailSenderImpl"&gt;
             &lt;property name="session" ref="mailSession" &gt;&lt;/property&gt; 
    &lt;/bean&gt;
  &lt;bean id="contentMessage"
          class="org.springframework.mail.SimpleMailMessage"&gt;
       &lt;!--    &lt;property name="session" ref="mailSession" &gt;&lt;/property&gt; --&gt;
  &lt;/bean&gt;
  &lt;bean id="mailSession"
          class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
          &lt;property name="jndiName" value="java:/Mail" /&gt;
          &lt;property name="resourceRef" value="true"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>MailController.java</p>
  
  <pre><code>public class MailController extends AbstractController{
  private String successView;
  private String failedView;
  private DAO dao;
  private MailService mailservice;
  
  public String getSuccessView() {
      return successView;
  }
  
  public void setSuccessView(String successView) {
      this.successView = successView;
  }
  
  public String getFailedView() {
      return failedView;
  }
  
  public void setFailedView(String failedView) {
      this.failedView = failedView;
  }
  
  
  public MailService getmailservice() {
      return mailservice;
  }
  
  public void setmailservice(MailService mailservice) {
      this.mailservice = mailservice;
  }
  
  
  public DAO getDao() {
      return dao;
  }
  
  public void setDao(DAO dao) {
      this.dao = dao;
  }
  public ModelAndView handleRequestInternal(HttpServletRequest request,HttpServletResponse response) throws Exception
  {
             try{
              SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
              simpleMailMessage.setSubject("Mail testing ");
              simpleMailMessage.setText("Mail success");
              System.out.println("ENTER CONTROLLER");
              String message="Hai";
              String receiverMailId="*******@gmail.com";
              System.out.println("START SENDING");
              mailservice.sendMail(message,receiverMailId);
              System.out.println("Sending success:)");
              return (new ModelAndView(this.getSuccessView()));
             }catch(Exception e){
                 System.out.println("EXCEPTION");
                 e.printStackTrace();
                 return (new ModelAndView(this.getFailedView()));
             }
  
    }     
  }
  </code></pre>
  
  <p>MailService.java</p>
  
  <pre><code>public interface MailService {
  
  void sendMail(String message,String receiverMailId);
  
  }
  </code></pre>
  
  <p>MailServiceImpl.java</p>
  
  <pre><code>public class MailServiceImpl implements MailService {   
  private JavaMailSender  mailSender;
  public JavaMailSender getMailSender() {
      return mailSender;
  }
  public void setMailSender(JavaMailSender mailSender) {
      this.mailSender = mailSender;
  }
  
  private SimpleMailMessage contentMessage;
  
  
  public SimpleMailMessage getContentMessage() {
      return contentMessage;
  }
  public void setContentMessage(SimpleMailMessage contentMessage) {
      this.contentMessage = contentMessage;
  }
  
  @Override
  public void sendMail(String message, String receiverMailId) {
      try{            
      MimeMessage message1 = this.getMailSender().createMimeMessage();        
      }catch(Exception e){
          System.out.println("EXCEPTION IN IMPL  "+e);
          e.printStackTrace();
      }
  }
  }
  </code></pre>
  
  <p>serviceconf.xml</p>
  
  <pre><code>&lt;bean id="mailservice" parent="txProxyTemplate"&gt;
      &lt;property name="target"&gt;
          &lt;bean class="com.sample.service.impl.MailServiceImpl"&gt;
          &lt;property name="mailSender" ref="mailSender"&gt;&lt;/property&gt;             
          &lt;/bean&gt;
      &lt;/property&gt;
  &lt;/bean&gt;  
  </code></pre>
  
  <p>and in my mail-service.xml of jboss5.0 server </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!-- $Id: mail-service.xml 62350 2007-04-15 16:50:12Z dimitris@jboss.org $ --&gt;
  &lt;server&gt;
  &lt;!-- ======================================================== --&gt;
  &lt;!-- Mail Connection Factory                         --&gt;
  &lt;!-- ====================================================== --&gt;
  &lt;mbean code="org.jboss.mail.MailService"
       name="jboss:service=Mail"&gt;
  &lt;attribute name="JNDIName"&gt;java:/Mail&lt;/attribute&gt;
  &lt;attribute name="User"&gt;******@gmail.com&lt;/attribute&gt;
  &lt;attribute name="Password"&gt;*******&lt;/attribute&gt;
  &lt;attribute name="Configuration"&gt;
    &lt;!-- A test configuration --&gt;
    &lt;configuration&gt;
  &lt;property name="mail.smtp.auth" value="true"/&gt;
      &lt;property name="mail.smtp.starttls.enable" value="true"/&gt;
      &lt;property name="mail.smtp.socketFactory.class" value="javax.net.ssl.SSLSocketFactory"/&gt;
      &lt;!-- Change to your mail server prototocol --&gt;
      &lt;property name="mail.store.protocol" value="pop3"/&gt;
      &lt;property name="mail.transport.protocol" value="smtp"/&gt;
  
      &lt;!-- Change to the user who will receive mail  --&gt;
      &lt;property name="mail.user" value="nobody"/&gt;
  
      &lt;!-- Change to the mail server  --&gt;
      &lt;property name="mail.pop3.host" value="pop3.gmail.com"/&gt;
  
      &lt;!-- Change to the SMTP gateway server --&gt;
      &lt;property name="mail.smtp.host" value="smtp.gmail.com"/&gt;
  
      &lt;!-- The mail server port --&gt;
      &lt;property name="mail.smtp.port" value="465"/&gt;
  
      &lt;!-- Change to the address mail will be from  --&gt;
      &lt;property name="mail.from" value="******@gmail.com"/&gt;
  
      &lt;!-- Enable debugging output from the javamail classes --&gt;
      &lt;property name="mail.debug" value="false"/&gt;
    &lt;/configuration&gt;
  &lt;/attribute&gt;
  &lt;depends&gt;jboss:service=Naming&lt;/depends&gt;
  &lt;/mbean&gt;
  
  &lt;/server&gt;
  </code></pre>
  
  <p>The output of the result is:</p>
  
  <pre><code>ENTER CONTROLLER
  START SENDING
  Sending success:)
  </code></pre>
  
  <p>It doesn't show any exception.But the message was not send?What will do?Is there any mistake when connecting with mail-service.xml?Please anyone help me to solve the isssue...</p>
  
  <p>Thank you...</p>