mailサーバ構築 (postfix) | ぼぶろぐ

ぼぶろぐ

以前は、あいらぶLinux♪というタイトルでしたが、
最近はLinux以外のことも書いているので、タイトルを変更しました。
ぼぶちゃんのぶろぐでぼぶろぐです。

◆mailサーバ構築 (postfix)

postfixでメールサーバを構築してみました。
ちなみにpostfixを構築するのは初めてだったのですが、
特に問題なくできました。

設定ファイルの行数が多すぎです。。。


[root@localhost ~]# yum -y install postfix
Loaded plugins: downloadonly, fastestmirror, refresh-packagekit
Determining fastest mirrors
* fedora: ftp.iij.ad.jp
* updates: www.ftp.ne.jp
fedora | 2.8 kB 00:00
updates | 3.4 kB 00:00
Setting up Install Process
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.
--> Running transaction check
---> Package postfix.i386 2:2.5.6-1.fc10 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================
Package Arch Version Repository Size
=========================================================================================
Installing:
postfix i386 2:2.5.6-1.fc10 updates 3.8 M

Transaction Summary
=========================================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 3.8 M
Downloading Packages:
postfix-2.5.6-1.fc10.i386.rpm | 3.8 MB 00:13
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 2:postfix-2.5.6-1.fc10.i386 1/1

Installed:
postfix.i386 2:2.5.6-1.fc10

Complete!
[root@localhost ~]# cp -p /etc/postfix/main.cf /etc/postfix/main.cf.org
[root@localhost ~]# vi /etc/postfix/main.cf

変更箇所
[root@localhost ~]# diff /etc/postfix/main.cf /etc/postfix/main.cf.org
77d76
< myhostname = mail.bobchan.local
85d83
< mydomain = bobchan.local
102d99
< myorigin = $mydomain
119c116
< inet_interfaces = all
---
> inet_interfaces = localhost
164c161
< mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
---
> mydestination = $myhostname, localhost.$mydomain, localhost
420,421c417
< home_mailbox = Maildir/
<
---
>
572d567
< smtpd_banner = $myhostname ESMTP unknown
681,689d675
<
< smtpd_sasl_auth_enable = yes
< smtpd_sasl_local_domain = $myhostname
< smtpd_recipient_restrictions =
< permit_mynetworks
< permit_sasl_authenticated
< reject_unauth_destination
<
< message_size_limit = 10485760
[root@localhost ~]# /etc/rc.d/init.d/saslauthd start
saslauthd を起動中: [ OK ]
[root@localhost ~]# chkconfig saslauthd on
[root@localhost ~]# chkconfig --list saslauthd
saslauthd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost ~]# cp -p /usr/lib/sasl2/smtpd.conf /usr/lib/sasl2/smtpd.conf.org
[root@localhost ~]# vi /usr/lib/sasl2/smtpd.conf

変更箇所
[root@localhost ~]# diff /usr/lib/sasl2/smtpd.conf /usr/lib/sasl2/smtpd.conf.org
1c1
< pwcheck_method: auxprop
---
> pwcheck_method: saslauthd
[root@localhost ~]# mkdir -p /etc/skel/Maildir/{new,cur,tmp}
[root@localhost ~]# chmod -R 700 /etc/skel/Maildir/
[root@localhost ~]# /etc/rc.d/init.d/sendmail stop
[root@localhost ~]# chkconfig sendmail off
[root@localhost ~]# chkconfig --list sendmail
sendmail 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@localhost ~]# alternatives --config mta

2 プログラムがあり 'mta' を提供します。

選択 コマンド
-----------------------------------------------
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.postfix

Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:2
[root@localhost ~]# /etc/rc.d/init.d/postfix start
postfix を起動中: [ OK ]
[root@localhost ~]# chkconfig postfix on
[root@localhost ~]# chkconfig --list postfix
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost ~]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mail.bobchan.local ESMTP unknown
HELO test
250 mail.bobchan.local
MAIL FROM: xxxx@xxxx.xxxx.xxxx ←実際の自分のメールアドレス
250 2.1.0 Ok
RCPT TO: xxxx@xxxx.xxxx.xxxx
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
To:xxxx@xxxx.xxxx.xxxx
From:xxxx@xxxx.xxxx.xxxx
Subject:test-mail

This is test-mail.
.
250 2.0.0 Ok: queued as E9C5BE4332
quit
221 2.0.0 Bye
Connection closed by foreign host.



無事にテストメールが届きました。
もう少し細かい設定とかを見ていきたいですね。