• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem sending mail with spring javamailsender  RSS feed

Dipika Saxena
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm unable to send mails using interface org.springframework.mail.javamail.JavaMailSender whereas simple Javamail API is working fine.
I am using following code:
public void sendRegistrationMail(List params)
mailSender.send(new MimeMessagePreparator() {
public void prepare(MimeMessage mimeMessage) throws MessagingException {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true, "UTF-8");
message.setFrom(new InternetAddress("dsaxena@fiberlink.com"));
message.setTo(new InternetAddress("dipika.saxena@iiitb.ac.in"));
message.setSubject("my subject");
message.setText("my test mail");
//message.addInline("myLogo", new ClassPathResource("img/mylogo.gif"));
//message.addAttachment("myDocument.pdf", new ClassPathResource("doc/myDocument.pdf"));

where mailSender is the bean of type org.springframework.mail.javamail.JavaMailSenderImpl
and I have set the smtp host server as property of this bean in applicationContext-storefront-service.xml as following:

<bean id="mailSender"
<property name="host">
<property name="port">
It is not giving any exception but the mail is not reaching in the inbox whereas if I use JavaMail API, it goes fine.

Please suggest.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!