What Is SendGrid And How To Integrate It In A Web Application
Posted By : Kaushlendra Kumar Pal | 27-Apr-2018
Hello, friends nowadays email has great importance in modern business communication. Every day, ample emails area unit sent from corporations to customers and suppliers, from workers to their managers and from one coworker to a different. There are many reasons to use email service when compared to other methods of communication. That is why in this blog I will give you the information about a very good email service provider and how to use that service in your application.
What is Sendgrid
- SendGrid is an email service platform which is cloud-based.
- SendGrid provides companies with unmatched deliverability, scalability, and reliability when it comes to email management.
- SendGrid assist companies with transactional email management while at the same time abiding by anti-spam regulations.
- Sendgrid is able to manage various types of emails such as friend requests, shipping notifications, email newsletters, and sign-up confirmations.
- In addition, the tool manages Internet service provider (ISP) monitoring, sender policy framework (SPF), domain keys, and feedback loops.
- SendGrid has been established as an API company.
- It has been built to serve developers and makes it fast for companies to send the email.
- It is able to send emails over SMTP or HTTP, and you can also use one of the company’s official client libraries.
Sendgrid Features
- SMTP Service
- Custom API Integration
- Open & Click Tracking
- Email Template Engine
- File attachment
- SMTP API
- ISP Monitoring
- SPAM Filter Testing
- 24/7 Support (Phone and Chat) How to integrate sendgrid
- Sign up to create free Sendgrid Account
- You will get Full feature free trial which includes accessing 40,000 email plan, free for 30 days.
- After that, you can send 100 emails/day for free forever.
- Also, store up to 2,000 contacts within Marketing Campaigns
- No credit card required for the free account.
Integrate into Application
Update the development environment with your unique SENDGRID_API_KEY.
Then add the following maven dependency in the root of your project.
<dependency>
<groupId>com.sendgrid</groupId>
<artifactId>sendgrid-java</artifactId>
<version>4.1.2</version>
</dependency>
Now you are ready to send emails using sendgrid from your application. here I'm providing a sample mail sending API which will help you to start sending emails with sendgrid from your application.
SendGridApplication.java
import com.sendgrid.*;
import java.io.IOException;
public class SendGridApp {
public static void main(String[] args) throws IOException {
Email from = new Email("[email protected]");
String subject = "Test mail using SendGrid";
Email to = new Email("[email protected]");
Content content = new Content("text/plain", "and easy to do anywhere, even with Java");
Mail mail = new Mail(from, subject, to, content);
SendGrid sg = new SendGrid("your unique SENDGRID_API_KEY");
Request request = new Request();
try {
request.setMethod(Method.POST);
request.setEndpoint("mail/send");
request.setBody(mail.build());
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
I hope you have got something useful information from this blog.
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Kaushlendra Kumar Pal
Kaushlendra is an experienced Java Developer with comprehensive mastery of all Java packages. Able to Write well designed, testable, efficient code as per the requirements and handle different types of issues as well as functions.