File tree Expand file tree Collapse file tree
java/com/vimaltech/contactapi/service/impl Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .vimaltech .contactapi .service .impl ;
2+
3+ import com .vimaltech .contactapi .dto .EmailRequest ;
4+ import com .vimaltech .contactapi .service .EmailService ;
5+ import lombok .extern .slf4j .Slf4j ;
6+ import org .springframework .context .annotation .Primary ;
7+ import org .springframework .stereotype .Service ;
8+
9+ @ Service
10+ @ Primary
11+ @ Slf4j
12+ public class NoOpEmailService implements EmailService {
13+
14+ @ Override
15+ public void sendEmail (EmailRequest request ) {
16+ log .warn ("Email disabled (NoOp) | to={}" , request .getTo ());
17+ }
18+ }
Original file line number Diff line number Diff line change 44import com .vimaltech .contactapi .service .EmailService ;
55import lombok .extern .slf4j .Slf4j ;
66import org .springframework .beans .factory .annotation .Value ;
7+ import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
78import org .springframework .mail .SimpleMailMessage ;
89import org .springframework .mail .javamail .JavaMailSender ;
910import org .springframework .scheduling .annotation .Async ;
1011import org .springframework .stereotype .Service ;
1112
1213@ Service
1314@ Slf4j
15+ @ ConditionalOnProperty (name = "spring.mail.host" )
1416public class SmtpEmailService implements EmailService {
1517
1618 private final JavaMailSender mailSender ;
Original file line number Diff line number Diff line change 1+ # application-test.yml
2+ spring :
3+ mail :
4+ host : localhost
5+ port : 1025
6+ username : test
7+ password : test
8+
9+ app :
10+ mail :
11+ from : test@test.com
12+ enabled : false
13+ admin :
14+ email : test@test.com
You can’t perform that action at this time.
0 commit comments