package nlib.mail;
 
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMessage.RecipientType;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;

import nlib.mail.service.EmailVO;
 
 
@Component
public class EmailSender  {
     
    @Autowired
    protected JavaMailSender  mailSender;
 
    public void SendEmail(EmailVO email) throws Exception {
        MimeMessage msg = mailSender.createMimeMessage();
        MimeMessageHelper helper = new MimeMessageHelper(msg, true, "utf-8");
        helper.setText(email.getContent(), true);	//***HTML 적용
		helper.setTo(email.getReciver());
		helper.setSubject(email.getSubject());
		helper.setFrom("siasia0824@gmail.com","한국문화원연합회");

       /* msg.setSubject(email.getSubject());
        msg.setText(email.getContent(),"text/html");
        msg.setText
        msg.setRecipient(RecipientType.TO , new InternetAddress(email.getReciver()));
         */
        mailSender.send(msg); 
    }
}