D.postfix

Last-modified: 2006-10-10 (火) 17:17:38
swisspc:~# apt-get install postfix
Reading Package Lists... Done
Building Dependency Tree... Done
Suggested packages:
 postfix-mysql postfix-pgsql postfix-ldap postfix-pcre
Recommended packages:
 resolvconf
The following packages will be REMOVED:
 exim4 exim4-base exim4-config exim4-daemon-light
The following NEW packages will be installed:
 postfix
0 upgraded, 1 newly installed, 4 to remove and 2 not upgraded.
Need to get 802kB of archives.
After unpacking 1118kB disk space will be freed.
Do you want to continue? [Y/n] y
Get:1 http://ftp.jp.debian.org stable/main postfix 2.1.5-9 [802kB]
Fetched 802kB in 1s (787kB/s)
Preconfiguring packages ...
Debian Configuration
 lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu Postfix Configuration tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
 x                                                                                     x
 x You have several choices for general configuration at this point.  If you have      #
 x your debconf priority set to 'low' or 'medium', you will be asked more questions    a
 x later.  You can always run "dpkg-reconfigure --priority=low postfix" at a later     a
 x point if you want to see these questions again.                                     a
 x                                                                                     a
 x No configuration - IF YOU WANT THE INSTALL TO LEAVE YOUR CONFIG ALONE, CHOOSE THIS  a
 x OPTION.  No configuration changes will be done now:  If you have not already        a
 x configured Postfix, your mail system will be broken and should not be used. You     a
 x must then do the configuration yourself by editing /usr/share/postfix/main.cf.dist  a
 x and saving your changes as /etc/postfix/main.cf, or by running dpkg-reconfigure     a
 x Postfix.  main.cf will not be modified by the Postfix install process.              a
 x                                                                                     a
 x Internet site - mail is sent and received directly using SMTP. If your needs don't  a
 x fit neatly into any category, you probably want to start with this one and then     a
 x edit the config file by hand.                                                       a
 x                                                                                     a
 x Internet site using smarthost - You receive Internet mail on this machine, either   a
 x directly by SMTP or by running a utility such as fetchmail. Outgoing mail is sent   a
 x using a smarthost. optionally with addresses rewritten. This is probably what you   a
 x want for a dialup system.                                                           a
 x                                                                                     a
 x Satellite system - All mail is sent to another machine, called a "smart host" for   a
 x delivery. root and postmaster mail is delivered according to /etc/aliases. No mail  a
 x is received locally.                                                                a
 x                                                                                     a
 x
 x                                       <Ok>
 x                                                                                     x
 mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

Debian Configuration

                          lqqqqu Postfix Configuration tqqqqqk
                          x General type of configuration?   x
                          x                                  x
                          x     No configuration             x
                          x     Internet Site                x
                          x     Internet with smarthost      x
                          x     Satellite system             x
                          x     Local only                   x
                          x                                  x
                          x                                  x
                          x      <Ok>          <Cancel>      x
                          x                                  x
                          mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

Debian Configuration

lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu Postfix Configuration tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x The user root (and any other users with a uid of 0) must have mail redirected via   x
x an alias, or their mail may be delivered to /var/mail/nobody.  This is by design:   x
x mail is not delivered to external delivery agents as root.                          x
x                                                                                     x
x If you already have a /etc/aliases file, then you possibly need to add this entry.  x
x  (I will only add it if I am creating a new /etc/aliases.)                          x
x                                                                                     x
x What address should I add to /etc/aliases, if I create the file?  (Enter NONE to    x
x not add one.)                                                                       x
x                                                                                     x
x Where should mail for root go                                                       x
x                                                                                     x
x swisspc____________________________________________________________________________ x
x                                                                                     x
x                       <Ok>                           <Cancel>                       x
x                                                                                     x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

Debian Configuration

lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu Postfix Configuration tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x Your `mail name' is the hostname portion of the address to be shown on outgoing     x
x news and mail messages (following the username and @ sign).                         x
x                                                                                     x
x This name will be used by other programs besides Postfix; it should be the single,  x
x full domain name (FQDN) from which mail will appear to originate.                   x
x                                                                                     x
x Mail name?                                                                          x
x                                                                                     x
x swisspc.info_______________________________________________________________________ x
x                                                                                     x
x                       <Ok>                           <Cancel>                       x
x                                                                                     x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

Debian Configuration

lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu Postfix Configuration tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x Give a comma-separated list of domains that this machine should consider itself     x
x the final destination for.  If this is a mail domain gateway, you probably want to  x
x include the top-level domain.                                                       x
x                                                                                     x
x Other destinations to accept mail for? (blank for none)                             x
x                                                                                     x
x swisspc.info, localhost.swisspc.info, localhost____________________________________ x
x                                                                                     x
x                       <Ok>                           <Cancel>                       x
x                                                                                     x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

Debian Configuration

lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu Postfix Configuration tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x                                                                                     x
x If synchronous updates are forced, then mail is processed more slowly. If not       x
x forced, then there is a remote chance of losing some mail if the system crashes at  x
x an inopportune time, and you are not using a journaled filesystem (such as ext3).   x
x                                                                                     x
x The default is "off".                                                               x
x                                                                                     x
x Force synchronous updates on mail queue?                                            x
x                                                                                     x
x                        <Yes>                           <No>                         x
x                                                                                     x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

(Reading database ... 25248 files and directories currently installed.)
Removing exim4 ...
dpkg: exim4-base: dependency problems, but removing anyway as you request:

exim4-daemon-light depends on exim4-base (>= 4.50).

Removing exim4-base ...
Stopping MTA: exim4.
Removing exim4-config ...
dpkg: exim4-daemon-light: dependency problems, but removing anyway as you request:

at depends on mail-transport-agent; however:
 Package mail-transport-agent is not installed.
 Package exim4-daemon-light which provides mail-transport-agent is to be removed.
mailx depends on exim4 | mail-transport-agent; however:
 Package exim4 is not installed.
 Package mail-transport-agent is not installed.
 Package exim4-daemon-light which provides mail-transport-agent is to be removed.
mutt depends on exim4 | mail-transport-agent; however:
 Package exim4 is not installed.
 Package mail-transport-agent is not installed.
 Package exim4-daemon-light which provides mail-transport-agent is to be removed.

Removing exim4-daemon-light ...
Stopping MTA: exim4.
Selecting previously deselected package postfix.
(Reading database ... 25128 files and directories currently installed.)
Unpacking postfix (from .../postfix_2.1.5-9_i386.deb) ...
Setting up postfix (2.1.5-9) ...
Adding group `postfix' (105)...
Done.
Adding system user `postfix'...
Adding new user `postfix' (103) with group `postfix'.
Not creating home directory.
setting synchronous mail queue updates: false
Creating /etc/postfix/dynamicmaps.cf
Adding tcp map entry to /etc/postfix/dynamicmaps.cf
Adding group `postdrop' (106)...
Done.
setting myhostname: swisspc.swisspc.info
setting alias maps
setting alias database
changing /etc/mailname
setting myorigin
setting destinations: swisspc.info, localhost.swisspc.info, localhost
setting relayhost:
setting mynetworks: 127.0.0.0/8
setting mailbox_command
setting mailbox_size_limit: 0
setting recipient_delimiter: +
setting inet_interfaces: all

Postfix is now set up with a default configuration. If you need to make
changes, edit
/etc/postfix/main.cf (and others) as needed. To view Postfix configuration
values, see postconf(1).

After modifying main.cf, be sure to run '/etc/init.d/postfix reload'.

Running newaliases
Starting mail transport agent: Postfix.

swisspc:~# apt-get install dovecot
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:

 dovecot-common dovecot-imapd dovecot-pop3d libmysqlclient12 libpq3 mysql-common
 openssl

Suggested packages:

 postgresql-doc postgresql-client ca-certificates

The following NEW packages will be installed:

 dovecot dovecot-common dovecot-imapd dovecot-pop3d libmysqlclient12 libpq3
 mysql-common openssl

0 upgraded, 8 newly installed, 0 to remove and 2 not upgraded.
Need to get 2179kB of archives.
After unpacking 4919kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ftp.jp.debian.org stable/main mysql-common 4.0.24-10sarge2 [34.6kB]
Get:2 http://ftp.jp.debian.org stable/main libmysqlclient12 4.0.24-10sarge2 [297kB]
Get:3 http://security.debian.org stable/updates/main openssl 0.9.7e-3sarge4 [906kB]
Get:4 http://ftp.jp.debian.org stable/main libpq3 7.4.7-6sarge3 [128kB]
Get:5 http://ftp.jp.debian.org stable/main dovecot-common 0.99.14-1sarge0 [245kB]
Get:6 http://ftp.jp.debian.org stable/main dovecot-imapd 0.99.14-1sarge0 [293kB]
Get:7 http://ftp.jp.debian.org stable/main dovecot-pop3d 0.99.14-1sarge0 [268kB]
Get:8 http://ftp.jp.debian.org stable/main dovecot 0.99.14-1sarge0 [7516B]
Fetched 2179kB in 8s (265kB/s)
Selecting previously deselected package mysql-common.
(Reading database ... 25268 files and directories currently installed.)
Unpacking mysql-common (from .../mysql-common_4.0.24-10sarge2_all.deb) ...
Selecting previously deselected package libmysqlclient12.
Unpacking libmysqlclient12 (from .../libmysqlclient12_4.0.24-10sarge2_i386.deb) ...
Selecting previously deselected package libpq3.
Unpacking libpq3 (from .../libpq3_7.4.7-6sarge3_i386.deb) ...
Selecting previously deselected package openssl.
Unpacking openssl (from .../openssl_0.9.7e-3sarge4_i386.deb) ...
Creating directory /etc/ssl
Selecting previously deselected package dovecot-common.
Unpacking dovecot-common (from .../dovecot-common_0.99.14-1sarge0_i386.deb) ...
Selecting previously deselected package dovecot-imapd.
Unpacking dovecot-imapd (from .../dovecot-imapd_0.99.14-1sarge0_i386.deb) ...
Selecting previously deselected package dovecot-pop3d.
Unpacking dovecot-pop3d (from .../dovecot-pop3d_0.99.14-1sarge0_i386.deb) ...
Selecting previously deselected package dovecot.
Unpacking dovecot (from .../dovecot_0.99.14-1sarge0_all.deb) ...
Setting up mysql-common (4.0.24-10sarge2) ...
Setting up libmysqlclient12 (4.0.24-10sarge2) ...

Setting up libpq3 (7.4.7-6sarge3) ...

Setting up openssl (0.9.7e-3sarge4) ...

Setting up dovecot-common (0.99.14-1sarge0) ...
Creating generic self-signed certificate: /etc/ssl/certs/dovecot.pem
(replace with hand-crafted or authorized one if needed).

Setting up dovecot-imapd (0.99.14-1sarge0) ...

Setting up dovecot-pop3d (0.99.14-1sarge0) ...

Setting up dovecot (0.99.14-1sarge0) ...
swisspc:~#

DebianライクUbuntuのインストール
Postfix/POP3/IMAP

In order to install Postfix with SMTP-AUTH and TLS as well as a POP3 server that also does POP3s (port 995) and an IMAP server that is also capable of IMAPs (port 993) do the following steps:

apt-get install postfix postfix-tls libsasl2 sasl2-bin libsasl2-modules ipopd-ssl uw-imapd-ssl (1 line!)

  • pop3 and pop3s
  • No
  • Internet Site
  • NONE
  • server1.example.com
  • server1.example.com, localhost.example.com, localhost
  • No

postconf -e 'smtpd_sasl_local_domain ='
postconf -e 'smtpd_sasl_auth_enable = yes'
postconf -e 'smtpd_sasl_security_options = noanonymous'
postconf -e 'broken_sasl_auth_clients = yes'
postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'
postconf -e 'inet_interfaces = all'
echo 'pwcheck_method: saslauthd' >> /etc/postfix/sasl/smtpd.conf
echo 'mech_list: plain login' >> /etc/postfix/sasl/smtpd.conf

mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024
chmod 600 smtpd.key
openssl req -new -key smtpd.key -out smtpd.csr
openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt
openssl rsa -in smtpd.key -out smtpd.key.unencrypted
mv -f smtpd.key.unencrypted smtpd.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650

postconf -e 'smtpd_tls_auth_only = no'
postconf -e 'smtp_use_tls = yes'
postconf -e 'smtpd_use_tls = yes'
postconf -e 'smtp_tls_note_starttls_offer = yes'
postconf -e 'smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key'
postconf -e 'smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt'
postconf -e 'smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem'
postconf -e 'smtpd_tls_loglevel = 1'
postconf -e 'smtpd_tls_received_header = yes'
postconf -e 'smtpd_tls_session_cache_timeout = 3600s'
postconf -e 'tls_random_source = dev:/dev/urandom'

The file /etc/postfix/main.cf should now look like this:

See /usr/share/postfix/main.cf.dist for a commented, more complete version
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
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

myhostname = server1.example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = server1.example.com, localhost.example.com, localhost
relayhost =
mynetworks = 127.0.0.0/8
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
smtpd_sasl_local_domain =
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_tls_auth_only = no
smtp_use_tls = yes
smtpd_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom

/etc/init.d/postfix restart

Authentication will be done by saslauthd. We have to change a few things to make it work properly. Because Postfix runs chrooted in /var/spool/postfix we have to do the following:

mkdir -p /var/spool/postfix/var/run/saslauthd

Now we have to edit /etc/default/saslauthd in order to activate saslauthd. Remove # in front of START=yes and add the line PARAMS="-m /var/spool/postfix/var/run/saslauthd -r":

This needs to be uncommented before saslauthd will be run automatically
START=yes

PARAMS="-m /var/spool/postfix/var/run/saslauthd -r"

You must specify the authentication mechanisms you wish to use.
This defaults to "pam" for PAM support, but may also include
"shadow" or "sasldb", like this:
MECHANISMS="pam shadow"
MECHANISMS="pam"

We must also edit /etc/init.d/saslauthd and change the location of saslauthd's PID file. Change the value of PIDFILE to /var/spool/postfix/var/run/${NAME}/saslauthd.pid:

PIDFILE="/var/spool/postfix/var/run/${NAME}/saslauthd.pid"

Now start saslauthd:

/etc/init.d/saslauthd start

Next we create the file /etc/c-client.cf with the following contents:

I accept the risk
set disable-plaintext 0

and restart inetd:

/etc/init.d/inetd restart

If we don't do this, then our POP3/IMAP logins will fail.

To see if SMTP-AUTH and TLS work properly now run the following command:

telnet localhost 25

After you have established the connection to your postfix mail server type

ehlo localhost

If you see the lines

250-STARTTLS

and

250-AUTH

everything is fine.

Type

quit

to return to the system's shell.

Courier-IMAP/Courier-POP3

If you want to use a POP3/IMAP daemon that has Maildir support (if you do not want to use the traditional Unix mailbox format) you can install Courier-IMAP/Courier-IMAP-SSL (for IMAPs on port 993) and Courier-POP3/Courier-POP3-SSL (for POP3s on port 995). Otherwise you can proceed with the Apache configuration.

apt-get install courier-imap courier-imap-ssl courier-pop courier-pop-ssl

  • No

ipopd and UW-IMAP will then be replaced.

Then configure Postfix to deliver emails to a user's Maildir*:

postconf -e 'home_mailbox = Maildir/'
postconf -e 'mailbox_command ='
/etc/init.d/postfix restart

Please note: You do not have to do this if you intend to use ISPConfig on your system as ISPConfig does the necessary configuration using procmail recipes. But please go sure to enable Maildir under Management -> Settings -> EMail in the ISPConfig web interface.

Postfix loadable modules development environment
Postfix is Wietse Venema's mail transport agent that started life as an alternative to the widely-used Sendmail program. Postfix attempts to be fast, easy to administer, and secure, while at the same time being sendmail compatible enough to not upset existing users. Thus, the outside has a sendmail-ish flavor, but the inside is completely different.

This provides the headers and library links to build additional map types for Postfix. If you're not developing postfix modules, then you do not need this.

Removing postfix-dev ...
skier-ch:~# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.
220 localhost.localdomain ESMTP Postfix (Debian/GNU)
^]
telnet> quit
Connection closed.
skier-ch:~#

skier-ch:~# chown skier:skier /home/skier/Maildir
skier-ch:~# newaliases

skier-ch:~# aptitude install dovecot
The following NEW packages will be installed:

 dovecot dovecot-common dovecot-imapd dovecot-pop3d libpq3

Selecting previously deselected package libpq3.
(Reading database ... 22309 files and directories currently installed.)
Unpacking libpq3 (from .../libpq3_7.4.7-6sarge3_i386.deb) ...
Selecting previously deselected package dovecot-common.
Unpacking dovecot-common (from .../dovecot-common_0.99.14-1sarge0_i386.deb) ...
Selecting previously deselected package dovecot-imapd.
Unpacking dovecot-imapd (from .../dovecot-imapd_0.99.14-1sarge0_i386.deb) ...
Selecting previously deselected package dovecot-pop3d.
Unpacking dovecot-pop3d (from .../dovecot-pop3d_0.99.14-1sarge0_i386.deb) ...
Selecting previously deselected package dovecot.
Unpacking dovecot (from .../dovecot_0.99.14-1sarge0_all.deb) ...
Setting up libpq3 (7.4.7-6sarge3) ...

Setting up dovecot-common (0.99.14-1sarge0) ...
Creating generic self-signed certificate: /etc/ssl/certs/dovecot.pem
(replace with hand-crafted or authorized one if needed).

Setting up dovecot-imapd (0.99.14-1sarge0) ...

Setting up dovecot-pop3d (0.99.14-1sarge0) ...

Setting up dovecot (0.99.14-1sarge0) ...

skier-ch:~# vi /etc/dovecot/dovecot.conf
protocols = pop3 pop3s
default_mail_env = mbox:/var/mail/%d/%n/

skier-ch:~# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.localdomain.
Escape character is '^]'.

  1. OK dovecot ready.
    ^]
    telnet> quit
    Connection closed.
    skier-ch:~#