- Summary
OB25P (Outbound Port 25 Blocking) 対策でメールの送信設定が必要。
手動でPOP before SMTPに対応するのも手間。
MTAを設定して、GmailのSMTPを利用することにする。
- /etc/postfix/main.cf
# GmailのSMTPサーバを指定 relayhost = [smtp.gmail.com]:587 # TLSにより暗号化 smtp_use_tls = yes # plain方式の SMTP AUTH認証を有効にする smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_tls_security_options = noanonymous smtp_sasl_mechanism_filter = plain # GmailのTLS証明書の妥当性確認のための設定 smtp_tls_CApath = /etc/pki/tls/certs/ca-bundle.crt
- /etc/postfix/sasl_passwdを作成
[smtp.gmail.com]:587 username@gmail.com:password
- /etc/postfix/sasl_passwdの権限変更
# chown root:root /etc/postfix/sasl_passwd # chmod 600 /etc/postfix/sasl_passwd
- hash形式の /etc/postfix/sasl_passwd.dbを作成
# postmap /etc/postfix/sasl_passwd
- postfixの再起動
# /etc/init.d/postfix restart
- Gmail SMTP サーバーの証明書を正しく検証する
Gmail SMTP サーバーが持っている証明書から、ルート CA を調べる。
上記の openssl s_client セッションから、Thawte Premium Server CA がルート CA だと分かる。
ルート CA のインターネットドメイン thawte.com のルート証明書をダウンロード。
http://www.thawte.com/roots/ からダウンロード
/usr/share/ca-certificates/thawte.com/ 内に展開。
/etc/postfix/main.cf を編集
/usr/share/ca-certificates/thawte.com/Thawte SSLWeb Server Roots/thawte Premium Server CA/Thawte Premium Server CA.pem
- 注意点
From が自分のGmailアカウントで上書きされる。
送信メールが"送信済みメール"フォルダに配置される。
- Reference
linux.matchy.net - 2008-07-24 - Postfix から Gmail 経由でメールを送る
http://linux.matchy.net/archives/35
Postfix で、Gmail にメールをリレーする - 私の二次記憶
http://d.hatena.ne.jp/ayokoyama/20061207/p1
- Summary
J-COMのOP25B (Outbound Port25 Blocking)により,メールが送信できていなかった.
が,まだ送信できず….
- postfix で submissionポートを開ける.
submission inet n - - - - smtpd -o smtpd_sasl_auth_enable=yes -o smtpd_etrn_restrictions=reject
# /etc/init.d/postfix reload
- Reference
zapanet.info - 突然メールが送信できなくなった時の話
http://zapanet.info/blog/item/851
J-COM - セキュリティ情報 - セキュリティ対策:OP25B (Outbound Port25 Blocking) 導入のお知らせ
http://www.home.ne.jp/cs/data/vs-200609-001.html
J-COM - お知らせ情報 - メール送信のみが突然出来なくなったお客様へのご案内
http://www.home.ne.jp/cs/data/in-200609-003.html
@NetHome セキュリティ - @NetHomeの迷惑メール対策
http://www.home.ne.jp/cs/virus/spam/spam_block.shtml#03
Kozupon.com - Postfixで実現するSubmission over SMTP-AUTH!
http://www.kozupon.com/mail/submission.html
ぴえ〜るの活動日記 - Postfixのsubmissionポート対応 (Debian編)
http://pierre.vg/x/modules/pukiwiki/?Postfix%A4%CEsubmission%A5%DD%A1%BC%A5%C8%C2%D0%B1%FE%A1%CADebian%CA%D4%A1%CB
- Summary
Postfix で SMTP-AUTHを実現する方法.
- SASL関連をインストール
# aptitude install sasl2-bin libsasl2 libsasl-modules
■SASLの設定
- SASLのアカウント操作
- アカウント作成
# saslpasswd2 -c -u myhostname username
- アカウント削除
# saslpasswd2 -d -u myhostname username
- アカウント確認
# sasldblistusers2
- Postfix 側とのデータベース関連付け
ユーザ登録毎に以下作業が必要.
# chgrp postfix /etc/sasldb2
# chmod 640 /etc/sasldb2
# cp /etc/sasldb2 /var/spool/postfix/etc/
- パスワードチェックメソッド (pwcheck_method) の指定
/usr/lib/sasl2/smtpd.conf
pwcheck_method: auxprop mech_list: cram-md5
- Plain loginのみ対応のMUAを使用する場合
/usr/lib/sasl2/smtpd.conf
pwcheck_method: saslauthd mech_list: plain login
(pwcheck_method に saslauthd を指定した場合,mech_list にはplain loginしか指定できない)
- smtpd.confのコピー
# cp /usr/lib/sasl2/smtpd.conf /etc/postfix/sasl/
■Postfixの設定
- /etc/postfix/main.cf
smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_recipient_restrictions = permit_mynetworks, regexp:/etc/postfix/recipient_checks.reg, check_sender_access hash:/etc/postfix/bad_sender, reject_rbl_client relays.ordb.org, reject_rbl_client spamcop.net, reject_rbl_client dynablock.wirehub.net, reject_rbl_client opm.blitzed.org, reject_non_fqdn_recipient, permit_auth_destination, permit_sasl_authenticated, reject_unauth_destination
- /etc/postfix/master.cf
smtp-amavis unix - - n - 2 smtp
-o smtp_data_done_timeout=1200
-o disable_dns_lookups=yes
127.0.0.1:10025 inet n - n - - smtpd
-o smtpd_sasl_auth_enable=yes
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_client_restrictions=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o mynetworks=127.0.0.0/8
-o strict_rfc821_envelopes=yes
-o smtp_error_sleep_time=0
-o smtp_soft_error_limit=1001
-o smtp_hard_error_limit=1000
■動作確認
# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 example.com ESMTP Postfix
EHLO localhost
250-example.com
250-PIPELINING
250-SIZE 51200000
250-ETRN
250-AUTH NTLM LOGIN PLAIN DIGEST-MD5 CRAM-MD5
250-AUTH=NTLM LOGIN PLAIN DIGEST-MD5 CRAM-MD5
250 8BITMIME
quit
221 Bye
Connection closed by foreign host.
- ログの確認
sasl_method=CRAM-MD5, sasl_username=xxxx
- エラーログについて
openldap + sasl2 を導入していると,auth.logに以下のメッセージが記録されることがある.
Aug 17 14:54:37 ns postfix/smtpd[3819]: sql_select option missing
Aug 17 14:54:37 ns postfix/smtpd[3819]: auxpropfunc error no mechanism available
Aug 17 14:54:37 ns postfix/smtpd[3819]: _sasl_plugin_load failed on sasl_auxprop_plug_init for plugin: sql
■トラブルシューティング
- /etc/sasldb2: Permission denied
以下のエラーが発生
Nov 24 03:58:22 myhostname postfix/smtpd[12200]: warning: SASL authentication problem: unable to open Berkeley db /etc/sasldb2: Permission denied
/var/spoold/postfix/sasldb2 の権限が間違っている場合でも /etc/sasldb2 の Permission deniedが発生していた.
# cp /etc/sasldb2 /var/spool/postfix/sasldb2
# chgrp postfix /var/spool/postfix/sasldb2
# chmod 640 /var/spool/postfix/sasldb2
- Reference
Kozupon.com - Postfix + SMTP-AUTH2(SASL2)のセットアップ!
http://www.kozupon.com/mail/sasl2.html
- Summary
user@example.com 宛のメールを /path/to/script にリダイレクト
- /etc/postfix/aliases を変更
user: "|/path/to/script"
- aliasの変更を反映
# newaliases
- Reference
最新WebサービスAPIエクスプローラ pp. 91
- メールの変換
% mh2maildir -courier -f -r -R Mail Maildir
... read from directory Mail/ and store in /home/yoshiki/Maildir/.inbox: processed 0 mails
... read from directory Mail/queue and store in /home/yoshiki/Maildir/.queue: processed 0 mails
... read from directory Mail/mdrop and store in /home/yoshiki/Maildir/.mdrop: processed 0 mails
... read from directory Mail/attach and store in /home/yoshiki/Maildir/.attach: processed 0 mails
... read from directory Mail/postq and store in /home/yoshiki/Maildir/.postq: processed 0 mails
- 不要なフォルダの削除
% cd ~/Maildir
% mv .inbox/cur/* cur
% mv .inbox/new/* new
% mv .inbox/tmp/* tmp
% rm -rf .inbox .draft .queue .postq
- mewの設定
;; For IMAP (setq mew-proto "%") (setq mew-imap-user "yoshiki") (setq mew-imap-server "localhost") ;; ローカルのメールボックスを利用する (setq mew-mailbox-type 'maildir) (setq mew-mbox-command "incm") ;; パスワードの保存 (setq mew-use-cached-passwd t) ;; 送ったメールのバックアップフォルダを指定 (setq mew-fcc "%Sent") (setq mew-imap-trash-folder "%Trash")
(setq mew-refile-guess-alist '( ("To:" ; Debian-users ML ("debian-users@debian.or.jp" . "%debian-users") ) ) )
- Summary
Courier-IMAP をインストール.
# aptitude install courier-imap
# pw2userdb | grep [username] >> /etc/courier/userdb/users
- Postfix
/etc/postfix/main.cf
home_mailbox = Maildir/
- Reference
Fetchmail + Procmail + Courier-IMAP + PostfixでIMAP環境構築
http://www.tugumi.net/tips/imap/
Debian パッケージディレクトリ検索 (バイナリ) - courier-imap
- Postfixで停滞キューを強制排出する
# postfix flush
または
# postqueue -f
- 停滞キューを削除する
# postsuper -d <Queue Number>
- 停滞キュー全てを削除する
# postsuper -d ALL
- hoge@example.com で aaa@example.net, bbb@example.org に転送する.
/etc/postfix/main.cf
alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases
/etc/aliases
hoge: aaa@example.net, bbb@example.org
# newaliases
- 対象OS
Solaris 8
- 方法
http://www.postfix.org/ から ソースを持ってくる
- 解凍
$ tar zxfv postfix-2.0.9.tar.gz
$ cd postfix-2.0.9
- 注意
ここで LD_LIBRARY_PATH が設定されているとエラーがでるので
$ unsetenv LD_LIBRARY_PATH
- make
$ make tidy
$ make makefiles
- ユーザとグループ追加
User : postfix , postdrop
Group: postfix
を作成
- インストール
# make install
- 設定ファイル変更
main.cf の
myhostname = cs.u-gakugei.ac.jp mydomain = u-gakugei.ac.jp myorigin = $myhostname mynetworks = 157.105.54.0/24, 127.0.0.0/8
- postfix スタート
# postfix start
- Reference
BLUCOARA a Network Station - Postfix
http://solaris.bluecoara.net/servers/postfix/postfix1.phtml
- Summary
Postfix が受けとったメールを AMaViS がウィルススキャンソフトの H+BEDV AntiVir に渡して
ウィルスチェックを行うようにします
- インストール方法
AMaViS はパッケージが用意されているので,インストール
# aptitude install amavis-postfix
arc の圧縮形式も対応したければ rpm から借りてくる.
$ alien arc-[version]-i386.rpm
# dpkg -i arc-[version]_i386.deb
rar はパッケージで入れる
# aptitude install rar
- AMaViSの設定ファイル /etc/amavisd.conf の修正
# H+BEDV AntiVir $antivir = "antivir";
だけで動作するが,
$unrar = "/usr/bin/rar"; $warnsender = "no";
を追加
$warnsender は ウィルス感染者にメールを送る設定.
- Postfix の設定
/etc/postfix/main.cf
content_filter = vscan:
/etc/postfix/master.cf
vscan unix - n n - 10 pipe flags=q user=amavis argv=/usr/sbin/amavis ${sender} ${recipient}
localhost:10025 inet n - n - - smtpd -o content_filter=
# postfix reload
- Reference
山本 道成のページ - ネットワーク&自宅サーバ - Postfix で ウィルスメール対策
http://nap.dyndns.org/~michi/network/virus_postfix.html