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" me@gmail.com

Is actually giving an error in /var/spool/mail/ which says:

Mailing to remote domains not supported.

Why is that happening?

4 Answers 4


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.

  • 2
    From the logfile here, it looks like exim 4.69
    – bobobobo
    Aug 20, 2010 at 17:34
  • 9
    If you're running Debian/Ubuntu, you'll need to edit /etc/exim4/update-exim4.conf.conf and change the line to read dc_eximconfig_configtype='internet' and restart exim. If you're using another distro, make sure this line looks like this hostlist relay_from_hosts =
    – vmfarms
    Aug 20, 2010 at 17:43
  • 10
    Actually I used the dpkg-reconfigure exim4-config "wizard" command and it works now! Thanks!
    – bobobobo
    Aug 20, 2010 at 17:47
# fgrep remote /var/log/exim4/mainlog.1 | sed -E 's#([ <])[^ <]+@[^ >]+([ >])#\1a@b\2#g' | head -1
2019-01-08 00:47:00 1ggebk-00055M-St ** a@b <a@b> R=nonlocal: Mailing to remote domains not supported

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 first internet option. Note that in subsequent dialogue boxes within the wizard, the defaults are still set to only listen on localhost 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 running dpkg-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):

dc_local_interfaces=' ; ::1'

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)?

  • I believe I have exim
    – bobobobo
    Aug 20, 2010 at 17:34

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.