@Override protected void configure() { installEmailConfig(); } }
@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); }
@Inject public OverdueStateApplicator(final BlockingInternalApi accessApi, final AccountInternalApi accountApi, final EntitlementApi entitlementApi, final Clock clock, @Named(DefaultOverdueModule.OVERDUE_NOTIFIER_CHECK_NAMED) final OverduePoster checkPoster, final OverdueEmailGenerator overdueEmailGenerator, final EmailConfig config, final PersistentBus bus, final NonEntityDao nonEntityDao, final TagInternalApi tagApi) { this.blockingApi = accessApi; this.accountApi = accountApi; this.entitlementApi = entitlementApi; this.clock = clock; this.checkPoster = checkPoster; this.overdueEmailGenerator = overdueEmailGenerator; this.tagApi = tagApi; this.nonEntityDao = nonEntityDao; this.emailSender = new DefaultEmailSender(config); this.bus = bus; }
private void sendEmail(final List<String> to, final List<String> cc, final String subject, final Email email) throws EmailApiException { try { email.setSmtpPort(config.getSmtpPort()); if (config.useSmtpAuth()) { email.setAuthentication(config.getSmtpUserName(), config.getSmtpPassword()); email.setHostName(config.getSmtpServerName()); email.setFrom(config.getDefaultFrom()); email.setSSL(config.useSSL()); throw new EmailApiException(ee, ErrorCode.EMAIL_SENDING_FAILED);
final String subject = config.getInvoiceEmailSubject(); final EmailSender sender = new DefaultEmailSender(config); try { sender.sendHTMLEmail(to, cc, subject, htmlBody); } catch (EmailApiException e) { throw new InvoiceApiException(e, ErrorCode.EMAIL_SENDING_FAILED);
@Test(enabled = false) public void testSendEmail() throws Exception { final String html = "<html><body><h1>Test E-mail</h1></body></html>"; final List<String> recipients = new ArrayList<String>(); recipients.add("killbill.ning@gmail.com"); final EmailSender sender = new DefaultEmailSender(config); sender.sendHTMLEmail(recipients, null, "Test message", html); } }
@Override protected void configure() { super.configure(); install(new CallContextModule()); install(new MockGlobalLockerModule()); install(new CatalogModule(configSource)); install(new CacheModule(configSource)); install(new TemplateModule()); install(new EmailModule(configSource)); install(new NotificationQueueModule(configSource)); install(new TagStoreModule()); install(new CustomFieldModule()); installExternalApis(); bind(TestInvoiceHelper.class).asEagerSingleton(); } }
private void sendEmailIfRequired(final BillingState billingState, final Account account, final OverdueState nextOverdueState, final InternalTenantContext context) { // Note: we don't want to fail the full refresh call because sending the email failed. // That's the reason why we catch all exceptions here. // The alternative would be to: throw new OverdueApiException(e, ErrorCode.EMAIL_SENDING_FAILED); // If sending is not configured, skip if (nextOverdueState.getEnterStateEmailNotification() == null) { return; } final List<String> to = ImmutableList.<String>of(account.getEmail()); // TODO - should we look at the account CC: list? final List<String> cc = ImmutableList.<String>of(); final String subject = nextOverdueState.getEnterStateEmailNotification().getSubject(); try { // Generate and send the email final String emailBody = overdueEmailGenerator.generateEmail(account, billingState, account, nextOverdueState); if (nextOverdueState.getEnterStateEmailNotification().isHTML()) { emailSender.sendHTMLEmail(to, cc, subject, emailBody); } else { emailSender.sendPlainTextEmail(to, cc, subject, emailBody); } } catch (IOException e) { log.warn(String.format("Unable to generate or send overdue notification email for account %s and overdueable %s", account.getId(), account.getId()), e); } catch (EmailApiException e) { log.warn(String.format("Unable to send overdue notification email for account %s and overdueable %s", account.getId(), account.getId()), e); } catch (MustacheException e) { log.warn(String.format("Unable to generate overdue notification email for account %s and overdueable %s", account.getId(), account.getId()), e); } }
protected void installEmailConfig() { final EmailConfig config = new ConfigurationObjectFactory(configSource).build(EmailConfig.class); bind(EmailConfig.class).toInstance(config); }
@Override protected void configure() { super.configure(); install(new AuditModule()); install(new CacheModule(configSource)); install(new CallContextModule()); install(new CustomFieldModule()); install(new EmailModule(configSource)); install(new MockAccountModule()); install(new MockEntitlementModule()); install(new MockInvoiceModule()); install(new MockTagModule()); install(new TemplateModule()); // We can't use the dumb mocks in MockJunctionModule here install(new ApplicatorMockJunctionModule()); bind(OverdueBusListenerTester.class).asEagerSingleton(); bind(TestOverdueHelper.class).asEagerSingleton(); } }
@Override public void sendPlainTextEmail(final List<String> to, final List<String> cc, final String subject, final String body) throws IOException, EmailApiException { final SimpleEmail email = new SimpleEmail(); try { email.setMsg(body); } catch (EmailException e) { throw new EmailApiException(e, ErrorCode.EMAIL_SENDING_FAILED); } sendEmail(to, cc, subject, email); }