@pichalite I didn't know about this feature! Thank you for pointing that out to me, that is great! I totally agree with your point made above then 🙂
NodeBB Email - Options
Initial draft for gotwf nodebb email how-to two cents worth. Confusion over email seems to be a recurring issue so I thought I'd take a stab at culling and consolidating the salient bits. Caveat emptor.
tl;dr: NodeBB recommends using a third party emailer like Sendgrid because they have better deliverability. And so do I. At least if you're coming at this looking to get NodeBB sending email with the least amount of effort.
NodeBB Email Options
NodeBB Offers Several Ways to Send Email:
Emailer plugins: There are a few plugins like the MailChimp plugin which operate directly with various email providers. I'll leave configuration of such to their respective plugin documentation.
SMTP transport: NodeBB has built-in support for SMTP, so you can use a Gmail account for instance to email your users. This is pretty self explanatory. Season details to scratch your provider's itches.
Sendmail: NodeBB supports using sendmail on Linux to send emails. To do this you just turn off the SMTP transport and make sure no email plugins are enabled.
sendmail, the executable, will send mail via a variety of transports.
man sendmail(8) speaketh thusly:
Sendmail sends a message to one or more recipients, routing the message over whatever networks are necessary. Sendmail does internetwork forwarding as necessary to deliver the message to the correct place.
..... snip, snip.....
With no flags, sendmail reads its standard input up to an end-of-file or a line consisting only of a single dot and sends a copy of the message found there to all of the addresses listed. It determines the network(s) to use based on the syntax and contents of the addresses.
If the recipient is not known locally, i.e. a local user/domain, then the server's resolver subsystem should, (contingent upon configuration) return the MX record for the domain at hand and attempt a delivery. Whether or not that MX accepts your mail is at the mercy of their assessment of your server's legitimacy. At minimum you will need matching forward and reverse DNS enteries, and likely an SPF record, for example. Others will automatically put you on their blacklist even if your stuff is squeaky clean and require a near act of god to be removed.
Handling of refused, bounced, etc. mail is, once again, contingent upon configuration. One should ensure their mail queues do not become constipated to the extent undeliverable mail exhausts disk space, thereby effectively creating a DOS.
One may also run a MX daemon such as Postfix on their NodeBB host. Running as a daemon has advantages for certain use cases. In which case, I recommend deploying Postifx as a Null Client. Quoting from preceeding:
A null client is a machine that can only send mail. It receives no mail from the network, and it does not deliver any mail locally.
One must therefore have some OTHER, supplementary MX that will receive mail for your domain. Else opt for a more complex Postfix configuration.
Example screenshot NodeBB side utilizing Postfix Null Client running on the local host and listening on port 25:
Selecting the Custom Service pull down may seem counter intuitive but this is the option you need to populate parameters for your localhost null client.
Connection security should be None. Else if you invoke STARTTLS NodeBB side then of course Postfix will endeavor to oblige (depending on config). I am of the opinion that if you need TLS for the localhost to talk to itself then you likely have much larger concerns. Username and Password should not be necessary for local submission.
Conversely, it is highly advisable to use TLS when talking to external SMTP servers. Free certificates are available thru Let's Encrypt. Numerous Acme Clients are available. I favor Dehydrated Boulders
This approach also requires configuration of additional cogs and widgets such as matching forward and reverse DNS enteries and likely an SPF record, for example, that are beyond scope of the present discussion.
Note: Postfix was designed to be a drop in replacement for Sendmail and many Linux distributions include it as part of their default installs. In which case the sendmail executable mentioned above may be Postfix's version, or perhaps be a symlink. This can cause confusion with Options 3 and 4 above so if you're running into issues please clarify when running as a daemon.
Something seemingly simple at first blush can pose more than a few sticky wickets and why I recommend following @julian et.al.'s advice and opt for the low hanging fruits offered by the first two options. Unless you have a clear use case not to. Learning how to do all of this stuff is a legitmate use case. Just be forewarned that you may experience a bit of trial by fire if you are learning the zen of email administration on a production system.
@gotwf Excellent! Thanks for writing this up. It very thoroughly explains our reasoning and suggestions to use third-party emailers
@julian You're welcome and thank you for the kind words.