source: src/main/java/it/finki/charitable/services/EmailService.java@ 2d8c0e7

Last change on this file since 2d8c0e7 was ab49338, checked in by KostaFortumanov <kfortumanov@…>, 3 years ago

Dodadeno prijavuvanje na objavi

  • Property mode set to 100644
File size: 1.9 KB
Line 
1package it.finki.charitable.services;
2
3import org.springframework.mail.SimpleMailMessage;
4import org.springframework.mail.javamail.JavaMailSender;
5import org.springframework.stereotype.Component;
6
7@Component
8public class EmailService {
9
10 private final JavaMailSender javaMailSender;
11
12 public EmailService(JavaMailSender javaMailSender) {
13 this.javaMailSender = javaMailSender;
14 }
15
16 public void sendValidationEmail(String to, String subject, String token) {
17 SimpleMailMessage message = new SimpleMailMessage();
18 message.setTo(to);
19 message.setSubject(subject);
20
21 String text = "Verify your account on the following link\n" +
22 "http://localhost:8080/validate?token=" + token;
23 message.setText(text);
24 javaMailSender.send(message);
25 }
26
27 public void sendApprovalEmail(String to, String subject, Long postId) {
28 SimpleMailMessage message = new SimpleMailMessage();
29 message.setTo(to);
30 message.setSubject(subject);
31
32 String text = "Your post has been approved\n" + "http://localhost:8080/post?postid=" + postId;
33 message.setText(text);
34 javaMailSender.send(message);
35 }
36
37 public void sendNoApprovalEmail(String to, String subject, String description) {
38 SimpleMailMessage message = new SimpleMailMessage();
39 message.setTo(to);
40 message.setSubject(subject);
41
42 String text = "Sorry, your post hasn't been approved\n" +
43 "Moderator:\n" + description;
44 message.setText(text);
45 javaMailSender.send(message);
46 }
47
48 public void sendDeletionEmail(String to, String subject, String description) {
49 SimpleMailMessage message = new SimpleMailMessage();
50 message.setTo(to);
51 message.setSubject(subject);
52
53 String text = "Sorry, your post has been deleted\n" +
54 "Moderator:\n" + description;
55 message.setText(text);
56 javaMailSender.send(message);
57 }
58}
Note: See TracBrowser for help on using the repository browser.