Hacker News new | ask | show | jobs
by wdewind 2445 days ago
Not OP but I've spent a lot of time setting up email sending for SaaS apps. It shouldn't be too difficult, just use a third party provider like sendgrid and make sure your DKIM and SPF records are setup properly and you should be good to go. I've also used stuff like Amazon SES and it's not worth the trouble for side projects (or even medium sized, real businesses, honestly). If you have specific questions feel free to ask.
2 comments

Hey there -

How would I setup a "native" email system. I don't want to use some third party that I have to pay for. I'd like to be able to send the "raw" email myself.

So for example my current system uses Java + GMail's SMTP server. I have to pass it a username+password, and I can send basic emails that way. There are at least 2 major problems with this setup:

1) So far, all I have done is send REALLY basic 100% test based emails. It's not exactly clear to me how I would send a fully baked HTML email.

2) Consistently GMail BLOCKS my username. It requires me to manually go in at least every few days and enable "Allow less secure applications"

Basically you don't. It's a really big challenge to create a consistently non-blocked email sending service, especially if you host on a big cloud provider like AWS.

Sounds like you are using the Gmail API. To be honest that's not really fit for sending transactional emails, and is increasingly unfit for 3rd party consumption due to API restrictions.

Sendgrid also has a free tier that may work for your use case if the app is for a very limited audience, other than that you're kind of asking "how do I get something really difficult for free?"

Well, how does Sendgrid do it?
Sendgrid uses a mail transfer agent like Postfix or PowerMTA (I don't actually know what they use but I wouldn't be surprised if it was PowerMTA) to talk to receiving email servers via SMTP.

It's not hard to set up the technical bits to send email. You basically just need to run an MTA that knows how to stamp your outgoing messages with DKIM (a cryptographic signature). Your server has to have an SSL certificate. You also need SPF records set up that accurately reflect what servers are allowed to send on your behalf. DMARC records are helpful as well but not required. If you're only sending as yourself, that's basically it. You should be able to get mail through to the big receivers without much trouble (maybe having to mark "not spam" a few times to start).

The trick to maintaining your sending reputation as an individual is to not send email for anyone else and never send content that you don't control. Sendgrid sends for other people and they have people on staff who's full time job is to fight with the big receivers to maintain their reputation.

Sendgrid puts a huge amount of money and resources into maintaining both technical and political legitimacy. They have relationships with other major senders and receivers of email, they follow every single rule to the T, they aggressively police their own IPs (of which they have many) etc. It's a complicated business, which is why it's totally worth it to pay them to do it for you.
Funny how its a common refrain on HN that email is the one true decentralized communication protocol, and yet...
Yes there is a real lesson about the pragmatic impossibility of true decentralization in email. Specialization of labor is a useful thing, it turns out.

That being said: the fact that is a protocol and not a proprietary standard does have decentralizing effects that do provide a useful incentive check against providers, even if there are only a few of them. There is also a real lesson there too, that one I'll leave for the reader.

Create an app password [0], and then use something like ssmtp for sending the mail.

Your app then then just call out to ssmtp, passing in the relevant mail information (to, from, subject, message, etc).

0: https://support.google.com/accounts/answer/185833?hl=en

(Email noob here) I'm writing a very low traffic web app, and I was thinking about SES, mostly because it's free for small volumes. What's wrong with it? Would you recommend sendgrid (or something else) instead?
I recently set up SES for my own projects so some this info is fresh in my mind. I’m not an SES power user so ymmv.

My only real, big issue with SES is with email templates as in I don’t know of any way to view templates in SES.

So, if you create an email template and want to preview it, you’ll have to do it locally/off-SES. If you need to handle hundreds of templates, this can get tedious.

The other minor tech issue is that SES needs you to work out of one of three regions - US east, west, and EU (if I recall correctly).

If, for legal or hygiene purposes you need your data anywhere else in the world, you’re SOL.

Other than these two, SES has been amazing. It costs pennies and I host all my email, both transactional and personal, with them. Worth noting that my transactional email is in the order of a few hundred per month, if that.

I’m a little biased (being the CEO) but check out EmailOctopus. We connect to Amazon SES and if you've got fewer than 2,500 contacts/subscribers you'll be on our free tier.

https://emailoctopus.com/amazon-ses

My experience has just been that SES is a little less user friendly to setup and debug. It's not a huge deal, you'll probably be fine.