1

I have been trying to use the unix mail command to send emails, but haven't been having much success. I wasn't getting any errors though so I checked my var/mail file and found a lot of these messages:

Mailing to remote domains not supported

That makes sense, because I haven't given it an SMTP server, but how do I do this? I read through the man mail page and didn't see anything that would help, and googling took me to this page which left me feeling confused and rather unintelligent.

Is there a guide for setting up smtp settings which is not too much harder than it should be?

6
  • That page seems to be about setting up a web server: nothing to do with email. Commented Aug 11, 2014 at 10:59
  • 2
    You need to configure your local email server e.g. Sendmail or Postfix. Commented Aug 11, 2014 at 11:10
  • What @CristianCiupitu said, though I think there are command line tools which will connect directly to a SMTP server to deliver your mail. Though going through a local server is better. For one thing, it keeps logs for you. Commented Aug 11, 2014 at 11:52
  • @FaheemMitha Yes there are (telnet for example), but a decent email server will block him. He will probably need to use a relay provided by his ISP or set up an MX record.
    – SailorCire
    Commented Aug 11, 2014 at 13:56
  • Oh, and for another, on failure it will attempt to resend mails periodically, though the exim mail queue at least seems to get into a "frozen" state rather easily. Commented Aug 11, 2014 at 14:42

2 Answers 2

0

Like others have said, you'll need to set up a local mail server (sendmail, postfix, or whatever is your preference).

My assumption is that you're doing this from your home and you get an IP that changes every so often. If this is the case, then you'll find other problems with sending email. A lot of servers will simply deny you because of your IP address (see spamhaus or others).

To get around this, you'll need a relay (or ideally, a static IP* and DNS). Your ISP may provide you with an relay (you may need to ask) at which point you'll simply add the following directives

If you're using sendmail:

 define(`SMART_HOST', `smtp.your.provider')dnl

If you're using postfix:

relayhost = smtp.your.provider

Where smtp.your.provider would be your relay host (this can be an IP as well).

Here are some guides for sendmail and postfix.

I use both; however, I think postfix is supposed to be easier and safer, but good practices it what really makes the difference. On Redhat-like systems (Fedora, CentOS, RHEL, Oracle, and so on) Sendmail seems to be default while others use Postfix.

*static IP isn't necessary, but makes life so much easier.

0

You can use Postfix, which is a widely used SMTP server and is also simple to set up for a testing environment. Here the Debian docs explain about Postfix. Also you can check different configurations on Postfix Docs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .