11package pl .databucket .server .service .mail ;
22
3- import com .sun .mail .util .MailConnectException ;
43import lombok .AllArgsConstructor ;
5- import org .springframework .mail .MailSendException ;
64import org .springframework .mail .javamail .JavaMailSender ;
75import org .springframework .stereotype .Service ;
86import pl .databucket .server .entity .User ;
@@ -15,7 +13,7 @@ public class MailSenderService {
1513
1614 private JavaMailSender sender ;
1715
18- public void sendConfirmationLink (User user , String link ) throws MessagingException {
16+ public void sendConfirmationLink (User user , String link , String from ) throws MessagingException {
1917 String htmlContent = "<h2>Thanks for signing up to Databucket.</h2>" ;
2018
2119 htmlContent += "<p>To confirm your registration, copy and paste the URL into your browser:</p>" ;
@@ -25,26 +23,28 @@ public void sendConfirmationLink(User user, String link) throws MessagingExcepti
2523 htmlContent += "<p>If you didn't request a registration, don't worry. You can safely ignore this email.</p><br/><br/>" ;
2624
2725 MailSenderHandler mailHandler = new MailSenderHandler (sender );
26+ mailHandler .setFrom (from );
2827 mailHandler .setTo (user .getEmail ());
2928 mailHandler .setSubject ("Databucket account - registration" );
3029 mailHandler .setText (htmlContent , true );
3130 mailHandler .send ();
3231 }
3332
34- public void sendRegistrationConfirmation (User user ) throws MessagingException {
33+ public void sendRegistrationConfirmation (User user , String from ) throws MessagingException {
3534 String htmlContent = "<h2>Databucket account</h2>" ;
3635
3736 htmlContent += "<p>Your account has been activated.</p>" ;
3837 htmlContent += "<p>Log in to the application and request to be assigned to the project.</p>" ;
3938
4039 MailSenderHandler mailHandler = new MailSenderHandler (sender );
40+ mailHandler .setFrom (from );
4141 mailHandler .setTo (user .getEmail ());
4242 mailHandler .setSubject ("Databucket account - activated" );
4343 mailHandler .setText (htmlContent , true );
4444 mailHandler .send ();
4545 }
4646
47- public void sendForgotPasswordLink (User user , String link ) throws MessagingException {
47+ public void sendForgotPasswordLink (User user , String link , String from ) throws MessagingException {
4848 String htmlContent = "<h2>Databucket account</h2>" ;
4949 htmlContent += "<h4>Forgot your password?</h4>" ;
5050 htmlContent += "<p>We received a request to reset the password for your account.</p><br/>" ;
@@ -56,19 +56,21 @@ public void sendForgotPasswordLink(User user, String link) throws MessagingExcep
5656 htmlContent += "<p>If you didn't request a reset, don't worry. You can safely ignore this email.</p><br/><br/>" ;
5757
5858 MailSenderHandler mailHandler = new MailSenderHandler (sender );
59+ mailHandler .setFrom (from );
5960 mailHandler .setTo (user .getEmail ());
6061 mailHandler .setSubject ("Databucket account - forgot your password?" );
6162 mailHandler .setText (htmlContent , true );
6263 mailHandler .send ();
6364 }
6465
65- public void sendNewPassword (User user , String password ) throws MessagingException {
66+ public void sendNewPassword (User user , String password , String from ) throws MessagingException {
6667 String htmlContent = "<h2>Databucket account</h2>" ;
6768 htmlContent += "<p>Your password has been reset.</p>" ;
6869 htmlContent += "<p>Below you can find your temporary password:</p>" ;
6970 htmlContent += "<h2>" + password + "</h2>" ;
7071
7172 MailSenderHandler mailHandler = new MailSenderHandler (sender );
73+ mailHandler .setFrom (from );
7274 mailHandler .setTo (user .getEmail ());
7375 mailHandler .setSubject ("Databucket account - temporary password" );
7476 mailHandler .setText (htmlContent , true );
0 commit comments