Search in sources :

Example 1 with Email

use of org.simplejavamail.api.email.Email in project Novel-Grabber by Flameish.

the class EmailNotification method sendAttachment.

/**
 * Sends an Email with chapter names/links and created EPUB of novel as attachment.
 */
public void sendAttachment(Novel novel) {
    StringBuilder links = new StringBuilder();
    for (int i = novel.firstChapter - 1; i < novel.lastChapter; i++) {
        links.append("<a href=\"" + novel.chapterList.get(i).chapterURL + "\">" + novel.chapterList.get(i).name + "</a><br>");
    }
    File epub = new File(novel.saveLocation + "/" + novel.filename);
    Email email = EmailBuilder.startingBlank().to(config.getInstance().getReceiverEmail()).from(config.getInstance().getReceiverEmail()).withSubject("[Novel-Grabber]" + novel.metadata.getTitle() + " - Update").withHTMLText(links.toString()).withAttachment(epub.getName(), new FileDataSource(epub)).buildEmail();
    mailer.sendMail(email);
    GrabberUtils.info("Email send with attachment.");
}
Also used : Email(org.simplejavamail.api.email.Email) FileDataSource(javax.activation.FileDataSource) File(java.io.File)

Example 2 with Email

use of org.simplejavamail.api.email.Email in project dew by gudaoxuri.

the class MAILChannel method innerSend.

@Override
public Resp<String> innerSend(String content, String title, Set<String> receivers) throws Exception {
    Email email = EmailBuilder.startingBlank().from(emailFrom).toMultiple(receivers).withSubject(title).withPlainText(content).buildEmail();
    mailSender.sendMail(email);
    return Resp.success("");
}
Also used : Email(org.simplejavamail.api.email.Email)

Example 3 with Email

use of org.simplejavamail.api.email.Email in project backend by CatalogueOfLife.

the class JobExecutor method sendErrorMail.

private void sendErrorMail(BackgroundJob job) {
    if (mailer != null && onErrorTo != null && onErrorFrom != null) {
        StringWriter sw = new StringWriter();
        sw.write(job.getClass().getSimpleName() + " job " + job.getKey());
        sw.write(" has failed with an exception");
        if (job.getError() != null) {
            sw.write(" " + job.getError().getClass().getSimpleName() + ":\n\n");
            PrintWriter pw = new PrintWriter(sw);
            job.getError().printStackTrace(pw);
        } else {
            sw.write(".\n");
        }
        Email mail = EmailBuilder.startingBlank().to(onErrorTo).from(onErrorFrom).withSubject(String.format("COL job %s %s failed", job.getClass().getSimpleName(), job.getKey())).withPlainText(sw.toString()).buildEmail();
        mailer.sendMail(mail, true);
    }
}
Also used : Email(org.simplejavamail.api.email.Email) StringWriter(java.io.StringWriter) PrintWriter(java.io.PrintWriter)

Example 4 with Email

use of org.simplejavamail.api.email.Email in project nzyme by lennartkoopmann.

the class EmailCallback method call.

@Override
public void call(Alert alert) {
    LOG.info("Sending alert email.");
    try {
        Email email = EmailBuilder.startingBlank().to(configuration.recipients()).from(configuration.from()).withSubject(configuration.subjectPrefix() + " " + buildSubject(alert)).withPlainText(buildPlainTextBody(alert)).withHTMLText(buildHTMLTextBody(alert)).withEmbeddedImage("nzyme_logo", loadLogoFile(), "image/png").buildEmail();
        mailer.sendMail(email);
    } catch (Exception e) {
        LOG.error("Could not send Email.", e);
    }
}
Also used : Email(org.simplejavamail.api.email.Email) IncompleteConfigurationException(horse.wtf.nzyme.configuration.IncompleteConfigurationException) URISyntaxException(java.net.URISyntaxException) InvalidConfigurationException(horse.wtf.nzyme.configuration.InvalidConfigurationException) IOException(java.io.IOException)

Example 5 with Email

use of org.simplejavamail.api.email.Email in project spring-zerocell by nndi-oss.

the class ExcelToEmailController method sendEmailToCustomer.

private void sendEmailToCustomer(Customer customer) {
    Email email = EmailBuilder.startingBlank().from("noreply@nndi-tech.com").to(customer.getFullName(), customer.getEmail()).withSubject("Spring Zerocell Newsletter").withPlainText(String.format("Hello %s, \nPlease view this email in a modern email client!", customer.getFullName())).buildEmail();
    Mailer mailer = MailerBuilder.withDebugLogging(true).withSessionTimeout(10 * 1000).async().buildMailer();
    mailer.sendMail(email);
}
Also used : Email(org.simplejavamail.api.email.Email) Mailer(org.simplejavamail.api.mailer.Mailer)

Aggregations

Email (org.simplejavamail.api.email.Email)121 Test (org.junit.Test)101 Recipient (org.simplejavamail.api.email.Recipient)31 File (java.io.File)26 EmailPopulatingBuilder (org.simplejavamail.api.email.EmailPopulatingBuilder)15 MimeMessage (jakarta.mail.internet.MimeMessage)10 EmailConverter.mimeMessageToEmail (org.simplejavamail.converter.EmailConverter.mimeMessageToEmail)10 InternalEmailPopulatingBuilder (org.simplejavamail.email.internal.InternalEmailPopulatingBuilder)7 URL (java.net.URL)6 AttachmentResource (org.simplejavamail.api.email.AttachmentResource)6 ByteArrayDataSource (jakarta.mail.util.ByteArrayDataSource)5 InternetAddress (jakarta.mail.internet.InternetAddress)4 Date (java.util.Date)4 SpEmail (org.apache.streampipes.model.mail.SpEmail)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 GregorianCalendar (java.util.GregorianCalendar)3 HashedMap (org.apache.commons.collections4.map.HashedMap)3 NotNull (org.jetbrains.annotations.NotNull)3 MimeMessageAndEnvelope (testutil.testrules.MimeMessageAndEnvelope)3 IOException (java.io.IOException)2