Package com.sivalabs.springmvc.services

Source Code of com.sivalabs.springmvc.services.EmailService

/**
*
*/
package com.sivalabs.springmvc.services;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Service;

/**
* @author Siva
*
*/
@Service
public class EmailService {

  @Autowired
  private Environment env;
 
  @Autowired
  private JavaMailSenderImpl mailSender;
 
  public void sendMail(String from, String to, String subject, String msg) {
    
    SimpleMailMessage message = new SimpleMailMessage();
    message.setFrom(from);
    message.setTo(to);
    message.setSubject(subject);
    message.setText(msg);
    mailSender.send(message)
  }
 
  public void sendMail(String from, String subject, String msg) {
    
    SimpleMailMessage message = new SimpleMailMessage();
    message.setFrom(env.getProperty("support.email"));
    message.setTo(env.getProperty("support.email"));
    message.setSubject(subject);
    message.setText(msg+"\n\nThanks,\n"+from);
    mailSender.send(message)
  }
}
TOP

Related Classes of com.sivalabs.springmvc.services.EmailService

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.