質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Dovecot

Dovecotとは、POPやIMAPサーバーを提供するMDA(メール配送エージェント)の一つです。

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

Postfix

Postfixは、電子メールサーバソフトウェアで、 メールを配送するシステムMTAの一種です。

Q&A

1回答

8861閲覧

Postfix 送信できない

tony

総合スコア86

Dovecot

Dovecotとは、POPやIMAPサーバーを提供するMDA(メール配送エージェント)の一つです。

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

Postfix

Postfixは、電子メールサーバソフトウェアで、 メールを配送するシステムMTAの一種です。

0グッド

0クリップ

投稿2017/03/21 02:38

編集2017/03/21 03:24

お世話になります。メールサーバー構築初心者です。
Postfix + Dovecotでメールサーバーの構築をしており、送信受信でつまずいています(致命的)。
環境としてはPostfix + Dovecot で、ユーザー・ドメイン管理はMysql + PostfixAdminを使用しています。
仮想ドメインに対応させようとしています。。

[環境]
CentOS7.3.1611【KVMゲストOS】
Postfix2.10.1
Dovecot2.2.10
Mysql5.7.17
PostfixAdmin3.0.2
Thunderbird45.8.0【クライアントメーラー】

【送信】
PostfixにてSMTP-AUTH認証を行い、送信しようとしていますが、現状では送信時に認証エラーとなります。
クライアントの設定は
メールサーバー:mail.hoge.jp
ポート:587
ユーザー名:test001@hoge.jp
認証方式:通常のパスワード認証
接続の保護:STARTTLS

証明書はとりあえず自己証明(オレオレ証明書)を使っています。
送信時のエラーログは下記です。

/var/log/maillog
↓↓↓

maillog

1mail postfix/smtpd[12036]: connect from unknown[xxx.xxx.xxx.xxx] 2mail postfix/smtpd[12036]: Anonymous TLS connection established from unknown[xxx.xxx.xxx.xxx]: TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits) 3mail postfix/smtpd[12036]: warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory 4mail postfix/smtpd[12036]: warning: SASL authentication failure: Password verification failed 5mail postfix/smtpd[12036]: warning: unknown[xxx.xxx.xxx.xxx]: SASL PLAIN authentication failed: generic failure 6mail postfix/smtpd[12036]: warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory 7mail postfix/smtpd[12036]: warning: unknown[xxx.xxx.xxx.xxx]: SASL LOGIN authentication failed: generic failure 8mail postfix/smtpd[12036]: disconnect from unknown[xxx.xxx.xxx.xxx]

postconf -n の実行結果は下記のとおりです。

postconf

1alias_database = hash:/etc/aliases 2alias_maps = hash:/etc/aliases 3broken_sasl_auth_clients = yes 4command_directory = /usr/sbin 5config_directory = /etc/postfix 6daemon_directory = /usr/libexec/postfix 7data_directory = /var/lib/postfix 8debug_peer_level = 2 9debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5 10fallback_transport = virtual 11home_mailbox = Maildir/ 12html_directory = no 13inet_interfaces = all 14inet_protocols = all 15local_transport = virtual 16mail_owner = postfix 17mailq_path = /usr/bin/mailq.postfix 18manpage_directory = /usr/share/man 19mydestination = $myhostname, $mydomain 20mydomain = hoge.jp 21myhostname = mail.hoge.jp 22mynetworks = 127.0.0.0/8 23myorigin = $myhostname 24newaliases_path = /usr/bin/newaliases.postfix 25queue_directory = /var/spool/postfix 26readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES 27relay_domains = $mydestination 28relayhost = 29sample_directory = /usr/share/doc/postfix-2.10.1/samples 30sendmail_path = /usr/sbin/sendmail.postfix 31setgid_group = postdrop 32smtp_sasl_security_options = noanonymous, noplaintext 33smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_relay_domains, reject 34smtpd_sasl_auth_enable = yes 35smtpd_sasl_local_domain = $myhostname 36smtpd_tls_cert_file = /etc/pki/dovecot/certs/dovecot.pem 37smtpd_tls_key_file = /etc/pki/dovecot/private/dovecot.pem 38smtpd_tls_loglevel = 1 39smtpd_tls_session_cache_database = btree:/etc/postfix/smtpd_scache 40smtpd_tls_session_cache_timeout = 3600s 41smtpd_use_tls = yes 42unknown_local_recipient_reject_code = 550 43virtual_alias_domains = $virtual_alias_maps 44virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf 45virtual_gid_maps = static:600 46virtual_mailbox_base = /home/vmailbox 47virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf 48virtual_mailbox_limit = 51200000 49virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf 50virtual_minimum_uid = 600 51virtual_transport = virtual 52virtual_uid_maps = static:600
[/etc/postfix/mysql_virtual_alias_maps.cf] user = postfixadmin password = xxxxxxxxxxxxx hosts = localhost dbname = postfixadmin query = SELECT goto FROM alias WHERE address='%s' [/etc/postfix/mysql_virtual_domains_maps.cf] user = postfixadmin password = xxxxxxxxxxxxx hosts = localhost dbname = postfixadmin query = SELECT domain FROM domain WHERE domain='%s' and domain!='hoge.jp' [/etc/postfix/mysql_virtual_mailbox_maps.cf] user = postfixadmin password = xxxxxxxxxxxxx hosts = localhost dbname = postfixadmin query = SELECT concat(maildir, 'Maildir/') FROM mailbox WHERE username = '%s' AND active = '1'

【受信】
Dovecotにて受信設定を行っていまして、認証自体は通っており、他からのメール(gmailなど)はメールボックスに入っているようです。
現状の受信先は
/home/vmailbox/hoge.jp/test001@hoge.jp/Maildir/new
になっています。
上記にはどんどんメールがたまっていっているのですが、メールクライアントからはPOPでダウンロードできていない状態です。
dovecot.logの出力内容は書きです。

pop3-login: Info: Login: user=<test001@hoge.jp>, method=PLAIN, rip=xxx.xxx.xxx.xxx, lip=yyy.yyy.yyy.yyy, mpid=16688, TLS, session=<mdc/cjRLyAC0KkTg> pop3(test001@hoge.jp): Info: Disconnected: Logged out top=0/0, retr=0/0, del=0/1, size=4571

dovecotの現在のコンフィグは下記のとおりです。

dovecot.conf

1[dovecot.conf] 2protocols = pop3 imap lmtp 3listen = *, :: 4dict { 5} 6!include conf.d/*.conf 7!include_try local.conf 8 9[10-auth.conf] 10disable_plaintext_auth = no 11auth_mechanisms = plain digest-md5 cram-md5 12!include auth-system.conf.ext 13 14[auth-system.conf.ext] 15passdb { 16 driver = sql 17 args = /etc/dovecot/dovecot-mysql.conf 18} 19userdb { 20 driver = sql 21 args = /etc/dovecot/dovecot-mysql.conf 22} 23 24[10-director.conf] 25service director { 26 unix_listener login/director { 27 } 28 fifo_listener login/proxy-notify { 29 } 30 unix_listener director-userdb { 31 } 32 inet_listener { 33 } 34} 35service imap-login { 36} 37service pop3-login { 38} 39protocol lmtp { 40} 41 42[10-logging.conf] 43log_path = /var/log/dovecot.log 44plugin { 45} 46 47[10-main.conf] 48mail_location = maildir:/home/vmailbox/%d/%n 49namespace inbox { 50 inbox = yes 51} 52first_valid_uid = 600 53mbox_write_locks = fcntl 54 55[10-master.conf] 56service imap-login { 57 inet_listener imap { 58 } 59 inet_listener imaps { 60 port = 993 61 ssl = yes 62 } 63} 64service pop3-login { 65 inet_listener pop3 { 66 port = 110 67 } 68 inet_listener pop3s { 69 port = 995 70 ssl = yes 71 } 72} 73service lmtp { 74 unix_listener lmtp { 75 } 76} 77service imap { 78} 79service pop3 { 80} 81service auth { 82 unix_listener auth-userdb { 83 } 84} 85service auth-worker { 86} 87service dict { 88 unix_listener dict { 89 } 90} 91 92[10-ssl.conf] 93ssl = yes 94ssl_cert = </etc/pki/dovecot/certs/dovecot.pem 95ssl_key = </etc/pki/dovecot/private/dovecot.pem 96 97[15-lda.conf] 98protocol lda { 99} 100 101[15-mailboxes.conf] 102namespace inbox { 103 mailbox Drafts { 104 special_use = \Drafts 105 } 106 mailbox Junk { 107 special_use = \Junk 108 } 109 mailbox Trash { 110 special_use = \Trash 111 } 112 mailbox Sent { 113 special_use = \Sent 114 } 115 mailbox "Sent Messages" { 116 special_use = \Sent 117 } 118} 119 120[20-imap.conf] 121protocol imap { 122} 123 124[20-lmtp.conf] 125protocol lmtp { 126} 127 128[20-pop3.conf] 129protocol pop3 { 130} 131

何卒よろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

[10-main.conf]

mail_location = maildir:/home/vmailbox/%d/%n ...

Dovecotのマニュアル「Mail Location」の「Variables」には次のように書いてあります。

You can use several variables in the mail_location setting. See Variables for a full list, but the most commonly used ones are:

  • %u: Full username.
  • %n: User part in user@domain, same as %u if there's no domain.
  • %d: Domain part in user@domain, empty if there's no domain.

ですから、ユーザ名test001@hoge.jpだと、メールボックスの場所は/home/vmailbox/hoge.jp/test001と認識されます。

ログインした直後にセッションが終了してしまう (接続が切れる) のは、ログインは成功してもメールボックスが見つからないためでしょう。


送信の方ですが、設定を見ると認証にCyrus SASLを使う設定 (これがデフォルト) になっています。その場合はsaslauthdを設定して起動しておく必要があります。ログを見ると起動していないようです。

また、dovecot SASLを使うこともできます。その場合はdovecotにも設定が必要です。

また、SMTP-AUTHがうまくいくようになったら、認証をより安全にする設定を以前回答していますので、参考になさって下さい。ここの「変更案2」です。

投稿2017/03/21 05:10

編集2017/03/21 15:17
ikedas

総合スコア4333

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

tony

2017/03/21 14:04 編集

ありがとうございます! 実際にメール保存されていたディレクトリは/home/vmailbox/hoge.jp/test001@hoge.jp/Maildir/newとかなっていたので一通り設定を見直したらmysql_virtual_mailbox_maps.cfのSQLがおかしいことになってるのに気づきました。 【修正前】 query = SELECT concat(maildir, 'Maildir/') FROM mailbox WHERE username = '%s' AND active = '1' 【修正後】 query = SELECT maildir FROM mailbox WHERE username = '%s' AND active = '1' あとはご指摘のDovecotの設定で mail_location = maildir:/home/vmailbox/%d/%u としたところクライアント側で受信が確認できました。 ほんとは mail_location = maildir:/home/vmailbox/%d/%n としたいところなんですが。。(まぁこだわりで) Postfix側のmaildirに原因ありそうですね。調べてみます。
ikedas

2017/03/21 15:22

わたしも%d/%nとサブディレクトリを掘るほうが好みです。 あとすみません。送信の方の回答が抜けていました。加筆してみました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問