import org.springframework.context.annotation.*;
import com.broadleafcommerce.notification.service.*;
import com.broadleafcommerce.notification.service.integration.GmailJavaMailSender;
@Configuration
public class MyNotificationConfiguration {
// Step 1: Configure a JavaMailSender
@Bean
GmailJavaMailSender gmailJavaMailSender() {
// Example seetings for sending from a gmail account
String login = "senderusername@gmail.com";
String password = "passwordForAccount";
return new GmailJavaMailSender(username, password);
}
// Step 2: Configure a Broadleaf JavaMailMessageSender
@Bean
JavaMailMessageSender broadleafJavaMailMessageSender(GmailJavaMailSender javaMailSender) {
return new JavaMailMessageSender(javaMailSender);
}
// Step 3: Register an EMAIL handler with the NotificationService
@Bean
NotificationHandler javaMailNotificationHandler(ThymeleafMessageBuilder builder,
JavaMailMessageSender sender) {
return new DefaultNotificationHandler(builder, sender);
}
}