Quantcast
Channel: NKBMobile のメモ
Viewing all articles
Browse latest Browse all 42

obsA7-006 exim4とmydns.jp

$
0
0
Mail Transfer Agentはexim4を、おうちメールサーバアドレスとしては無料のダイナミックDNS(Dynamic DNS、DDNS)MyDNS.JPを使って構成する。 スマートホストの中継先は、smtp.mail.yahoo.co.jpを使っているが、たぶんsmtp.gmail.comでも同様に動作するだろう。

MyDNS.JP取得については省略する。以下のように名前解決していることが前提。

# host obsa7_sample.mydns.jp
obsa7_sample.mydns.jp has address 106.XXX.YYY.ZZZ
obsa7_sample.mydns.jp mail is handled by 10 obsa7_sample.mydns.jp.

1.exim4の設定

前準備

# パッケージexim4をインストール
# aptitude install exim4
# dpkg -l | grep exim4
ii exim4 4.80-7 all metapackage to ease Exim MTA (v4) installation
ii exim4-base 4.80-7 armel support files for all Exim MTA (v4) packages
ii exim4-config 4.80-7 all configuration for the Exim MTA (v4)
ii exim4-daemon-light 4.80-7 armel lightweight Exim MTA (v4) daemon

# もしpaniclogがあれば空にしておく。
# ls -l /var/log/exim4/paniclog
# cp /dev/null /var/log/exim4/paniclog

# ls -l /etc/exim4/update-exim4.conf.conf
-rw-r--r-- 1 root root 1027 Dec 24 21:18 /etc/exim4/update-exim4.conf.conf

# このupdate-exim4.conf.confは中間設定ワークであるが、
# /var/lib/exim4/config.autogenerated が設定・変更される

# update-exim4.conf.confを直接変更したときは、
# /usr/sbin/update-exim4.conf
# /etc/init.d/exim4 restart
# として、/var/lib/exim4/config.autogeneratedを更新・反映させる。
ではexim4-config を行う。以下はテキストベースの設定画面を説明用に部分抽出したもの。

# dpkg-reconfigure exim4-config

Package configuration
┤ Mail Server configuration


General type of mail configuration: メール設定の一般的なタイプ
│ internet site; mail is sent and received directly using SMTP
│ X mail sent by smarthost; received via SMTP or fetchmail
│ mail sent by smarthost; no local mail
│ local delivery only; not on a network
│ no configuration at this time


System mail name: システムメール名 /etc/mailname
│ obsa7.local_sample.or.jp


IP-addresses to listen on for incoming SMTP connections: 入力側SMTP接続をリスンするIPアドレス
│ 空


Other destinations for which mail is accepted: このSMTPサーバーで扱うドメインを指定します。
│ obsa7_sample.mydns.jp


Domains to relay mail for: 外部リレーは認証済みのアカウント以外はできないので空でもよい。
│ smtp.mail.yahoo.co.jp


Machines to relay mail for: メールをリレーするマシン
│ local_sample.or.jp:*.local_sample.or.jp:*.mail.yahoo.co.jp


IP address or host name of the outgoing smarthost: このホストから送出されたメールを操作するマシン (スマートホスト)
│ smtp.mail.yahoo.co.jp::587


│ Hide local mail name in outgoing mail? 送出するメールでローカルメール名を隠しますか?


Keep number of DNS-queries minimal (Dial-on-Demand)? DNS クエリの数を最小限に留めますか (ダイヤルオンデマンド)?


Delivery method for local mail:
│ X mbox format in /var/mail/
│ Maildir format in home directory


Split configuration into small files? 設定を小さなファイルに分割しますか?


Root and postmaster mail recipient:
│ root


[ ok ] Stopping MTA for restart: exim4_listener.
[ ok ] Restarting MTA: exim4.

# egrep -v '^#' update-exim4.conf.conf

dc_eximconfig_configtype='smarthost'
dc_other_hostnames='obsa7_sample.mydns.jp'
dc_local_interfaces=''
dc_readhost='obs.local_sample.or.jp'
dc_relay_domains='smtp.mail.yahoo.co.jp'
dc_minimaldns='false'
dc_relay_nets='local_sample.or.jp:*.local_sample.or.jp:*.mail.yahoo.co.jp'
dc_smarthost='smtp.mail.yahoo.co.jp::587'
CFILEMODE='644'
dc_use_split_config='true'
dc_hide_mailname='false'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'
SMTP-AUTH認証用 passwd.client を設定

# egrep -v '^#' /etc/exim4/passwd.client
smtp.mail.yahoo.co.jp:Yahoo_JAPAN_MAIL@yahoo.co.jp:"Yahoo! JAPAN パスワード"

# chgrp Debian-exim passwd.client
# ls -l /etc/exim4/passwd.client
-rw-r----- 1 root Debian-exim 330 Dec 31 09:42 /etc/exim4/passwd.client
passwd.clientへのIDパスワードは、
http://info.mail.yahoo.co.jp/options/imapprofile/
Yahoo!JAPANにログイン後このページを見て
smtp.mail.yahoo.co.jp:メールアドレス:パスワード の行を設定する。
Yahoo_JAPAN_MAIL@yahoo.co.jp部分は@yahoo.co.jpを省略しても通ったようだ。

サーバー設定
受信メール(IMAP)サーバー imap.mail.yahoo.co.jp
受信メール(IMAP)通信方法 SSL
受信メール(IMAP)ポート番号 993
送信メール(SMTP)サーバー smtp.mail.yahoo.co.jp
送信メール(SMTP)認証方式 SMTP_AUTH
送信メール(SMTP)通信方法 SSL
送信メール(SMTP)ポート番号 465
アカウント名/ログイン名 Yahoo_JAPAN_ID ... "Yahoo! JAPAN ID"
メールアドレス Yahoo_JAPAN_MAIL@yahoo.co.jp
パスワード Yahoo! JAPAN パスワード
証明書の作成
# /usr/share/doc/exim4-base/examples/exim-gencert
Country Code (2 letters) [US]:JP
State or Province Name (full name) []:MY_FULL_NAME
Locality Name (eg, city) []:
Organization Name (eg, company; recommended) []:
Organizational Unit Name (eg, section) []:
Server name (eg. ssl.domain.tld; required!!!) []:
Email Address []:
[*] Done generating self signed certificates for exim!
Refer to the documentation and example configuration files
over at /usr/share/doc/exim4-base/ for an idea on how to enable TLS
support in your mail transfer agent.
root@obsa7:exim4# ls -l exim.crt exim.key
-rw-r----- 1 root Debian-exim 652 Dec 30 23:22 exim.crt
-rw-r----- 1 root Debian-exim 916 Dec 30 23:22 exim.key
SMTP認証の設定
ユーザ認証方式は、「AUTH PLAIN」「AUTH LOGIN」を有効化する。
# diff /etc/exim4/exim4.conf.template.org /etc/exim4/exim4.conf.template
316c316
<
---
> MAIN_TLS_ENABLE = USE
1818,1826c1818,1826
< # plain_server:
< # driver = plaintext
< # public_name = PLAIN
< # server_condition = "${if crypteq{$auth3}{${extract{1}{:}{${lookup{$auth2}lsearch{CONFDIR/passwd}{$value}{*:*}}}}}{1}{0}}"
< # server_set_id = $auth2
< # server_prompts = :
< # .ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS
< # server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}}
< # .endif
---
> plain_server:
> driver = plaintext
> public_name = PLAIN
> server_condition = "${if crypteq{$auth3}{${extract{1}{:}{${lookup{$auth2}lsearch{CONFDIR/passwd}{$value}{*:*}}}}}{1}{0}}"
> server_set_id = $auth2
> server_prompts = :
> .ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS
> server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}}
> .endif
1833,1841c1833,1841
< # login_server:
< # driver = plaintext
< # public_name = LOGIN
< # server_prompts = "Username:: : Password::"
< # server_condition = "${if crypteq{$auth2}{${extract{1}{:}{${lookup{$auth1}lsearch{CONFDIR/passwd}{$value}{*:*}}}}}{1}{0}}"
< # server_set_id = $auth1
< # .ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS
< # server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}}
< # .endif
---
> login_server:
> driver = plaintext
> public_name = LOGIN
> server_prompts = "Username:: : Password::"
> server_condition = "${if crypteq{$auth2}{${extract{1}{:}{${lookup{$auth1}lsearch{CONFDIR/passwd}{$value}{*:*}}}}}{1}{0}}"
> server_set_id = $auth1
> .ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS
> server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}}
> .endif

2.メール送信テスト


<toYahoo.sh>
#! /bin/sh
set -x
export DT="TEST_test `date`"
(echo "Subject: $DT"; echo "To: au_user@ezweb.ne.jp";\
echo "From: Yahoo_JAPAN_MAIL@yahoo.co.jp"; echo ""; echo "$DT" ;\
echo "from `hostname`") | \
/usr/sbin/exim4 -v -f Yahoo_JAPAN_MAIL@yahoo.co.jp au_user@ezweb.ne.jp

# このスクリプトを実行
obsa7user@obsa7:~% ./toYahoo.sh
+ date
+ export DT=TEST_test Tue Dec 31 00:37:01 JST 2013
+ /usr/sbin/exim4+ -v -f obsa7_sample_user@yahoo.co.jp au_user@ezweb.ne.jp
echo Subject: TEST_test Tue Dec 31 00:37:01 JST 2013
+ echo To: au_user@ezweb.ne.jp
+ echo From: obsa7_sample_user@yahoo.co.jp
+ echo
+ echo TEST_test Tue Dec 31 00:37:01 JST 2013
+ hostname
+ echo from obsa7
LOG: MAIN
<= obsa7_sample_user@yahoo.co.jp U=obsa7user P=local S=408
obsa7user@obsa7:~% delivering 1Vxetp-0001hN-6O
R: smarthost for au_user@ezweb.ne.jp
T: remote_smtp_smarthost for au_user@ezweb.ne.jp
Transport port=25 replaced by host-specific port=587
Connecting to smtp.mail.yahoo.co.jp [114.111.99.228]:587 ... connected
SMTP<< 220 smtp506.mail.kks.yahoo.co.jp ESMTP
SMTP>> EHLO obsa7
SMTP<< 250-smtp506.mail.kks.yahoo.co.jp
250-AUTH LOGIN PLAIN XYMCOOKIE
250-PIPELINING
250 8BITMIME
SMTP>> AUTH PLAIN ****************************
SMTP<< 235 ok, go ahead (#2.0.0)
SMTP>> MAIL FROM: AUTH=obsa7user@obsa7.local_sample.or.jp
SMTP>> RCPT TO:
SMTP>> DATA
SMTP<< 250 ok
SMTP<< 250 ok
SMTP<< 354 go ahead
SMTP>> writing message and terminating "."
SMTP<< 250 ok 1388417821 qp 62878
SMTP>> QUIT
LOG: MAIN
=> au_user@ezweb.ne.jp R=smarthost T=remote_smtp_smarthost H=smtp.mail.yahoo.co.jp [114.111.99.228]
LOG: MAIN
Completed
%

</var/log/exim4/mainlog>
2013-12-31 00:37:01 1Vxetp-0001hN-6O <= Yahoo_JAPAN_MAIL@yahoo.co.jp U=a7user P=local S=408
2013-12-31 00:37:02 1Vxetp-0001hN-6O => au_user@ezweb.ne.jp R=smarthost T=remote_smtp_smarthost H=smtp.mail.yahoo.co.jp [114.111.99.228]
もし送信に失敗していたなら、メールがFrozenになるので、
→ 1Vxdpt-0000tm-7W Frozen (delivery error message)
# pushd /var/spool/exim4/input/; rm -i 1* とかして、失敗メールは削除する。


Viewing all articles
Browse latest Browse all 42

Trending Articles


EASY COME, EASY GO


Girasoles para colorear


Pokemon para colorear


Presence Quotes – Positive Quotes


Two timer Sad tagalog Love quotes


Tropa Quotes


“Mali man na ikaw ay ibigin ko, akoy iibig padin sayo”


RE: Mutton Pies (frankie241)


Vimeo 10.7.0 by Vimeo.com, Inc.


FORECLOSURE OF REAL ESTATE MORTGAGE


Long Distance Relationship Tagalog Love Quotes


HOY PANGIT, MAGBAYAD KA!


Sapos para colorear


Love Quotes Tagalog


Papa Jack Tagalog Love Quotes and Advice for you


Top 7 Lies of Boys


Re:Mutton Pies (lleechef)


Ka longiing longsem kaba skhem bad kaba khlain ka pynlong kein ia ka...


Vimeo 10.7.1 by Vimeo.com, Inc.


UPDATE SC IDOL: TWO BECOME ONE