package com.reyun.task;

import com.reyun.util.MailUtils;
import com.reyun.util.SendCommonPostMail;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * Created by Administrator on 2017/5/6 0006.
 * desc:邮件发送线程
 */
public class EmailThread
        extends Thread {

    protected Logger logger = LoggerFactory.getLogger(EmailThread.class);

    private String title;
    private String content ;
    private List<String> receiver;

    public EmailThread(){}

    public EmailThread(String title, String content, List<String> receiver)
    {

        this.setName("SendEmailThread");
        this.title = title;
        this.content = content;
        this.receiver=receiver;
    }

    @Override
    public void run(){
        try {
            MailUtils.sendHtmlEmail(title,content,receiver);
        } catch (Exception e) {
            logger.error("fail to send email by reyun.com." + e.getMessage());
        }

        try {
            SendCommonPostMail.sendMail(title, content, "zhangxiaoyan@reyun.com");
        } catch (Exception e) {
            logger.error("fail to send email 2 zhangxiaoyan by sendcloud.......title is " + title);
        }

    }

}
