7

I have several servers running applications on debian. Each has the packages it requires for the application, and no more.

Currently, none have mail sending capability. However, I would like the output of tools like cron to be mailed to me.

The servers are hosted at an ISP site that provides a 'smart relay' server I should use for all outbound mail.

How should I configure my debian servers:

  • To permit local tools like cron to send mail, as something like automaton@example.com (I specifically do not want 'root@machinename')
  • Not provide any inbound mail services
  • Use the ISP's provided 'smart relay' for outbound mail

What package is good for such a 'minimal' mail service?

8 Answers 8

7

Similar to this answer, but I prefer to set exim to use a smarthost and have no local mail when the box isn't actually acting as a mail server.

  • apt-get install exim4
  • Run dpkg-reconfigure exim4-config
    • Yes, split the configs
    • verify the system name is correct
    • The listen address should be '127.0.0.1'
    • Other destinations should be the systems fqdn
    • Domains to relay for should be left empty
    • Machines to relay for should be left empty
    • smarthost should be the hostname of your smtp server
  • Update the /etc/aliases and point root at the email address I want service messages to be delievered too.
7

You want ssmtp, a super simple, really trivial to configure outbound mail relay. It's also very tiny, so suitable for embedded systems.

1
  • This! - if all you need is for a server to send out an email via smtp, ssmtp works very well, and is super simple to configure.
    – snemarch
    Apr 1, 2015 at 22:21
5

Such a configuration is called a 'nullclient' configuration. Some guides are available:

For sendmail, all you should need it:

FEATURE(`nullclient', `mailhub.domain.notused')dnl

Some distros (openSuSE) provide a separate 'nullclient.mc' configuration file for this purpose.

0
3

You have several choices for send-only mailers. ssmtp was already mentioned, but msmtp and nbsmtp will also get the job done.

2

I like to use exim, it's really easy to setup quickly on Debian. Run the following commands, when prompted with exim4-config select 'internet site' as the primary configuration. All other options are fairly self explanatory, make sure the domain names are setup properly to match forward and preferentially reverse dns.

sudo aptitude install exim4
sudo dpkg-reconfigure exim4-config

Then, edit /etc/aliases to look like:

root: your.email@example.net

Finally run newaliases to make mailing the root work (for cron etc)

sudo newaliases

Now you should be able to do something like

$mail root
Subject: Hello
What a fine day!
.
Cc: 

Update: I tested this with etch, not lenny, on an already configured install, I've corrected the errors above. No idea on what lenny does. This also works on ubuntu 8.04. Also I updated this to reflect that you do need to set domains properly

2
  • Are you sure the configuration is correct. On my current lenny install, the following are offered: internet site; mail is sent and received directly using SMTP mail sent by smarthost; received via SMTP or fetchmail mail sent by smarthost; no local mail local delivery only; not on a network no configuration at this time The third sounds nearer to what I think I want... May 7, 2009 at 17:57
  • Additionally, most of the defaults suggested were machinename.example.com where I think I want example.com May 7, 2009 at 18:00
1

On Debian, the Postfix package, when installed, ask you for the basic configuration. The "satellite" option is probably what you're after.

Please select the mail server configuration type that best meets your needs.  │ 
            │                                                                               │ 
            │  No configuration:                                                            │ 
            │   Should be chosen to leave the current configuration unchanged.              │ 
            │  Internet site:                                                               │ 
            │   Mail is sent and received directly using SMTP.                              │ 
            │  Internet with smarthost:                                                     │ 
            │   Mail is received directly using SMTP or by running a utility such           │ 
            │   as fetchmail. Outgoing mail is sent using a smarthost.                      │ 
            │  Satellite system:                                                            │ 
            │   All mail is sent to another machine, called a 'smarthost', for delivery.    │ 
            │  Local only:                                                                  │ 
            │   The only delivered mail is the mail for local users. There is no network.   │ 
            │                                                                               │ 
            │ General type of mail configuration:                                           │ 
            │                                                                               │ 
            │                            No configuration                                   │ 
            │                            Internet Site                                      │ 
            │                            Internet with smarthost                            │ 
            │                            Satellite system                                   │ 
            │                            Local only            
1

I think the most minimalistic package you'll find is nullmailer. Don't know much about it myself, but seems to be exactly what you're looking for. The debian package is called simply nullmailer. From the package description:

Description: simple relay-only mail transport agent
 Nullmailer is a replacement MTA for hosts, which relay to a fixed set of smart
 relays. It is designed to be simple to configure and especially useful on slave
 machines and in chroots. 

 The sendmail interface of this package doesn't provide the -bs switch, hence
 it's not LSB compatible!
Homepage: http://untroubled.org/nullmailer/

As I said, i don't know much about it, for me it just worked, pretty much out of the box, with some very minor configuration (like a mail address..).

0

I think you can run sendmail in some sort of submit-only mode, which means that all mail is forwarded to the smart relay (I think). Haven't done it myself as I've been using postfix for ages.

You could run a local instance of postfix and get it to relay all email to the other server you want to read the mail from.

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.