Reputation:
I read all related topics, but in all of them there was this line:
mailSender.send(message);
http://www.mkyong.com/spring/spring-sending-e-mail-via-gmail-smtp-server-with-mailsender/
But there is no send()
at all, i see mailSender.sendMail()
method with this arguments:
String s, String[] string,String[] string1,String[] string2,String s1,String s2
Here is my code:
public class Mail {
private MailSender mailSender;
public void setMailSender(MailSender mailSender) {
this.mailSender = mailSender;
}
public void sendMail(String from, String to, String subject, String msg) {
SimpleMailMessage message = new SimpleMailMessage();
String[] array = new String[];
array[0]="[email protected]";
array[1]="[email protected]";
array[2]="subject";
array[3]="text";
message.setFrom(from);
message.setTo(to);
message.setSubject(subject);
message.setText(msg);
mailSender.sendMail(); // what should be here?
}
}
What is this arguments?
Upvotes: 0
Views: 941
Reputation: 688
Try to use full path to mail sender
private org.springframework.mail.MailSender mailSender;
Upvotes: 2
Reputation: 120851
The interface org.springframework.mail.MailSender
provides two methods:
void send(SimpleMailMessage simpleMessage) throws MailException;
void send(SimpleMailMessage[] simpleMessages) throws MailException;
See
So you are wrong ("...But there is no send() at all...") and the tutorials are right!
Double check that your MailSender
is the one from org.springframework.mail
Upvotes: 0