Mailgun API
Instructions
If you do not have an account register on https://signup.mailgun.com/new/signup
Activate your account by clicking on the link in the verification email send to you.
In your Mailgun app click on Sending > Domains in the left menu
Select your sandbox domain
In the “Authorized Recipients” card add your email and click Save Recipient. Verification mail will be sent to that email address and recipient must agree to receiving emails.
In domain overview click on SMTP and copy the following settings to your application properties:
SMTP hostname
tospring.mail.host
Port
tospring.mail.port
Username
tospring.mail.jndi-name.spring.mail.username
Default password
tospring.mail.jndi-name.spring.mail.password
Test your connection by creating new Groovy runner (string
"your@email.com"
replace with the autorized recipients email address from step 5) and starting your app:@Component class TestMailRunner extends AbstractOrderedCommandLineRunner { @Autowired private IMailService mailService @Override void run(String... args) throws Exception { SimpleMailDraft draft = SimpleMailDraft.simpleMailDraftBuilder() .body("Test mail body") .isHtml(false) .subject("Test mail") .recipients(["your@email.com"]) .build() mailService.sendMail(draft) } }