Home > Debian | UNIX > [Debian]Debian lennyで1からサーバーを作ってみる – postfixとdovecotをインストール

[Debian]Debian lennyで1からサーバーを作ってみる – postfixとdovecotをインストール

  • メールサーバー構築(PostfixとDovecotをインストール)
    Debianの場合、デフォルトでexim4メールサーバがインストールされているので、まずこれらを消す。

    # aptitude remove exim4 exim4-base exim4-config
    

    exim4を消したら、makeまで消されたので再度インストール。

    # aptitude install make
    

    postfix、saslをインストール。

    # aptitude install postfix sasl2-bin libsasl2-modules
    # aptitude clean
    

    メール名を確認(ここで表示されたものがメールアドレスの@以降に使われます。思ったものと違うときは編集する。)

    # vi /etc/mailname
    
    saizensen.net
    
  • /etc/postfix/main.cfを編集(↓全部載せ)
    # vi /etc/postfix/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 (Debian/GNU)
    smtpd_banner = $myhostname ESMTP unknown
    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
    
    # TLS parameters
    #smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
    #smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
    #smtpd_use_tls=yes
    #smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
    #smtp_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 = mail.saizensen.net
    alias_maps = hash:/etc/aliases
    alias_database = hash:/etc/aliases
    myorigin = /etc/mailname
    #mydestination = saizensen.net, localhost.localdomain, localhost.localdomain, localhost
    mydestination = $myorigin, $myhostname, localhost.$myorigin, localhost
    relayhost =
    #mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
    mynetworks = 192.168.0.0/24 127.0.0.0/8
    #mailbox_command = procmail -a "$EXTENSION"
    mailbox_size_limit = 0
    recipient_delimiter = +
    inet_interfaces = all
    
    home_mailbox = Maildir/
    smtpd_sasl_auth_enable = yes
    smtpd_sasl_local_domain = $myhostname
    smtpd_recipient_restrictions =
        permit_mynetworks
        permit_sasl_authenticated
        reject_unauth_destination
    broken_sasl_auth_clients = yes
    unknown_local_recipient_reject_code = 550
    message_size_limit = 10485760
    
    # MobileMail setting([-] start address)
    allow_min_user = yes
    
  • /etc/postfix/master.cfを編集
    # vi /etc/postfix/master.cf
    
    smtp      inet  n       -       -       -       -       smtpd
    ↓
    smtp      inet  n       -       n       -       -       smtpd
    
    #submission inet n       -       -       -       -       smtpd
    ↓
    submission inet n       -       n       -       -       smtpd
    
  • /etc/default/saslauthdを編集。
    # vi /etc/default/saslauthd
    
    START=no
    ↓
    START=yes
    
    #OPTIONS="-c -m /var/run/saslauthd"
    ↓
    OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd"
    

    ↓これをやる必要があるのか微妙。色々やりすぎて忘れた。

    # dpkg-statoverride --add root sasl 710 /var/spool/postfix/var/run/saslauthd
    
  • /etc/postfix/sasl/smtpd.confを作成。
    # vi /etc/postfix/sasl/smtpd.conf
    
    pwcheck_method: auxprop
    
  • # chgrp postfix /etc/sasldb2
    # adduser postfix sasl
    # /etc/init.d/saslauthd restart
    # /etc/init.d/postfix restart
    
  • ルータの設定でPort25(TCP)を開けます。Submissionポート(587番)を使う場合はPort587(TCP)を開けます。
  • Submissionポート(587番)を使う場合は以下を参照。
    1. [CentOS]PostfixでSubmissionポート(587番)を使う。[Postfix]
    2. [CentOS]いつの間にかCentOS4.7サーバーからGmailへメール送信出来なくなってた。[Postfix]
  • Dovecotをインストール && 設定。
    # aptitude install dovecot-imapd dovecot-pop3d
    # vi /etc/dovecot/dovecot.conf
    
    #disable_plaintext_auth = yes
    ↓
    disable_plaintext_auth = no
    
    #mail_location =
    ↓
    mail_location = maildir:~/Maildir
    
    # /etc/init.d/dovecot restart
    
  • ポート110番(POPの場合)または143番(IMAPの場合)のOPEN
  • Maildir形式メールボックス作成。
    rootユーザーで以下を行う

    # mkdir -p /etc/skel/Maildir/{new,cur,tmp}
    # chmod -R 700 /etc/skel/Maildir/
    

    それぞれの一般ユーザーで以下を行う。(作成済ユーザー全員分)

    $ mkdir Maildir
    $ mkdir Maildir/{new,cur,tmp}
    $ chmod -R 700 Maildir
    
  • メールユーザ追加(hogeは適当な一般ユーザーへ)
    1. sshなどでログインしないユーザー追加の場合
      # useradd -s /sbin/nologin hoge
      # passwd hoge
      

      この場合、/home/以下にhoge用ディレクトリが作成されない為、手動で作成。

      # mkdir /home/hoge
      # mkdir /home/hoge/Maildir
      # mkdir /home/hoge/Maildir/new
      # mkdir /home/hoge/Maildir/cur
      # mkdir /home/hoge/Maildir/tmp
      # chown -R hoge.hoge /home/hoge
      # chmod -R 700 /home/hoge/Maildir
      
    2. sshなどでログインするユーザー追加の場合
      # useradd hoge
      # passwd hoge
      
    3. SMTP-Auth用ユーザ/パスワード登録(ホスト名は/etc/postfix/main.cfのsmtpd_sasl_local_domainでした物を指定すること。)
      # echo "******" | saslpasswd2 -p -u mail.saizensen.net -c hoge
      
    4. SMTP-Auth用ユーザ名、パスワード確認
      # sasldblistusers2
      
    5. ※SMTP-Auth用ユーザ名、パスワードを削除する場合
      # saslpasswd2 -d hoge -u mail.saizensen.net
      

Comments:0

add to hatena hatena.comment (5) add to del.icio.us (0) add to livedoor.clip (0) add to Yahoo!Bookmark (0) Total: 5

Comment Form
Remember personal info

Trackbacks:0

Trackback URL for this entry
http://ore.saizensen.net/archives/322/trackback
Listed below are links to weblogs that reference
[Debian]Debian lennyで1からサーバーを作ってみる – postfixとdovecotをインストール from おれ最前線ねっと

Home > Debian | UNIX > [Debian]Debian lennyで1からサーバーを作ってみる – postfixとdovecotをインストール

Search
Feeds
Meta

Return to page top