Post on 25-Feb-2016
description
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Popular MTAsEXIM & POSTFIX
SPARCS 10 이대근 (harry)
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
MTA
Mail Transfer Agent
Message Transfer Agentor
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Let’s recall…
MTA MTA
MUA (ex: outlook express) MUA
그냥 새
MDA : Mail 우편함
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
With MTA you can…
• Send and receive an email, of course– To users of your machine, without ISP– To other mail servers, you need connection to internet
• Fetch emails from POP3 server– using fetchmail
• Receive emails in right place– Using procmail
• Get messages from some programs via e-mail– Log files or security warnings can be delivered to your email
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
A Lot of MTAs
AndQmail, Courier, Smail, MMDF…
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
EXIMEXperimental Internet Mailer
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
EXIM
• One of the most popular MTAs• Default MTA for Ubuntu• SPARCS server
• GPL• Flexible, extensible• Good compatibility with Sendmail
• Latest stable release: 4.72 (2010/06/03)
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
How EXIM delivers mails?
Internet
SMTP(25)Daemon
Mail server
SpoolReceiver
Queue runner
DeliveryRemoteDelivery
LocalDelivery Mailbox
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Message ID
1OROMT-0003j0-6G
The time at which the message started to be received. The number of sec-onds since the start of the epoch.
Time Process IDID of the process which received the message.
TimeFractional part of the time of recep-tion. The unit may be 1/2000 sec, 1/1000 sec, 1/200 sec or 1/100 sec.
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Command line options
# exim [options] [arguments]
––helpDisplays help message
–bdRuns exim as a daemon, awaiting incoming SMTP connections from all available interfaces. Usually used with option –q.
–qStarts one queue runner process. Time specifications start queue runner periodically. (–q30m for starting every 30 minutes)
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Command line options
# exim [options] [arguments]
–Mc <message id> <message id> …Deliver messages in turn. Usually called internally by queue runner.
–C <filelist>Find configuration files in <filelist> and apply them instead of de-fault configuration file specified by CONFIGURE_FILE.
–bP <option name> <option name> …Print the current configuration to standard output.
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Let’s see SPARCS server
[21:56:58]harry@sparcs:~$ ps aux | grep exim102 2563 0.0 0.0 13344 1332 ? Ss Jul01 0:02 /usr/sbin/exim4 -bd -q30mRoot 17964 0.0 0.2 13588 3680 ? S 18:14 0:00 /usr/sbin/exim4 -Mc 1OXW93-0004fL-QH102 17966 0.0 0.1 13588 2056 ? S 18:14 0:00 /usr/sbin/exim4 -Mc 1OXW93-0004fL-QH102 17976 0.0 0.0 13352 896 ? S 18:14 0:00 /usr/sbin/exim4 -bd -q30m
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Configuring EXIM
• EXIM configuration file is divided into 6 parts– ACL: Access control list for controlling incoming SMTP mails– Authenticators: Settings for authenticator drivers– Routers: Determines how the messages is to be delivered– Transports: Defines the mechanisms how the messages are to be
copied– Retry: Rules for use when the message cannot be delivered imme-
diately– Rewrite: Global address rewriting rules– Local_scan: Private options for local_scan() function
Difficult?
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
/etc/exim4/update-exim4.conf.conf
[21:56:58]harry@sparcs:/etc/exim4$ cat update-exim4.conf.conf# /etc/exim4/update-exim4.conf.conf## Edit this file and /etc/mailname by hand and execute update-exim4.conf# yourself or use 'dpkg-reconfigure exim4-config'## Please note that this is _not_ a dpkg-conffile and that automatic changes# to this file might happen. The code handling this will honor your local# changes, so this is usually fine, but will break local schemes that mess# around with multiple versions of the file.## update-exim4.conf uses this file to determine variable values to generate# exim configuration macros for the configuration file.## Most settings found in here do have corresponding questions in the# Debconf configuration, but not all of them.## This is a Debian specific file
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
/etc/exim4/update-exim4.conf.conf
dc_eximconfig_configtype='internet'dc_other_hostnames='sparcs.org;sparcs.net;143.248.234.102'dc_local_interfaces=''dc_readhost=''dc_relay_domains=''dc_minimaldns='false'dc_relay_nets=''dc_smarthost=''CFILEMODE='644'dc_use_split_config='true'dc_hide_mailname=''dc_mailname_in_oh='true'dc_localdelivery='maildir_home'
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
/etc/exim4/update-exim4.conf.conf
dc_eximconfig_configtype='internet'
dc_eximconfig_configtype : The main configuration type.
‘local’: Mails are sent and received between the accounts of local machine‘internet’: Configure as a general email server connected to internet‘satellite’: Sends mail to another machine(smarthost)‘smarthost’: Intermediates email
Sets macro DC_eximconfig_configtype.
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
/etc/exim4/update-exim4.conf.conf
dc_other_hostnames='sparcs.org;sparcs.net;143.248.234.102'
dc_other_hostnames : List of domains of mails that the server will finally accept
Multiple values can be set, separated by colon(:).
Mails delivered to harry@sparcs.org, harry@sparcs.net, har-ry@143.248.234.102 will be passed from daemon process to receiver process.
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
/etc/exim4/update-exim4.conf.conf
dc_local_interfaces=''
dc_local_interfaces : List of IPs for daemon to listen on
Multiple values can be set, separated by colon(:).
Empty string means all interfaces.
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
/etc/exim4/update-exim4.conf.conf
CFILEMODE='644'
CFILEMODE : The octal file mode of the generated file
Sets the mode of the files that are generated by update-exim4.conf.
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
/etc/exim4/update-exim4.conf.conf
dc_use_split_config='true'
dc_use_split_config : Defines whether it uses split configuration files
‘true’: Uses multiple files below /etc/exim4/conf.d‘false’: Uses single file /etc/exim4/exim4.conf.template
dc_localdelivery='maildir_home'
dc_local_delivery : Name of default transport directory
‘’ or ‘mail_spool’: Mails are delivered to spool by default‘maildir_home’: Mails are delivered to ~/Maildir/ by default
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Update configuration
# update-exim4.conf –d /etc/exim4 –o /etc/exim4/exim4.conf
Automatically generates configuration files.
# /etc/init.d/exim4 restart
Restarts the daemon with new configuration.
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Log files
• /var/log/exim4/mainlog
• /var/log/exim4/rejectlog
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
POSTFIX
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
POSTFIX
• One of the most popular MTAs
• IBM Public License(free)
• Secure alternative to Sendmail• Able to handle large amounts of emails
• Latest stable release: 2.7.1 (2010/06/08)
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Installation
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
/etc/postfix/main.cf
[21:56:58]harry@sparcs:/etc/postfix$ cat main.cf# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first# line of that file to be used as the name. The Debian default# is /etc/mailname.myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)biff = no
# appending .domain is the MUA's job.append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings#delay_warning_time = 4h
readme_directory = no
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
/etc/postfix/main.cf
# TLS parameterssmtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pemsmtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.keysmtpd_use_tls=yessmtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scachesmtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for# information on enabling SSL in the smtp client.
myhostname = sparcsalias_maps = hash:/etc/aliasesalias_database = hash:/etc/aliasesmydestination = sparcs.org, sparcs.net, localhost.localdomain, , localhostrelayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128mailbox_size_limit = 0recipient_delimiter = +inet_interfaces = all
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
/etc/postfix/main.cf
# Debian specific: Specifying a file name will cause the first# line of that file to be used as the name. The Debian default# is /etc/mailname.myorigin = /etc/mailname
myorigin : Specifies the domain that appears in mail that posted on this machine.
/etc/mailname has sparcs.kaist.ac.kr in its first line, so specifying myorigin = /etc/mailname makes the sender of the mails outgoing from this machine like ‘harry@sparcs.kaist.ac.kr’.
myorigin = $mydomain is one of the most generally used set-tings.
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
/etc/postfix/main.cf
mynetworks_style = subnet
mynetworks_style : Specifies what kinds of clients to relay mail from.
host: Forwards mails from only the local machinesubnet: Forwards mail from the clients in the same subnetwork as the machineclass: Forwards mail from the clients in the same class as the ma-chine
If mynetworks_style is not set, you should specify the mynetworks list by hand.
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
/etc/postfix/main.cf
mydestination = sparcs.org, sparcs.net, localhost.localdomain, , localhost
mydestination : Specifies what domains this server will finally accept
Multiple values can be set, separated by commas(,).
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
/etc/postfix/main.cf
relayhost =
relayhost : Specifies the delivery method
(empty string): Deliver the mail directly to the internet$mydomain: Deliver mails via local mail server
inet_interfaces = all
inet_interfaces : Specifies what interfaces that daemon should listen on
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Update configuration
# postfix reload# /etc/init.d/postfix restart
Restarting postfix daemon will apply your new settings
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Log files
• /var/log/mail.log
• /var/log/mail.info• /var/log/mail.err• /var/log/mail.warn
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
ALIASES & FORWARDING
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Aliases
• Alias is a way to use a virtual mail account– If webmaster is an alias of harry, messages sent to webmas-ter@sparcs.org will be redirected to harry’s mailbox.
• Alias is an easy way to configure mailing list– If wheel-seminar is aliases of all members who participates in
wheel seminar, messages sent to wheel-seminar@sparcs.org will be redirected to their mailboxes.
• MTAs automatically reads alias database when the delivery process starts and deliver messages according to it.
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
/etc/aliases
• <alias> : <actual name>– webmaster : harry
• <alias> : :include:<file name>– wheel-seminar : :include:/SPARCS/mail/aliases.d/wheel-seminar– Files is just a list of usernames separated by newlines.
• We have a good tool: edalias
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
newaliases
• MTAs read /etc/aliases.db, not /etc/aliases.• You have to update database file after editing aliases files.
• # newaliases
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Forwarding
• Pass messages to other mail addresses
• If harry forwards his mails to harry@gmail.com, all mails sent to harry@sparcs.org will be delivered to harry@gmail.com, in fact.
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Settings
• Alias– harry : harry@gmail.com
• /home/harry/.forward– harry@gmail.com
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Questions?
Syst
em P
rogr
amm
ers'
Asso
ciatio
n fo
r Res
earc
hing
Com
pute
r Sys
tem
s
Thank you!