A word of warning to anyone building web apps: Be careful about requirements around “emails coming from the web app”. Here’s an example of why:
- I agreed that (on my open source real estate listing site) people could email listings to any recipient. Didn’t sound too hard, get an email provider, create an unauthenticated link to the listing, send it off! Right?
- First problem I noticed is that many domains won’t even accept email from new domains, they get flagged. There is no procedural way to get your new domain’s email accepted by all other domains in some rigorous fashion; it seems to be a combination of crafting the “right” MX record at the domain level and/or adding some other private key/value pairs, an obscure art form, and literally calling domain admins up or filing obscure tech support requests via some dusty automated system. Blame spammers, I guess.
- Then, they wanted custom body and signature, so I built in a rich-text editor for the body and added a rich-text signature area in their profile page. This was fun (shout-out to Quill), even if a bit out-of-spec.
- Then, they wanted multiple email recipients… It is at this point that you’ve now entered “reinventing a perfectly working email client” territory. The RFC describing the possible formatting for multiple email recipients is pretty insane, even if you love regex like me. So I nixed that.
- Now they want the sent-by to not be the owner of the listing, but the logged-in person viewing the listing (or have the option to choose).
At this point I think I want to literally DELETE all the email functionality and just create a
mailto: link that prepopulates the body with the “magic unauthenticated URL” for the listing (which of course cannot be styled, from what I understand).
And in hindsight, that’s probably the only thing I should have signed on to do. Then it would open up in whatever email client they already have installed, all domains would accept the email, and the “magic link” would be there. They would have their email client's email signature, and they could turn on styles for the body and add whatever other fanciment they want; cc anyone in their address book (with autocomplete!), etc. etc.
Heed my warning: Don't build an email client into your web app if you can at all avoid doing so.