Search code examples
javaemailgrailsconfigurationmailjet

Using Mailjet API in Grails application for sending mails


I want to integrate Mailjet API in Grails application for sending mails, I have already used ASYNC mail API for sending mail in grails, in this api , I need to give configuration parameters in config.groovy. Now as I am using Mailjet for sending mails, so I need to give Mailjet SMTP settings in config.groovy, so I give as follows :

grails {
       mail {
         host = "in.mailjet.com"
         port = 465
         username = "xxx@gmail.com"
         password = "xxx"
         props = ["mail.smtp.host": "in.mailjet.com",
                  "mail.smtp.socketFactory.port": "465",
                  "mail.smtp.socketFactory.class": "javax.net.ssl.SSLSocketFactory",
                  "mail.smtp.auth":"true",                     
                  "mail.smtp.port": "465",
                  "mail.smtp.user": "API key of mailjet",
                  "mail.smtp.password": "secret key of mailjet"]
       }
    } 

Here is the example of sending mail using java code

What am I doing wrong?


Solution

  • username and password have to contain your api key and the api secret, not the credentials that you use to log into the web site. Using mail.smtp.host as a property is redundant and should not be necessary.