Search in sources :

Example 1 with HtmlEmail

use of pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail in project Flare-event-calendar by PollubCafe.

the class RegistrationServiceImpl method sendActivationEmail.

private void sendActivationEmail(Email email) {
    try {
        checkArgument(email instanceof HtmlEmail);
        emailSender.send((HtmlEmail) email);
    } catch (MessagingException e) {
        e.printStackTrace();
        throw new SendingActivationEmailFailException();
    }
}
Also used : MessagingException(javax.mail.MessagingException) SendingActivationEmailFailException(pl.pollub.cs.pentagoncafe.flare.exception.sendingEmail.SendingActivationEmailFailException) HtmlEmail(pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail)

Example 2 with HtmlEmail

use of pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail in project Flare-event-calendar by PollubCafe.

the class EmailBuilderImpl method buildEmailToEventAuthor.

@Override
public EmailBuilder buildEmailToEventAuthor(String messageContent, String subject) {
    HtmlEmail instance = new HtmlEmail("PentagonCafe");
    instance.setSubject(subject);
    Context emailTemplateContext = new Context();
    emailTemplateContext.setVariable("messageContent", messageContent);
    String templateName = "messageToEventAuthor";
    String htmlContent = templateEngine.process(templateName, emailTemplateContext);
    instance.setHtmlContent(htmlContent);
    this.instance = instance;
    return this;
}
Also used : Context(org.thymeleaf.context.Context) HtmlEmail(pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail)

Example 3 with HtmlEmail

use of pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail in project Flare-event-calendar by PollubCafe.

the class EmailBuilderImpl method buildActivationEmail.

@Override
public EmailBuilder buildActivationEmail(String activationToken) {
    HtmlEmail instance = new HtmlEmail("from@no-spam.com");
    instance.setSubject("Finish registration");
    Context emailTemplateCtx = new Context();
    String activationURL = messages.get("registration.activationURL") + activationToken;
    emailTemplateCtx.setVariable("activationURL", activationURL);
    String templateName = "finishRegistration";
    String htmlContent = templateEngine.process(templateName, emailTemplateCtx);
    instance.setHtmlContent(htmlContent);
    this.instance = instance;
    return this;
}
Also used : Context(org.thymeleaf.context.Context) HtmlEmail(pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail)

Example 4 with HtmlEmail

use of pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail in project Flare-event-calendar by PollubCafe.

the class EmailBuilderImpl method buildResetPasswordEmail.

@Override
public EmailBuilder buildResetPasswordEmail(String generatedPassword) {
    HtmlEmail instance = new HtmlEmail("from@no-spam.com");
    instance.setSubject("Reset password");
    Context emailTemplateCtx = new Context();
    emailTemplateCtx.setVariable("generatedPassword", generatedPassword);
    String templateName = "forgotPassword";
    String htmlContent = templateEngine.process(templateName, emailTemplateCtx);
    instance.setHtmlContent(htmlContent);
    this.instance = instance;
    return this;
}
Also used : Context(org.thymeleaf.context.Context) HtmlEmail(pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail)

Example 5 with HtmlEmail

use of pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail in project Flare-event-calendar by PollubCafe.

the class EmailSenderServiceImpl method sendEmail.

@Override
public void sendEmail(EmailToEventAuthorReqDTO emailToEventAuthorReqDTO) {
    Event event = eventRepository.findById(emailToEventAuthorReqDTO.getEventID()).orElseThrow(() -> new ObjectNotFoundException(Event.class, "id", emailToEventAuthorReqDTO.getEventID()));
    User eventAuthor = event.getOrganizer();
    String message = emailToEventAuthorReqDTO.getContent();
    String subject = emailToEventAuthorReqDTO.getSubject();
    Email email = emailBuilder.buildEmailToEventAuthor(message, subject).to(eventAuthor.getEmail());
    try {
        checkArgument(email instanceof HtmlEmail);
        emailSender.send((HtmlEmail) email);
    } catch (MessagingException e) {
        e.printStackTrace();
        throw new SendingEmailException("Email to author sending filed.");
    }
}
Also used : User(pl.pollub.cs.pentagoncafe.flare.domain.User) Email(pl.pollub.cs.pentagoncafe.flare.component.email.Email) HtmlEmail(pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail) MessagingException(javax.mail.MessagingException) ObjectNotFoundException(pl.pollub.cs.pentagoncafe.flare.exception.ObjectNotFoundException) HtmlEmail(pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail) Event(pl.pollub.cs.pentagoncafe.flare.domain.Event) SendingEmailException(pl.pollub.cs.pentagoncafe.flare.exception.sendingEmail.SendingEmailException)

Aggregations

HtmlEmail (pl.pollub.cs.pentagoncafe.flare.component.email.HtmlEmail)6 MessagingException (javax.mail.MessagingException)3 Context (org.thymeleaf.context.Context)3 Email (pl.pollub.cs.pentagoncafe.flare.component.email.Email)1 Event (pl.pollub.cs.pentagoncafe.flare.domain.Event)1 User (pl.pollub.cs.pentagoncafe.flare.domain.User)1 ObjectNotFoundException (pl.pollub.cs.pentagoncafe.flare.exception.ObjectNotFoundException)1 SendingActivationEmailFailException (pl.pollub.cs.pentagoncafe.flare.exception.sendingEmail.SendingActivationEmailFailException)1 SendingEmailException (pl.pollub.cs.pentagoncafe.flare.exception.sendingEmail.SendingEmailException)1 SendingResetPasswordEmailFailException (pl.pollub.cs.pentagoncafe.flare.exception.sendingEmail.SendingResetPasswordEmailFailException)1