-
-
Notifications
You must be signed in to change notification settings - Fork 274
Description
Currently, the email validation is fixed to email-rfc2822-validator (but can be configured or even turned off completely). And sending emails is restricted to the internal JavaMail logic with SMTP servers.
It would make Simple Java Mail more flexible if these choices could be replaced with a user choice by means of interfaces. For example, have validation replaced by a call to Mailgun's email validation service or whatever. Or have the sending completely replaced by an implementation that uses SendGrid to do the actual sending.
This way Simple Java Mail still acts as accelerator for populating emails, validating email (not addresses), producing an RFC compliant MimeMessage and multi-threaded batch sending, but the address validation and actual sending can be replaced.
Currently Simple Java Mail internally already has two way of sending: sending as normal and logging instead of sending. It might even be possible to abstract proxy / batchprocessing into separate implementations, making the MailSender class much simpler.
Here's what I have in mind for the API:
MailerBuilder
.withSMTPServer(...)
.withAddressValidator(new MailgunAddressValidator())
.withMailSender(myCustomLoggingSender)
.buildMailer();
class MailgunAddressValidator implements AddressValidator {
validateAddress(String emailAddress) {
// call to webservice
}
}