サーバー環境

Aws EC2 Postfix + Dovecotメールサーバー 構築記録

概要

Postfixインストール


# yum -y update
# yum install postfix

postfixの設定

main.cf の編集
# vi /etc/postfix/main.cf
myhostname = mail.example.jp
mydomain = example.jp
myorigin = $myhostname
#inet_interfaces = localhost
inet_interfaces = all
inet_protocols = ipv4
mydestination =
          $myhostname,
          localhost.$mydomain,
          localhost,
          $mydomain
mynetworks = xxx.xxx.xxx.xxx/32, 127.0.0.1
home_mailbox = Maildir/

# 最終行へ追記
# 送受信メールサイズを10Mに制限
message_size_limit = 10485760
# メールボックスサイズを1Gに制限
mailbox_size_limit = 1073741824
# 以下SMTP-Auth用
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $mydomain
smtpd_recipient_restrictions
     = permit_mynetworks,
permit_auth_destination,
permit_sasl_authenticated,
reject
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd


#vi /etc/postfix/master.cf
#以下コメントをはずす。
submission inet n – n – – smtpd
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
-o milter_macro_daemon_name=ORIGINATING

dovecot のインストール



# yum -y install dovecot

dovecotのの設定

# vi /etc/dovecot/dovecot.conf
protocols = imap pop3
listen = *,

# vi /etc/dovecot/conf.d/10-mail.conf
location = maildir:~/Maildir

# vi /etc/dovecot/conf.d/10-auth.conf
auth_mechanisms = plain login

# vi /etc/dovecot/conf.d/10-master.conf
service imap-login {
  inet_listener imap {
    port = 143
  }
  inet_listener imaps {
    port = 993
    ssl = yes
  }
}

service pop3-login {
  inet_listener pop3 {
    port = 110
  }
  inet_listener pop3s {
    port = 995
    ssl = yes
  }
}

service auth {
  # Postfix smtp-auth
  unix_listener /var/spool/postfix/private/auth {
    mode = 0666
    user = postfix
    group = postfix
  }
}

# vi /etc/dovecot/conf.d/10-ssl.conf
# 今回disable_plaintext_auth = no を設定して
# PlainText認証許可したのでsslを必須としない。
#ssl = required
ssl = yes

Sendmailから差し替え


# alternatives --config mta
# 今回disable_plaintext_auth = no を設定して
There are 2 programs which provide ‘mta’.

Selection Command
———————————————–
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.postfix

Enter to keep the current selection[+], or type selection number: 2
2 を入力して Postfixにする

sendmailの停止と、postfixの起動


#service sendmail stop
# chkconfig sendmail off
# service postfix start
# chkconfig postfix on

dovecotの起動


# service dovecot start # chkconfig dovecot on

動作確認とその準備


# service dovecot start

新規ユーザ追加時に、デフォルトのメールボックス(~/Maildir)を作成するようにする。
# mkdir -p /etc/skel/Maildir/{new,cur,tmp}
# chmod -R 700 /etc/skel/Maildir/

パソコン(Mac)、thunderbirdのメール設定でメールの送受信の確認をしてみました。 (Dovecot で imap での受信メールの確認 submission(Port 587)でのメール送信の確認) 別途暗号化されたパスワード認証での実験も機会があればやってみたいと思います。

IMAPの設定画面


Submission(587)利用での設置画面


最近の記事

  1. wordpres5をubuntu nginxにインストール
  2. ubuntu 20.04 nginx php mysql Webサーバー環境整備
  3. Ubuntu nginx SSL
  4. EC-CUBE 4.0 インストール
  1. プログラミング

    python Django Webアプリケーションの構築 基本編
  2. ubuntu 20.04 nginx php mysql Webサーバー環境整備

    サーバー環境

    ubuntu 20.04 nginx php mysql Webサーバー環境…
  3. Web・デザイン

    Illustrator ショートカットデータベース、カテゴリー別絞り込み 、マウ…
  4. Web・デザイン

    CSS3 機能 セレクタ、target擬似クラス、構造擬似クラスについて学ぶ
  5. Web・デザイン

    ページ上の要素をふるわす CSShake 「CSSアニメーションライブラリー」
PAGE TOP