SendGrid’s Internet API and SMTP Relay are the 2 main strategies of integrating with and sending e-mail by SendGrid. You possibly can consider their variations like strategies of delivering a package deal: you might ship a package deal within the mail, or you might drive it to the vacation spot your self.
Whereas the strategies of supply are completely different, the tip outcome is similar: the package deal is acquired. Beneath, we’ll stroll you thru the ins and outs of our API vs. SMTP sending strategies.
Internet API
SendGrid’s Internet API sends mail through HTTP. Your server sends a message to SendGrid, and receives both a 250 message, indicating that the message was accepted by the receiving server, or a 400 or 500 message, indicating that one thing is unsuitable, prohibiting us from processing the request.
When every part is packaged accurately, SendGrid can course of the request after which ship it to the meant recipient’s ISP that responds with both a 250 message or a 500 message of their very own, informing SendGrid whether or not or not the message was acquired. This course of is extra just like placing your package deal within the mailbox and letting the publish workplace evaluate its data and ship it for you.
Reminder: A 250 message out of your recipient’s ISP does not assure that the e-mail will attain their inbox—it signifies that the ISP has decided the deal with is legitimate and has accepted the message. As soon as accepted, the ISP then determines if it ought to be positioned within the inbox, junk folder, spam folder, or defer the message all collectively.
You possibly can be taught extra in regards to the server response messages in our e-mail error messages glossary entry.
SMTP relay
Sending e-mail through SMTP relay, or Easy Mail Switch Protocol, requires extra forwards and backwards dialog to ship a message to the meant recipient than the Internet API. In our instance, this technique is extra like delivering a package deal your self as a result of it requires further steps to finish the supply course of. When a sender makes use of SMTP to hook up with SendGrid, separate items of knowledge should be handed forwards and backwards between SendGrid and its prospects earlier than the message might be processed and despatched to the recipient ISP.
With SMTP, SendGrid has to verify the message, DNS, and authentication. Every of these will return a 250 message or a 400 or 500 message indicating that one thing is correct or unsuitable individually. The same dialog has to happen between SendGrid and the receiving ISP earlier than the ISP can resolve whether or not it’s going to ship, block, or ship the e-mail to the spam folder.
Learn an in-depth clarification of SMTP Relay in our weblog publish E mail Message Circulate 101.
SMTP vs. API
Due to the additional “chatter” forwards and backwards throughout an SMTP connection, we recommend that SendGrid prospects use the Internet API when attainable for a number of causes:
- SMTP relay creates a number of factors of potential failure, which means that there are extra locations within the dialog between the sender and SendGrid that might trigger a kind of “not okay” messages.
- The Internet API is quicker. The additional forwards and backwards essential in SMTP relay could cause some (minimal) latency for purchasers who’re exterior of the US, and thus farther from our inbound information facilities.
- The Internet API additionally means that you can add an additional layer of safety to your program by using API keys. API keys will let you generate an authentication credential separate out of your username password, which considerably lowers the possibility of somebody utilizing your account to ship spam or phish.
That being stated, SMTP is an e-mail commonplace and is used universally. The Internet API was created by SendGrid’s founders to attach with our system extra effectively and may not be a viable possibility for all customers. SMTP relay will also be used to attach with an present utility like a CRM system or a mail shopper like Outlook. The Internet API is usually utilized by builders creating their very own merchandise.
To learn extra about SendGrid’s e-mail instruments and options, head over to our Documentation.