SendGrid’s Internet API and SMTP Relay are the 2 major strategies of integrating with and sending electronic mail by means of SendGrid. You may consider their variations like strategies of delivering a bundle: you could possibly ship a bundle within the mail, or you could possibly drive it to the vacation spot your self.
Whereas the strategies of supply are totally different, the tip end result is identical: the bundle 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 flawed, prohibiting us from processing the request.
When every thing 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 bundle within the mailbox and letting the put up workplace assessment 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 handle is legitimate and has accepted the message. As soon as accepted, the ISP then determines if it must be positioned within the inbox, junk folder, spam folder, or defer the message all collectively.
You may study extra concerning the server response messages in our electronic mail error messages glossary entry.
SMTP relay
Sending electronic 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 bundle your self as a result of it requires extra steps to finish the supply course of. When a sender makes use of SMTP to connect with SendGrid, separate items of data have to be handed forwards and backwards between SendGrid and its clients earlier than the message might be processed and despatched to the recipient ISP.
With SMTP, SendGrid has to test the message, DNS, and authentication. Every of these will return a 250 message or a 400 or 500 message indicating that one thing is true or flawed individually. The same dialog has to happen between SendGrid and the receiving ISP earlier than the ISP can determine 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 put up Electronic mail Message Movement 101.
SMTP vs. API
Due to the additional “chatter” forwards and backwards throughout an SMTP connection, we advise that SendGrid clients use the Internet API when doable 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 would trigger a type of “not okay” messages.
- The Internet API is quicker. The additional forwards and backwards crucial in SMTP relay may cause some (minimal) latency for purchasers who’re outdoors of the USA, and thus farther from our inbound information facilities.
- The Internet API additionally lets you add an additional layer of safety to your program by using API keys. API keys mean you can 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 mentioned, SMTP is an electronic 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 can be used to attach with an current utility like a CRM system or a mail shopper like Outlook. The Internet API is commonly utilized by builders creating their very own merchandise.
To learn extra about SendGrid’s electronic mail instruments and options, head over to our Documentation.