Index: src/main/java/com/example/salonbella/service/mail/ConfirmationTokenService.java
===================================================================
--- src/main/java/com/example/salonbella/service/mail/ConfirmationTokenService.java	(revision 0f3491d058d3b33632a55dae8783810ed77e16f9)
+++ src/main/java/com/example/salonbella/service/mail/ConfirmationTokenService.java	(revision 0f3491d058d3b33632a55dae8783810ed77e16f9)
@@ -0,0 +1,47 @@
+package com.example.salonbella.service.mail;
+
+import com.example.salonbella.entity.ConfirmationTokenEntity;
+import com.example.salonbella.entity.UserEntity;
+import com.example.salonbella.repository.ConfirmationTokenRepository;
+import com.example.salonbella.repository.UserRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.transaction.Transactional;
+import java.time.LocalDateTime;
+import java.util.Optional;
+
+@Service
+public class ConfirmationTokenService {
+    private final ConfirmationTokenRepository confirmationTokenRepository;
+    private final UserRepository userRepository;
+
+    @Autowired
+    public ConfirmationTokenService(ConfirmationTokenRepository confirmationTokenRepository, UserRepository userRepository) {
+        this.confirmationTokenRepository = confirmationTokenRepository;
+        this.userRepository = userRepository;
+    }
+
+
+    public void saveConfirmationToken(ConfirmationTokenEntity confirmationTokenEntity) {
+        confirmationTokenRepository.save(confirmationTokenEntity);
+    }
+
+    @Transactional
+    public void confirmToken(String token) throws Exception {
+        ConfirmationTokenEntity confirmationTokenEntity = confirmationTokenRepository.findByToken(token).orElseThrow(IllegalStateException::new);
+        if (confirmationTokenEntity.getConfirmedAt() != null) {
+            throw new Exception();
+        }
+        LocalDateTime expiresAt = confirmationTokenEntity.getExpiresAt();
+
+        if (expiresAt.isBefore(LocalDateTime.now())) {
+            throw new Exception();
+        }
+
+        Optional<UserEntity> userEntity = userRepository.findById(confirmationTokenEntity.getUser().getId());
+        userEntity.ifPresent(entity -> entity.setValid(true));
+        confirmationTokenRepository.delete(confirmationTokenEntity);
+
+    }
+}
Index: src/main/java/com/example/salonbella/service/mail/EmailService.java
===================================================================
--- src/main/java/com/example/salonbella/service/mail/EmailService.java	(revision 0f3491d058d3b33632a55dae8783810ed77e16f9)
+++ src/main/java/com/example/salonbella/service/mail/EmailService.java	(revision 0f3491d058d3b33632a55dae8783810ed77e16f9)
@@ -0,0 +1,101 @@
+package com.example.salonbella.service.mail;
+
+
+import lombok.AllArgsConstructor;
+import org.springframework.mail.javamail.JavaMailSender;
+import org.springframework.mail.javamail.MimeMessageHelper;
+import org.springframework.stereotype.Service;
+
+import javax.mail.internet.MimeMessage;
+
+@AllArgsConstructor
+@Service
+public class EmailService {
+
+    private JavaMailSender javaMailSender;
+
+    public void send(String to, String name, String token) {
+        MimeMessage mimeMessage = javaMailSender.createMimeMessage();
+        try {
+
+            MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, false,"utf-8");
+            helper.setText(buildEmail(name, "http://localhost:8080/confirm?token=" + token), true);
+            helper.setTo(to);
+            helper.setSubject("Confirm your account");
+            helper.setFrom("salonbella@gmail.com");
+            javaMailSender.send(mimeMessage);
+        } catch (Exception ignored) {
+
+        }
+    }
+
+
+    private String buildEmail(String name, String link) {
+        return "<div style=\"font-family:Helvetica,Arial,sans-serif;font-size:16px;margin:0;color:#0b0c0c\">\n" +
+                "\n" +
+                "<span style=\"display:none;font-size:1px;color:#fff;max-height:0\"></span>\n" +
+                "\n" +
+                "  <table role=\"presentation\" width=\"100%\" style=\"border-collapse:collapse;min-width:100%;width:100%!important\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n" +
+                "    <tbody><tr>\n" +
+                "      <td width=\"100%\" height=\"53\" bgcolor=\"#0b0c0c\">\n" +
+                "        \n" +
+                "        <table role=\"presentation\" width=\"100%\" style=\"border-collapse:collapse;max-width:580px\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\">\n" +
+                "          <tbody><tr>\n" +
+                "            <td width=\"70\" bgcolor=\"#0b0c0c\" valign=\"middle\">\n" +
+                "                <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"border-collapse:collapse\">\n" +
+                "                  <tbody><tr>\n" +
+                "                    <td style=\"padding-left:10px\">\n" +
+                "                  \n" +
+                "                    </td>\n" +
+                "                    <td style=\"font-size:28px;line-height:1.315789474;Margin-top:4px;padding-left:10px\">\n" +
+                "                      <span style=\"font-family:Helvetica,Arial,sans-serif;font-weight:700;color:#ffffff;text-decoration:none;vertical-align:top;display:inline-block\">Confirm your email</span>\n" +
+                "                    </td>\n" +
+                "                  </tr>\n" +
+                "                </tbody></table>\n" +
+                "              </a>\n" +
+                "            </td>\n" +
+                "          </tr>\n" +
+                "        </tbody></table>\n" +
+                "        \n" +
+                "      </td>\n" +
+                "    </tr>\n" +
+                "  </tbody></table>\n" +
+                "  <table role=\"presentation\" class=\"m_-6186904992287805515content\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"border-collapse:collapse;max-width:580px;width:100%!important\" width=\"100%\">\n" +
+                "    <tbody><tr>\n" +
+                "      <td width=\"10\" height=\"10\" valign=\"middle\"></td>\n" +
+                "      <td>\n" +
+                "        \n" +
+                "                <table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"border-collapse:collapse\">\n" +
+                "                  <tbody><tr>\n" +
+                "                    <td bgcolor=\"#1D70B8\" width=\"100%\" height=\"10\"></td>\n" +
+                "                  </tr>\n" +
+                "                </tbody></table>\n" +
+                "        \n" +
+                "      </td>\n" +
+                "      <td width=\"10\" valign=\"middle\" height=\"10\"></td>\n" +
+                "    </tr>\n" +
+                "  </tbody></table>\n" +
+                "\n" +
+                "\n" +
+                "\n" +
+                "  <table role=\"presentation\" class=\"m_-6186904992287805515content\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"border-collapse:collapse;max-width:580px;width:100%!important\" width=\"100%\">\n" +
+                "    <tbody><tr>\n" +
+                "      <td height=\"30\"><br></td>\n" +
+                "    </tr>\n" +
+                "    <tr>\n" +
+                "      <td width=\"10\" valign=\"middle\"><br></td>\n" +
+                "      <td style=\"font-family:Helvetica,Arial,sans-serif;font-size:19px;line-height:1.315789474;max-width:560px\">\n" +
+                "        \n" +
+                "            <p style=\"Margin:0 0 20px 0;font-size:19px;line-height:25px;color:#0b0c0c\">Hi " + name + ",</p><p style=\"Margin:0 0 20px 0;font-size:19px;line-height:25px;color:#0b0c0c\"> Thank you for registering. Please click on the below link to activate your account: </p><blockquote style=\"Margin:0 0 20px 0;border-left:10px solid #b1b4b6;padding:15px 0 0.1px 15px;font-size:19px;line-height:25px\"><p style=\"Margin:0 0 20px 0;font-size:19px;line-height:25px;color:#0b0c0c\"> <a href=\"" + link + "\">Activate Now</a> </p></blockquote>\n Link will expire in 30 minutes. <p>See you soon</p>" +
+                "        \n" +
+                "      </td>\n" +
+                "      <td width=\"10\" valign=\"middle\"><br></td>\n" +
+                "    </tr>\n" +
+                "    <tr>\n" +
+                "      <td height=\"30\"><br></td>\n" +
+                "    </tr>\n" +
+                "  </tbody></table><div class=\"yj6qo\"></div><div class=\"adL\">\n" +
+                "\n" +
+                "</div></div>";
+    }
+}
