| package com.zt.modules.message.handler; | 
|   | 
| import java.util.List; | 
|   | 
| import org.apache.commons.lang3.StringUtils; | 
| import org.slf4j.Logger; | 
| import org.slf4j.LoggerFactory; | 
| import org.springframework.stereotype.Component; | 
|   | 
| import com.alibaba.fastjson.JSON; | 
| import com.zt.common.message.handler.MessageHandler; | 
| import com.zt.common.message.model.MessageContent; | 
| import com.zt.common.message.model.MessageType; | 
| import com.zt.common.message.model.identity.EmailIdentity; | 
| import com.zt.common.message.model.identity.MessageIdentity; | 
|   | 
| /** | 
|  * 邮件消息处理器。 | 
|  * | 
|  * @author jeff | 
|  */ | 
| @Component("bmp-mailHandler") | 
| public class MailHandler extends MessageHandler<MessageContent> { | 
|   | 
|     private static final Logger LOGGER = LoggerFactory.getLogger(MailHandler.class); | 
|   | 
|     @Override | 
|     public MessageType getType() { | 
|         return MessageType.EMAIL; | 
|     } | 
|   | 
|     @Override | 
|     public boolean getIsDefault() { | 
|         return true; | 
|     } | 
|   | 
|     @Override | 
|     public boolean getSupportHtml() { | 
|         return true; | 
|     } | 
|   | 
|     @Override | 
|     public boolean sendMessage(MessageContent notifMessage) { | 
|         List<MessageIdentity> recievers = notifMessage.getReceivers(); | 
|         for (MessageIdentity reciever : recievers) { | 
|             if (reciever instanceof EmailIdentity) { | 
|                 String email = ((EmailIdentity) reciever).getEmail(); | 
|                 if (StringUtils.isNotBlank(email)) { | 
|                     try { | 
|                         // send(email, notifMessage.getSubject(), notifMessage.getHtmlContent()); | 
|   | 
|                         // todo 调用邮件发送 | 
|                     } catch (Exception e) { | 
|                         LOGGER.error("发送邮件失败!, 发送参数:{}", JSON.toJSONString(notifMessage), e); | 
|                     } | 
|                 } | 
|             } | 
|         } | 
|         LOGGER.debug("发送邮件成功 :{}", JSON.toJSONString(notifMessage)); | 
|         return true; | 
|     } | 
|   | 
| } |