Amazon Simple Email Service (SES) - Should I use SMTP Interface or SES API?
Asked Answered
G

5

39

I'm new to Amazon SES and I see that there are two ways to programmatically send emails:

  1. SES API (http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-api.html)
  2. SES SMTP Interface (http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-using-smtp-java.html)

What are the pros and cons of each method? They seem interchangeable to me, but I'd like to hear from folks who have had experience with SES.

In terms of my own requirements, I'll be sending transactional emails (i.e. receipts, account confirmation, etc.) and notification emails (i.e. "you have a new message", status change, etc.) to my users as they interact with my web and mobile app. If possible, I'd like to keep a history of all these outgoing emails.

Goddaughter answered 9/6, 2015 at 1:27 Comment(0)
T
20

The SES API ties you to AWS, the SMTP interface... well it's SMTP.

Do you foresee, in the future the need to move off AWS? Does your application already speak SMTP to another email server?

Depending on your current application it may be easier to go with SMTP.

If you're starting from scratch and don't foresee any need to move off AWS you should probably go with the SES API.

Tabshey answered 11/6, 2015 at 5:39 Comment(0)
I
15

From Amazon's documentation on improving throughput, one advantage the API is the option of using persistent HTTP connections for increase throughput. This is not available to the SMTP option.

Apart from this, I have not been able to find any other major differences between the API and SMTP.

Internuncial answered 5/8, 2016 at 6:48 Comment(2)
Thanks for the useful linkSher
This documentation has moved to docs.aws.amazon.com/ses/latest/DeveloperGuide/…Vigen
P
8

By using the SES API, you are using the SDK, so you can use Roles on your instances: you won't have to handle and store a password for your configuration, so you won't go through the pain of changing the password.

I released a small project https://github.com/loopingz/aws-smtp-relay to relay from a localhost SMTP to SES API, this way you can connect legacy applications that only handles SMTP to a more normal SES API

Precisian answered 6/3, 2017 at 14:29 Comment(0)
P
4

They seem interchangeable to me

That's a fair analysis. I use both -- API for new code, SMTP for existing code that already knows how to speak SMTP. I haven't found a strong case either way.

Neither interface will preserve a history -- you'll have to do that yourself. One mechanism I'm working on for use with some legacy code is an SMTP proxy that captures the interaction between the app and SES, saving the entire transaction to S3 using the SES message ID as the S3 key for later retrieval if needed (still a work in progress, more pressing projects to do).

You, at minimum, need to preserve those message IDs returned by SES, and configure bounce, delivery, and complaint notifications so you have feedback... which also works the same with either interface.

Plaza answered 9/6, 2015 at 4:56 Comment(2)
can i get messages in amazon seller account using it?Inebriant
This answer is very valuable because in many cases, message retrieval is necessary. I wish they were stored somewhere.Gouda
O
0

Based on my experience, there is often a delay when sending bulk emails. I can send 20-30 emails per second using the API but only 5-10 emails per second with SMTP. Therefore, I prefer using the API over SMTP.

According to the troubleshoot documentation documentation, there are 4 benefits of using the API over SMTP:

  • Multiple Network Requests: Using the Amazon SES query API allows you to submit the email send request with a single network call. In contrast, interfacing with the SMTP endpoint involves multiple network requests (e.g., EHLO, MAIL FROM, RCPT TO, DATA, QUIT). For more information about the Amazon SES query API, see Using the Amazon SES API to send email.

  • Multiple thread: When an application uses a single thread, the application code calls the Amazon SES API and then synchronously waits for an API response. Sending emails is typically an I/O-bound operation, and doing the work from multiple threads provides better throughput. You can send concurrently using as many threads of execution as you wish.

  • Persistent HTTP Connections: With the API, you can use persistent HTTP connections to reduce overhead. Instead of establishing a new HTTP connection for each API request, you can reuse the same connection for multiple requests.

  • SMTP-Specific Issues: If you are using Amazon SES through its SMTP interface, refer to Amazon SES SMTP issues for specific SMTP-related issues that may affect throughput.

Oculist answered 10/7 at 22:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.