use of org.apache.commons.mail.EmailException in project killbill by killbill.
the class DefaultEmailSender method sendHTMLEmail.
@Override
public void sendHTMLEmail(final List<String> to, final List<String> cc, final String subject, final String htmlBody) throws EmailApiException {
final HtmlEmail email = new HtmlEmail();
try {
email.setHtmlMsg(htmlBody);
} catch (EmailException e) {
throw new EmailApiException(e, ErrorCode.EMAIL_SENDING_FAILED);
}
sendEmail(to, cc, subject, email);
}
use of org.apache.commons.mail.EmailException in project pinot by linkedin.
the class AlertTaskRunnerV2 method sendFailureEmail.
private void sendFailureEmail(Throwable t) throws JobExecutionException {
HtmlEmail email = new HtmlEmail();
String subject = String.format("[ThirdEye Anomaly Detector] FAILED ALERT ID=%d for config %s", alertConfig.getId(), alertConfig.getName());
String textBody = String.format("%s%n%nException:%s", alertConfig.toString(), ExceptionUtils.getStackTrace(t));
try {
EmailHelper.sendEmailWithTextBody(email, thirdeyeConfig.getSmtpConfiguration(), subject, textBody, thirdeyeConfig.getFailureFromAddress(), thirdeyeConfig.getFailureToAddress());
} catch (EmailException e) {
throw new JobExecutionException(e);
}
}
use of org.apache.commons.mail.EmailException in project graylog2-server by Graylog2.
the class AlarmCallbacksResource method test.
@POST
@Timed
@Path("/{alarmCallbackId}/test")
@ApiOperation(value = "Send a test alert for a given alarm callback")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Alarm callback not found."), @ApiResponse(code = 400, message = "Invalid ObjectId."), @ApiResponse(code = 500, message = "Error while testing alarm callback") })
@NoAuditEvent("only used to test alert notifications")
public Response test(@ApiParam(name = "alarmCallbackId", value = "The alarm callback id to send a test alert for.", required = true) @PathParam("alarmCallbackId") String alarmCallbackId) throws TransportConfigurationException, EmailException, NotFoundException {
final AlarmCallbackConfiguration alarmCallbackConfiguration = alarmCallbackConfigurationService.load(alarmCallbackId);
final String streamId = alarmCallbackConfiguration.getStreamId();
checkPermission(RestPermissions.STREAMS_EDIT, streamId);
final Stream stream = streamService.load(streamId);
final DummyAlertCondition testAlertCondition = new DummyAlertCondition(stream, null, Tools.nowUTC(), getSubject().getPrincipal().toString(), Collections.emptyMap(), "Test Alert");
try {
AbstractAlertCondition.CheckResult checkResult = testAlertCondition.runCheck();
AlarmCallback alarmCallback = alarmCallbackFactory.create(alarmCallbackConfiguration);
alarmCallback.call(stream, checkResult);
} catch (Exception e) {
throw new InternalServerErrorException(e.getMessage(), e);
}
return Response.ok().build();
}
use of org.apache.commons.mail.EmailException in project SpringStepByStep by JavaProgrammerLB.
the class JavaMailDemo method sendSimpleTextMail.
// @Test
public void sendSimpleTextMail() {
try {
Email email = new SimpleEmail();
email.setHostName("smtp.googlemail.com");
email.setSmtpPort(465);
email.setAuthenticator(new DefaultAuthenticator("username", "password"));
email.setSSLOnConnect(true);
email.setFrom("username");
email.setSubject("TestMail");
email.setMsg("This is a test mail ... :-)");
email.addTo("foo@bar.com");
email.send();
} catch (EmailException e) {
e.printStackTrace();
}
}
use of org.apache.commons.mail.EmailException in project SpringStepByStep by JavaProgrammerLB.
the class JavaMailDemo method sendEmailWithHtml.
// @Test
public void sendEmailWithHtml() {
try {
// Create the email message
HtmlEmail email = new HtmlEmail();
email.setHostName("smtp.googlemail.com");
email.setSmtpPort(465);
email.setSSLOnConnect(true);
email.setFrom("username", "LIUBEI");
email.addTo("admin@yitianyigexiangfa.com", "ADMIN");
email.setAuthentication("username", "password");
// embed the image and get the content id
URL url = new URL("http://www.apache.org/images/asf_logo_wide.gif");
String cid = email.embed(url, "Apache logo");
// set the html message
email.setHtmlMsg("<html>The apache logo - <img src=\"cid:" + cid + "\"></html>");
// set the alternative message
email.setTextMsg("Your email client does not support HTML messages");
// send the email
email.send();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (EmailException e) {
e.printStackTrace();
}
}
Aggregations