Tuesday, February 15, 2011

Configure exim4 internet site; mail is sent and received directly using SMTP

This option of exim4 let you configure SMTP server for your domain.
  • SMTP host FQDN: mail1.dev.local, ip: 192.168.10.11
  • Domain: dev.local, serves emails like user1@dev.local
  • Delivery mode: Maildir
  • Mail location: /var/mail/<user>
Here are few simple steps to configure:
  1. Let install the 'heavy' version of exim4:
    apt-get -y install exim4-daemon-heavy
    
  2. The easiest way is to reconfigure exim4-config package:
    dpkg-reconfigure exim4-config
    
  3. General type of mail configuration:
       internet site; mail is sent and received directly...
    System mail name:
       dev.local
    IP-addresses to listen on for incoming SMTP connections:
       192.168.10.11
    Other destinations for which mail is accepted:
       dev.local
    Domains to relay mail for:
    
    Machines to relay mail for:
       192.168.10.0/24
    Keep number of DNS-queries minimal (Dial-on-Demand)?
       No
    Delivery method for local mail:
       Maildir format in home directory
    Split configuration into small files?
       Yes
    
  4. Since we want to change default Maildir delivery to /var/mail/<user>, let add our custom local delivery rule (file /etc/exim4/update-exim4.conf.conf):
    #dc_localdelivery='maildir_home'
    dc_localdelivery='maildir_spool'
    
  5. Consider disable IPv6 (file /etc/exim4/update-exim4.conf.conf):
    disable_ipv6='true'
    
  6. Make a copy of existing Maildir rule file:
    cp /etc/exim4/conf.d/transport/30_exim4-config_maildir_\
    {home,spool}
    
  7. Change configuration for maildir_spool transport (file /etc/exim4/conf.d/transport/30_exim4-config_maildir_spool):
    ### transport/30_exim4-config_maildir_spool
    #################################
    
    maildir_spool:
      debug_print = "T: maildir_spool for $local_part@$domain"
      driver = appendfile
      .ifdef MAILDIR_HOME_MAILDIR_LOCATION
      directory = MAILDIR_HOME_MAILDIR_LOCATION
      .else
      directory = /var/mail/$local_part
      .endif
      .ifdef MAILDIR_HOME_CREATE_DIRECTORY
      create_directory
      .endif
      .ifdef MAILDIR_HOME_CREATE_FILE
      create_file = MAILDIR_HOME_CREATE_FILE
      .endif
      delivery_date_add
      envelope_to_add
      return_path_add
      maildir_format
      .ifdef MAILDIR_HOME_DIRECTORY_MODE
      directory_mode = MAILDIR_HOME_DIRECTORY_MODE
      .else
      directory_mode = 0700
      .endif
      .ifdef MAILDIR_HOME_MODE
      mode = MAILDIR_HOME_MODE
      .else
      mode = 0600
      .endif
      mode_fail_narrower = false
      current_directory = /var/mail
      group = mail
    
  8. Restart exim4:
    /etc/init.d/exim4 restart
    
Let verify it is working:
echo "test message" | mail -s "test" user1
... exim4 log (file /var/log/exim4/mainlog):
1PpRQR-0002Rz-1m <= root@dev.local U=root P=local S=460
1PpRQR-0002Rz-1m => user1  R=local_user T=maildir_spool
1PpRQR-0002Rz-1m Completed
At this point user1 should be able to receive your test message.

No comments :

Post a Comment