Hi, today I am going to explain about simple email sending verification by using Grails technology .

  • Firstly, create a new project in IntelliJ Idea and set the name of the project as per your choice. Here my project name is  DemoLoginPage and now select grails-app/config/BuildConfig.groovy  configuration file,and I’ll use a plugin which is mentioned below for email configuration.

 

here I wants to tell you that i am using Grails 2.3.9 version .

  • After using plug-in configuration, we will create email related configuration like host name,email port number ,username,password etc. In  Grails-app/config/Config. groovy file, so for more detail kindly check below . some time we do port related mistakes so be careful with the mail-port number, because for Gmail,  port number is 465 and sending email  via a Hotmail/Live account you need to use port number is 587 and so on.

  • After completing above configuration, our next level is to creating Domain class and here I am taking Domain class name is Register and choose attribute whatever I required. here i am taking normal property  and also using static constraints for given attribute limitation.

  • After creating domain class, now we need to create Controller and in the controller, we will put our email related configuration logic.

Here I am creating UserController and in this controller, I am creating three actions, where the first action name is  emailconfirm and this action will help to open emailconfirm GSP page and here we are also getting email parameter whenever user clicks on submit button, then request will reach at sendMail() action, then here we get the sender email address, subject line and text field. With the help of Text field, we can send the text message whatever we require with email . So after sending mail  confirm() action will execute and send the success message.

So by this, developer  can send email on given email address very easily, and this is the very simplest way to sending a email  using Grails.