Send email from two different addres

I would send some notifications from two different email address based on the context.
Is it possible ?

Hello,

Yes this possible, check our add-on. You can send email and fill the email sender inside Java code.

Best regards,
Dmitry

how i can set parameter for the secon email address?

jmix.email.from-address
spring.mail.host
spring.mail.port
spring.mail.protocol
spring.mail.username
spring.mail.password
spring.mail.properties.mail.smtp.auth
spring.mail.properties.mail.smtp.starttls.enable

Just read docs from Spring, there is no problem to found references how to do this:

1. Configure different email senders

@Bean
public JavaMailSender getJavaMailSenderGmail() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost("smtp.gmail.com");
mailSender.setPort(587);

...other stuff of your config...

return mailSender;
}

@Bean
public JavaMailSender getJavaMailZoho() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost("smtp.zoho.com");

...other stuff of your config...

return mailSender;
}

Don’t forget make one of them default to prevent qualifing error (or add props settings)

2. Override Jmix logics how to send email

@Component("asdasd_MyEmailerImpl")
public class MyEmailerImpl extends EmailerImpl {
    
  
    public void setEmailSender(EmailSender emailSender) {
        this.emailSender = emailSender;
    }
    
}

there is only two places where EmailSender used

image

! You can make bean prototype, because there is a global singleton bean that you will manage after setting new Sender

3. Usage. Before call

  1. Inject bean
@Autowired
private MyEmailerImpl emailer;
  1. Set target emailer
emailer.setEmailSender(...)
  1. Invoke necessary methods as is

Best regards,
Dmitry