So, I'd like to send email from my server.
I installed mailx
apt-get install mailx
But a command like
mail -s "Hello world" [email protected]
Is actually giving an error in /var/spool/mail/ which says:
Mailing to remote domains not supported.
Why is that happening?
What MTA are you using locally?
mail
just gives you the ability to form a mail message, but you still need and MTA to do the actual delivery? By default, most distributions come with sendmail. You'll likely need to install another MTA or configure the current one to support outside delivery.It would appear that Debian may come with an
exim4
that's set to not work correctly on an internet-connected machine where the outgoing smtp ports aren't blocked.As pointed out in various comments, to make it work correctly, one has to run
dpkg-reconfigure exim4-config
, and within the wizard, select the firstinternet
option. Note that in subsequent dialogue boxes within the wizard, the defaults are still set to only listen onlocalhost
IPv4/IPv6 addresses, so, it appears that, if you leave the other defaults alone, you're still leaving the incoming SMTP port alone.To verify the wizard worked correctly, you can check the Debian-specific
/etc/exim4/update-exim4.conf.conf
(yes, it's a double.conf.conf
, that's not a typo), which plays a part in this fiasco. Here's the relevant parts after runningdpkg-reconfigure exim4-config
and only changing the first option within the wizard, which enables sending mail, but keeps the SMTP port open only to the machine itself (a default option if you just click-through in the reconfig after the first option):Another solution would be to install DragonFly Mail Agent in jessie and up — https://packages.debian.org/jessie/dma — which is a simple implementation of a MTA, implementing all the good UNIX mail things except for incoming SMTP, so, you don't have to worry about misconfiguration or external vulnerabilities.
Because mailx expects a full SMTP infrastructure, which is not configured by default. What kind of SMTP server, if any, do you have installed (i.e. postfix, exim, sendmail, qmail)?
If you don't have an internal SMTP server installed you could send your mail for example through a gmail SMTP server, you can install sSMTP MTA and configure it with gMail SMTP Server, or another external SMTP server.