Ressources documentaires pour Mandriva Linux et les Logiciels Libres

Billets libellés procmail

How to configure local mail delivery

I have a separate server which hosts my database. Each night, a cron script is run to dump the databases contents and rsynced the backups to another server. The backup script will log the backup in /var/log, but also send a mail. Most of the time I’m using ssmtp to use my ISP SMTP server as a relay. However my database server most of the time is not connected to internet ( and this on purpose ). This is where the issue comes : ssmtp doesn’t allow local mail delivery 🙁 Even stranger, by default local mail delivery seems to not work at all in a default Mandriva installation 🙁

To handle local mail delivery, you need a local Mail Delivery Agent ( MDA ), and your Mail Transfert Agent ( MTA ) should called the local MDA to deliver local mails. So here are 2 methods to handle local mail delivery.

Using SENDMAIL

The easiest to have local mail delivery is to install … sendmail. Just install sendmail package and start the corresponding service, and your are done.

  • Install sendmail package : [bash light= »true »]urpmi sendmail[/bash]

  • Check that sendmail is used to provide send command : [bash light= »true »]update-alternatives –display sendmail-command[/bash]

  • If this is not the case, instruct update-alternative to use sendmail : [bash light= »true »]update-alternatives –config sendmail-command[/bash]

  • Start the sendmail service : [bash light= »true »]service sendmail restart[/bash]

Using ESMTP

Another way is to use ESMTP. i do advised to use ESMTP because it allow to configure easily a SMTP relay host, and handle also local delivery. However by default, ESMTP is not usable in default Mandriva configuration as it will not install a local MDA ( mdv bug #56759 ) and does not provide a default system-wide configuration file ( mdv bug #56757 ). So here his the procedure for a very simple ESMTP configuration which handle a SMTP relay and local mail delivery :

  • Install esmtp and procmail packages : [bash light= »true »]urpmi esmtp procmail[/bash]

  • Check that esmtp is used to emulate sendmail : [bash light= »true »]update-alternatives –display sendmail-command[/bash]

  • If this is not the case, instruct update-alternative to use esmtp : [bash light= »true »]update-alternatives –config sendmail-command[/bash]

  • Once done, create an empty system-wide configuration file for esmtp : [bash light= »true »]touch /etc/esmtprc[/bash]

  • If you want to configure a SMTP relay host to send mails outside, add the hostname option followed by the SMTP address in /etc/esmtprc. For example :
    # The place where the mail goes. The actual machine name is required
    # no MX records are consulted. Commonly mailhosts are named mail.domain.com
    hostname = smtp.myisp.com:25
    
  • Now add support to procmail as local MDA for local mail delivery by setting the mda option in /etc/esmtprc :
    # Use procmail as MDA for local mail delivery
    mda "/usr/bin/procmail -d %T"
    
Testing you local mail delivery setup

Now that sendmail or ESMTP are configured, you should test if local mail delivery is working correctly. The easiest way is to use the mail command to send, but also read your local mails. For example to send a mail containing the content of /etc/nsswitch.conf to the root user, just type : [bash light= »true »]mail -v -s "Local mail test" root < /etc/nsswitch.conf[/bash]

. Now log as root, and type mail to consult root mails. you may want to use Mutt eventually to read your mails instead of mail

Catégories

My Tweets