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

Last change on this file since 5306751 was 5306751, checked in by NikolaCenevski <cenevskinikola@…>, 3 years ago

Dodadeno posts to be approved

  • Property mode set to 100644
File size: 1.6 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}
Note: See TracBrowser for help on using the repository browser.