免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1066 | 回复: 0
打印 上一主题 下一主题

spring定时发送邮件 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-09-30 22:20 |只看该作者 |倒序浏览
我写了一个spring定时发送邮件的程序,服务器启动完以后,系统没有出错,可是邮件却没有发送出去,不知道是不是任务调度没有启动,请各位高手指点一下,以下是applicationContext.xml、web.xml、MailService类。   
  applicationContext.xml文件:   
     
     
   
     
   
     
     
                     
                             
                     
                     
                     
                             
                                  true   
                             
                     
            
            
            
                     
                     
                     
            
                     
            
                     
                     
            
                  
            
                     
                           
                     
            
                  
            
                     
                       
            
            
                     
                             
                                    
                             
                     
            
   
   
     
   
   
   
   
   
   
   
   
  web.xml文件:   
     
     
         
      contextConfigLocation   
      /WEB-INF/applicationContext.xml   
         
         
          action   
          org.apache.struts.action.ActionServlet   
            
              config   
              /WEB-INF/struts-config.xml   
            
            
              debug   
              3   
            
            
              detail   
              3   
            
          0   
         
         
           
  context     
  org.springframework.web.context.ContextLoaderServlet     
  1     
         
         
          action   
          *.do   
         
         
                  org.springframework.web.context.ContextLoaderListener   
         
     
   
   
   
   
   
   
   
   
   
   
  MailService类:   
  package   facade;   
  import   org.springframework.mail.MailException;   
  import   org.springframework.mail.MailSender;   
  import   org.springframework.mail.SimpleMailMessage;   
   
  public   class   MailService     
  {   
          private   MailSender   mailSender;   
          private   SimpleMailMessage   mailMessage;//邮件模板   
          public   void   sendMail()   {   
                  System.out.println("-----------发送邮件!---------");   
                  SimpleMailMessage   msg=new   SimpleMailMessage(this.mailMessage);   
                  msg.setText("this   is   a   test   mail");   
                  try   {   
                          mailSender.send(msg);   
                  }   catch   (MailException   e)   {   
                          e.printStackTrace();   
                  }   
                  System.out.println("-----------发送成功!---------");   
          }   
            //省略set,get方法   
  }

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/36006/showart_393245.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP