Settings

Theme

Trap and test AWS SES emails locally

github.com

63 points by anonfunction 2 years ago · 30 comments

Reader

hardwaresofton 2 years ago

Does anyone have a good reason they normally fall back on for using the AWS SDK vs the provided SMTP bridge? Rate limits or anything of the sort?

I find that basically every transnational email service supports SMTP so I normally code to that and call it a day…

  • chrizel 2 years ago

    We switched from using SMTP to the AWS SDK for SES because when sending an e-mail the SDK returns the unique message ID of the e-mail. This allowed us to have a special process for handling bounces in our software by using an SNS HTTP endpoint. So the SDK makes sense for use cases where the SMTP protocol doesn't provide enough information.

    • wiml 2 years ago

      Hm, many MTAs do return a unique queue ID when they accept a message over SMTP. Does SES not implement that?

      • sethammons 2 years ago

        Any examples? Curious how they do it. Just extra info in the 250 OK response to the DATA command?

        • meepmorp 2 years ago

          RFC 822 defines a Messsge-id header that the client can set, and most MTAs can be configured to add one if not set by the client. IIRC, they're supposed to be globally unique, but like so many things in email, ymmv.

          Edit: oh, yeah, there's also a queue id returned in the 250 response (in postfix, at least)

        • wiml 2 years ago

          Yeah, just in the text of the OK response. So I guess it isn't really very structured. Seems like it would be a useful ESMTP capability to add though - queue identifier and MTA-assigned message-ID.

    • mjl- 2 years ago

      Why would the Message-ID (that you assign) not work for this purpose? Perhaps the SNS notification doesn't include the message-id?

      • redditor98654 2 years ago

        SES does not allow the caller to set the id of the message and instead assigns one when you make the call.

        It is a bit painful for idempotency.

        • mjl- 2 years ago

          Interesting thanks. I can imagine that an email sending service wants to be in control of message-id's (would still be interesting to hear the actual rationale).

          Perhaps SMTP could use an extension with a new (pipelined) command after DATA, so a client can retrieve the assigned message-id.

          I wonder how common it is for message-id's to be overwritten. I must have run into this SES behaviour (along with other problems) when trying to use it as backup for outgoing mail for my mail server: My DKIM signatures include the message-id header, overwriting the header will invalidate them.

    • hardwaresofton 2 years ago

      Thanks for noting this, this is a pretty solid reason — I thought most people tried to correlate other fields on the incoming email but this also makes sense

  • rzzzt 2 years ago

    If you want to test SMTP mail delivery, there's MailCatcher: https://mailcatcher.me/

    • imankulov 2 years ago

      There are several alternatives. Most of them, including mailcatcher, seem to be unmaintained.

      Mailpit is an alternative that has regular updates: https://mailpit.axllent.org/

      • nickjj 2 years ago

        > Most of them, including mailcatcher, seem to be unmaintained.

        MailCatcher is great. It "just works" and has Docker images for both AMD64 and ARM64 CPUs.

      • nickcotter 2 years ago

        Thanks for the link - we’ve been using mailhog for local smtp testing and it still works ok for basic tasks, but it’s not maintained any more.

    • mjl- 2 years ago

      Pitching my own: https://github.com/mjl-/mox has a "mox localserve" subcommand that runs a mail server on localhost for testing, including a pedantic mode and special addresses that cause failure conditions you may want to test for. This is actually a full mail server (SMTP, IMAP and much more) and it comes with a webmail client. The "localserve" mode was just so easy to implement that I couldn't resist.

    • hardwaresofton 2 years ago

      Yeah thanks for this, I’ve been using it for years! Recently switched to mailslurper:

      https://github.com/mailslurper/mailslurper

  • meroje 2 years ago

    Can’t use an IAM role to auth to the bridge, it only works with user’s keys.

    • jjice 2 years ago

      That's a really great point. I was wondering the same thing as the comment root but this is enough for it to make sense. At the end of the day, having a wrapper email/notification class with an SMTP and moving to a specific SES implementation seems like it'll always be a safe dev path.

  • dharmab 2 years ago

    Not for production stuff, but for quick hacks I'll wire it up to SNS and send emails via SNS queue.

  • stephenr 2 years ago

    In theory you get higher effective sending rates, however I've not actually proven how much faster in practice.

isuckatcoding 2 years ago

You should get this merged into awslocal

Edit: uh never mind https://docs.localstack.cloud/user-guide/aws/ses/

ac2u 2 years ago

Someone needs to invent a protocol for transferring mail and make it simple.

traceroute66 2 years ago

Why would I use this instead of the AWS SES Simulator ? [1]

[1] https://docs.aws.amazon.com/ses/latest/dg/send-an-email-from...

  • stephenr 2 years ago

    > For billing purposes, emails that you send to the Amazon SES mailbox simulator are the same as any other email you send using Amazon SES. In other words, we bill you the same amount for messages that you send to the mailbox simulator as for those that you send to regular recipients.

    • traceroute66 2 years ago

      Fair enough, I didn't know SES simulator was only zero-affecting for stats and quotas.

      However then surely this thing is just re-inventing the wheel that LocalStack already invented ?

oblio 2 years ago

Somewhat offtopic, but is there a simple email service in the sense of SMTP + IMAP/POP + simple email web interface to use AWS as a end-user email service?

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection