我使用spring SimpleMailMessage,每当我尝试发送邮件功能时,我都会得到这个异常:
java.lang.IllegalArgumentException: The 'original' message argument cannot be null
我的 spring.xml
<bean id="MailSender" class="com.util.MailSender">
<property name="mailSender" ref="mailSender"/>
<property name="templateMessage" ref="templateMessage"/>
</bean>
邮件发件人类:
private MailSender mailSender;
private SimpleMailMessage templateMessage;
//getter and setter
public void sendMail(String content, List<String> listEmail){
SimpleMailMessage[] mailMessageArray = new SimpleMailMessage[listEmail.size()];
Iterator<String> iterator = listEmail.iterator();
for (int index = 0; iterator.hasNext(); index ++){
SimpleMailMessage message = new SimpleMailMessage(this.templateMessage);
String toAddress = iterator.next();
message.setTo(toAddress);
message.setText(content);
mailMessageArray[index] = message;
}
this.mailSender.send(mailMessageArray);
}
动作豆类:
private MailSender mailSender=new MailSender();
public void ReSend(){
mailSender.sendMail(listBEeans[i].getEmailContent(),listEmail);
//able to pass the content and listEmails correctly
}
我错过了动作 bean 中的任何配置吗?谢谢