- 论坛徽章:
- 0
|
我写了一个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 |
|