Announcement Announcement Module
Collapse
No announcement yet.
How do I send an E-mail notification with Spring 3 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I send an E-mail notification with Spring 3

    Hi,

    I am making a form for creating a taxpayer profile. I have already made the registration work. However, one of the specifications is that once the taxpayer profile is created, an e-mail notification should be sent to the email provided in the taxpayer profile form that has been submitted. How may I be able to do this? I really need help.

    Hope to hear a reply for this. Thanks in advance!

  • #2
    This has nothing to do with spring MVC.
    Spring provides some extended functionality over JavaMail in spring-context-support module.
    http://static.springsource.org/sprin...ailSender.html

    Comment


    • #3
      Hi,

      After I've made a class for the Email Notification, should I configure something on my servlet.xml file? What should I put there? Thanks.

      My class is now like this:
      Code:
      package ETPS.web;
      
      import org.springframework.mail.MailException;
      import org.springframework.mail.MailSender;
      import org.springframework.mail.SimpleMailMessage;
      
      public class EmailNotification {
      	
      	private MailSender mailSender;
      	private SimpleMailMessage simpleMailMessage;
      	
      	public void setSimpleMailMessage(SimpleMailMessage simpleMailMessage) {
      		this.simpleMailMessage = simpleMailMessage;
      	}
      
      	public void setMailSender(MailSender mailSender) {
      		this.mailSender = mailSender;
      	}
      	
      	public void sendMail(Taxpayer taxpayer) {
      
      		SimpleMailMessage message = new SimpleMailMessage(simpleMailMessage);
      		
      		message.setTo(taxpayer.getEmailAddress());
      		message.setText("Dear " + taxpayer.getTaxpayerName() + ",\n" + 
      				"Your profile has been created.");
      
      		try{
      			mailSender.send(message);
      		} catch(MailException e) {
      			System.err.println(e.getMessage());
      		}
      		
      	}
      	
      }

      Comment


      • #4
        Sending email notifications with Spring 3

        Try this:
        It worked for me:

        http://www.javacodegeeks.com/2010/07...l#comment-form

        Comment

        Working...
        X