Last-modified: 2014-08-16 (土) 13:51:32
Exim4/自前のSMTPサーバーをたてたい

概要

自前のSMTPサーバーをたてます。

方法

  1. exim4の再設定をします。
    Everything is expanded.Everything is shortened.
      1
    
     
    
    dpkg-reconfigure exim4-config
  2. [インターネットサイト; メールはSMTPを使って直接送受信される]を選択します。
    WS000001.PNG
  3. システムメール名を設定します。
    WS000002.PNG
  4. メールを受け取るその他の宛先を設定します。
    WS000003.PNG
  5. メールをリレーするマシンを設定します。
    WS000004.PNG
  6. DNSクエリ数の設定をします。
    WS000006.PNG
  7. ローカルメールの配送方式を設定します。
    WS000007.PNG
  8. 設定ファイルを分割するかを設定します。
    WS000008.PNG
  9. /etc/exim4/exim4.conf.templateを編集します。
    receivedヘッダを削除する設定を追加します。
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
    
    -
    |
    |
    !
     
     
     
    -
    !
     
     
     
     
     
     
    
    ### transport/30_exim4-config_remote_smtp
    #################################
    # This transport is used for delivering messages over SMTP connections.
     
    remote_smtp:
      debug_print = "T: remote_smtp for $local_part@$domain"
      driver = smtp
        # receivedヘッダ削除
        headers_remove = received
    .ifdef REMOTE_SMTP_HOSTS_AVOID_TLS
      hosts_avoid_tls = REMOTE_SMTP_HOSTS_AVOID_TLS
    .endif
    .ifdef REMOTE_SMTP_HEADERS_REWRITE
      headers_rewrite = REMOTE_SMTP_HEADERS_REWRITE
    .endif
  10. デーモンの再起動をします。
    Everything is expanded.Everything is shortened.
      1
    
     
    
    service restart exim4
  11. iptablesとlogrotate設定を環境に合わせて行います。
  12. 外部からのメールが受信できるかと、こちらから送信できるかを確認してます。
    この段階ではPOP3, IMAPサーバーは立てていないため、サーバー側の送受信確認はmailコマンドで行います。
    mail/チートシート

補足

Exim4/外部SMTPサーバー経由でメールを送信したい(Debian)をしている環境で行った場合
/etc/exim4/passwd.clientに書いたgmailアカウント情報は不要なので削除し、デーモンの自動起動を有効にします。

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
 
 
 
 
vi /etc/exim4/passwd.client
update-exim4.conf
 
update-rc.d -f exim4 defaults

検証時の環境