Introduction
In this article we will study how to send email with Spring by integrating with SendGrid's email service. Instead of the usual SMTP, we will use HTTP to communicate with SendGrid.Table of Contents
Part 1: Introduction and Functional SpecsPart 2: SendGrid account setup
Part 3: Java classes
Part 4: XML configuration
Part 5: Running the Application
Dependencies
- Spring core 3.1.0.RELEASE
- SendGrid account
- See pom.xml for details
Github
To access the source code, please visit the project's Github repository (click here)
Functional Specs
Let's define our application's requirements:- Create a simple form where users can compose and send emails
- Emails do not need to be persisted in a database
- Send email via HTTP instead of SMTP to avoid firewall issues
Here's our Use Case diagram:
In MVC terms, we decompose the application as follows:
- Model: A simple Map object that conforms with SendGrid's message format
- View: An HTML-based form where users can compose and send emails
- Controller: Spring controller that receives the request. The controller delegates actual work to the service layer which eventually executes an HTTP call to send email to SendGrid.
What is SendGrid?
SendGrid's cloud-based email infrastructure relieves businesses of the cost and complexity of maintaining custom email systems. SendGrid provides reliable delivery, scalability and real-time analytics along with flexible API's that make custom integration a breeze.
Source: http://www.sendgrid.com
Why SendGrid?
- It's easy to integrate with.
- It has a free plan that allows 200 email messages per day.
- SendGrid has an HTTP API for sending emails which is very simple to use.
Screenshots
Let's preview how our application will look like after it has been completed. This is also a good way to clarify further our application's specsThis is the entry page where users can compose and send emails.
After clicking "Send", the email message is sent. An alert is shown to confirm the action.
When user clicks on "Reset", the contents of the fields are cleared. An alert is shown to confirm the action.
Email Messages
This is the sample email received from Gmail. Notice Gmail is able to show that this email was sent via SendGrid.
This is the sample email received from Yahoo.
Next
In the next section, we will show how to sign-up with SendGrid's email service. This is required before we can start sending emails. Click here to proceed.
Share the joy:
|
Subscribe by reader Subscribe by email Share
I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeleteSpring online training Spring online training Spring Hibernate online training Spring Hibernate online training Java online training
spring training in chennai spring hibernate training in chennai
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeletecore java training in Electronic City
Hibernate Training in electronic city
spring training in electronic city
java j2ee training in electronic city
I enjoyed your blog Thanks for sharing such an informative post. We are also providing the best services click on below links to visit our website.
ReplyDeletedigital marketing company in nagercoil
digital marketing services in nagercoil
digital marketing agency in nagercoil
best marketing services in nagercoil
SEO company in nagercoil
SEO services in nagercoil
social media marketing in nagercoil
social media company in nagercoil
PPC services in nagercoil
digital marketing company in velachery
digital marketing company in velachery
digital marketing services in velachery
digital marketing agency in velachery
SEO company in velachery
SEO services in velachery
social media marketing in velachery
social media company in velachery
PPC services in velachery
online advertisement services in velachery
online advertisement services in nagercoil
web design company in nagercoil
web development company in nagercoil
website design company in nagercoil
website development company in nagercoil
web designing company in nagercoil
website designing company in nagercoil
best web design company in nagercoil
web design company in velachery
web development company in velachery
website design company in velachery
website development company in velachery
web designing company in velachery
website designing company in velachery
best web design company in velachery
Thanks for Sharing - ( Groarz branding solutions )