Search in sources :

Example 1 with SingleSendMailRequest

use of com.aliyuncs.dm.model.v20151123.SingleSendMailRequest in project TranslateIt-api by zunpiau.

the class EmailService method sendEmail.

private void sendEmail(String mailTo, String subject, String content) {
    SingleSendMailRequest request = new SingleSendMailRequest();
    request.setAccountName(aliAccount);
    request.setFromAlias("TranslateIt");
    request.setAddressType(1);
    request.setReplyToAddress(true);
    request.setToAddress(mailTo);
    request.setSubject(subject);
    request.setHtmlBody(content);
    try {
        HttpResponse response = client.doAction(request, true, 2);
        logger.debug("send email to [{}] status [{}]", mailTo, response.getStatus());
        if (!response.isSuccess()) {
            throw new EmailSendException();
        }
    } catch (ClientException e) {
        logger.error(mailTo, e);
        throw new EmailSendException();
    }
}
Also used : SingleSendMailRequest(com.aliyuncs.dm.model.v20151123.SingleSendMailRequest) HttpResponse(com.aliyuncs.http.HttpResponse) EmailSendException(zjp.translateit.web.exception.EmailSendException) ClientException(com.aliyuncs.exceptions.ClientException)

Aggregations

SingleSendMailRequest (com.aliyuncs.dm.model.v20151123.SingleSendMailRequest)1 ClientException (com.aliyuncs.exceptions.ClientException)1 HttpResponse (com.aliyuncs.http.HttpResponse)1 EmailSendException (zjp.translateit.web.exception.EmailSendException)1