LinuxでのPostfix + dovecot + foxmailメールサーバー



Postfix Dovecot Foxmail Mail Server Under Linux



Postfixの設定とインストールのリファレンスhttps://blog.csdn.net/ly_6118/article/details/89637270
これはスパム機能をテストするために使用されたSMTPサーバーであり、後に完全なメールサーバーがイントラネット上に構築されました。
のpostfix設定は少し異なります。これは、dovecotを構築する過程で、電子メールで受信できない問題が見つかったことが判明し、後で修正されたためです。
DNS構成はhttps://blog.csdn.net/ly_6118/article/details/89637270を参照してください

postfix設定

vi /etc/postfix/main.cf
最終的な構成ファイルは次のとおりです(すべてログアウトされた構成)



queue_directory = /var/spool/postfix command_directory = /usr/sbin daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix mail_owner = postfix myhostname = mail.jjonline.com.cn mydomain = jjonline.com.cn myorigin = $mydomain inet_interfaces = all inet_protocols = all mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain #Pay attention to this configuration, because the previous mydestination was logged off = $myhostname, localhost.$mydomain, localhost #Cause to check the status of maillog when sending mail last=bounced (mail for jjonline.com.cn loops back to myself) #Mail back to myself, not sent unknown_local_recipient_reject_code = 550 mynetworks = 127.0.0.1, 10.0.0.0/8, 209.45.60.0/24 #This trust domain network segment is configured according to your needs, the easiest is to configure0.0.0.0/0 All network segments can be sent alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases home_mailbox = Maildir/ smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) broken_sasl_auth_clients = yes smtpd_client_restrictions = permit_sasl_authenticated smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous message_size_limit = 5242880 smtpd_relay_restrictions = permit_mynetworks,permit_sasl_authenticated,defer_unauth_destination smtpd_sasl_type = dovecot #Added dovecot smtpd_sasl_path = private/auth debug_peer_level = 2 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 sendmail_path = /usr/sbin/sendmail.postfix newaliases_path = /usr/bin/newaliases.postfix mailq_path = /usr/bin/mailq.postfix setgid_group = postdrop html_directory = no manpage_directory = /usr/share/man sample_directory = /usr/share/doc/postfix-2.10.1/samples readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES

Cyrus-saslのインストールと構成

saslは、主にメールボックスのユーザー名とパスワードの認証に使用されます
参照元: https://www.cnblogs.com/ilanni/p/5294611.html 著者:マッドラインワールド

cyrus-saslのインストール
cyrus-saslのインストールは非常に簡単です。次のコマンドを使用してください。
yum -y install cyrus-sasl
cyrus-saslのバージョンを表示するには、次のコマンドを使用します。
/ usr / sbin / saslauthd -v
cyrus-sasl構成
次のように、saslauthdファイルを変更して、MECH値をシャドウに変更します。
vi / etc / sysconfig / saslauthd
SOCKETDIR = / run / saslauthd
MECH =シャドウ
フラグ=



smtpd.confファイルを変更し、次のコードを追加します。
vi /etc/sasl2/smtpd.conf
pwcheck_method:saslauthd
mech_list:plain login CRAM-MD5 DIGEST-MD5
log_level:3
saslauthd_path:/ var / run / saslauthd / mux

cyrus-saslをテストする
cyrus-saslを構成したら、それが正常かどうかをテストしましょう。システムユーザーilanniを作成し、そのパスワードを次のように変更します。
useradd ilanni && echo‘ilannimail ’| passwd --stdin ilanni
彼-ilanni
mkdir -p〜 / mail / .imap / INBOX
#ユーザー名ilanni
#password ilannimail
ユーザーが作成されたら、次のようにcyrus-saslを起動します。
/etc/init.d/saslauthdstartまたはservicesaslauthd start
#これはLinuxバージョンに関連しており、一部のバージョンは最初のバージョンをサポートしていません
chkconfig saslauthd on

次に、作成したユーザーを使用して、次のように認証テストを実行します。
testsaslauthd -u ilanni -p‘ilannimail ’
#成功が表示されます



接尾辞とユーザー名をテストする
telnet localhost 100
メール送信者:送信者メールまたは
rcpt to:受信者の電子メールまたは
データ
メッセージの内容

終了する

#新しいユーザーを作成すると、ホームディレクトリのユーザー名に対応するフォルダが生成されます
画像
ly_mail1とly_mail2のユーザーがいます
/ home / ly_mail1 / Maildir / new
送信したメールは対応するディレクトリで確認できます
画像
これはfoxmailによって送信されたコンテンツです
画像

dovecotのインストールと基本構成

dovecotをインストールするには、次のコマンドを使用します。
yum -y install dovecot dovecot-devel dovecot-mysql pam-devel
dovecot --version
これはバージョン2.2.36です
画像
dovecotの基本構成

dovecot構成ファイルはすべて/ etc / dovecot /ディレクトリにあります。
vi /etc/dovecot/dovecot.conf
主な構成は次のとおりです
プロトコル= imap pop3 lmtp
聞く= 、::
login_trusted_networks = 0.0.0.0/0
disable_plaintext_auth = no
!include conf.d /
.conf
!include_try local.conf

vi /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:〜/ Maildir
#一部の構成ファイルはログアウトですmail_location = mbox:〜/ mail:INBOX = / var / mail /%u
#ここで受信トレイからログオフしようとしましたが、最終的に受信トレイがファイルを読み取ることができませんでした
#telnet localhost pop3ノッキングリストには常に0messageが表示され、最終的にmaildirパスが間違っていることがわかりました

vi /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no
auth_mechanisms =プレーンログイン
!include auth-system.conf.ext

SSL認証を無効にする
vi /etc/dovecot/conf.d/10-ssl.conf
ssl = no

dovecotのログを有効にする
vi /etc/dovecot/conf.d/10-logging.conf
info_log_path = /var/log/dovecot_info.log
debug_log_path = /var/log/dovecot_debug.log

鳩小屋を始める
サービスダブコット開始
chkconfig dovecot on

鳩小屋をテストする
telnet mail.ilanni.com 110
telnet mail.ilanni.com 143
+ Ok Dovecot readyが表示された場合は、Dovecotの構成が正しいことを意味します。
ここで、受信ボックスにログインするためのユーザー名は完全な電子メール名ではなく、ドメイン名がないことに注意してください。
テスト入力受信ボックスのユーザー名とパスワードの入力リストは、3つの電子メールが受信されたことを示しています
retr1最初のメッセージを読む
ここで受け取ることができる場合は、鳩小屋の構成が成功していることを意味します
画像

foxmailを構成する

手動構成を選択します。ここで構成されている受信サーバーと送信サーバーはアドレスであり、メールです。
pop3プロトコルを選択してください。imapはより複雑です
着信サーバーと発信サーバーのユーザー名のパスワードは同じでなければならないことに注意してください
元の構成では、個別に構成されたさまざまなパスワードに注意が払われていませんでした。メールを送信するときにパスワードを再確認し、サーバーのログを確認して、常に認証エラーを報告する必要があります。
SMTPサーバーのパスワードを変更する
#smtpアカウントを作成する
saslpasswd2 -c -u postconf -h mydomain test #Enterは、2回連続してパスワードを要求します
#は、root @ xxxxx $ mydomainメールアカウント(SMTPアカウントでもある)とパスワードを作成することを意味します
#この例は、root @xxxxxのアカウントとパスワードを作成するためのものです
#ここで、SMTPログインに使用されるアカウントは単純なユーザー名ではなく、電子メールアドレス文字列全体であることに注意してください
画像
クリックして受信すると、メールを受信できます。ここのメールはサーバー/ home / ly_mail1 / Maildir /から読み取られます
画像