カスタム検索
tomo.gif (1144 ツバツイツト)line.gif (927 ツバツイツト)line.gif (927 ツバツイツト)line.gif (927 ツバツイツト)To previous pageTo home pageMailing to me

PostfixでSMTPサーバを立てる
(CentOS4.6

Modified: 21 October 2006

Centos4では、設定が簡単です。


Postfixのインストール
Postfixの基本設定
SMTP AUTHの追加設定
サーバー起動とテスト
クライアントの設定


Postfixのインストール

CentOS4.6では、デフォルトのメーラは、sendmailですので、このsendmailを無効にします。

# service sendmail stop
# chkconfig sendmail off

Postfixがインストールされていなければインストールします。

# yum install postfix


Postfixの設定

基本的な(最低限の)設定として、"/etc/postfix/main.cf" を以下のように設定します。

最低限、以下の6つを指定します。
myhostname, mydomain, myorigin, inet_interfaces, mydestination, mynetworks

         :

# INTERNET HOST AND DOMAIN NAMES
# 
# The myhostname parameter specifies the internet hostname of this
# mail system. The default is to use the fully-qualified domain name
# from gethostname(). $myhostname is used as a default value for many
# other configuration parameters.
#
myhostname = mail.tomo.ac

# The mydomain parameter specifies the local internet domain name.
# The default is to use $myhostname minus the first component.
# $mydomain is used as a default value for many other configuration
# parameters.
#
mydomain = tomo.ac

# SENDING MAIL
# 
# The myorigin parameter specifies the domain that locally-posted
# mail appears to come from. The default is to append $myhostname,
# which is fine for small sites.  If you run a domain with multiple
# machines, you should (1) change this to $mydomain and (2) set up
# a domain-wide alias database that aliases each user to
# user@that.users.mailhost.
#
# For the sake of consistency between sender and recipient addresses,
# myorigin also specifies the default domain name that is appended
# to recipient addresses that have no @domain part.
#
#myorigin = $myhostname
myorigin = $mydomain

# RECEIVING MAIL

# The inet_interfaces parameter specifies the network interface
# addresses that this mail system receives mail on.  By default,
# the software claims all active interfaces on the machine. The
# parameter also controls delivery of mail to user@[ip.address].
#
# See also the proxy_interfaces parameter, for network addresses that
# are forwarded to us via a proxy or network address translator.
#
# Note: you need to stop/start Postfix when this parameter changes.
#
inet_interfaces = all

         :

# The mydestination parameter specifies the list of domains that this
# machine considers itself the final destination for.
#
# These domains are routed to the delivery agent specified with the
# local_transport parameter setting. By default, that is the UNIX
# compatible delivery agent that lookups all recipients in /etc/passwd
# and /etc/aliases or their equivalent.
#
# The default is $myhostname + localhost.$mydomain.  On a mail domain
# gateway, you should also include $mydomain.
#
# Do not specify the names of virtual domains - those domains are
# specified elsewhere (see VIRTUAL_README).
#
# Do not specify the names of domains that this machine is backup MX
# host for. Specify those names via the relay_domains settings for
# the SMTP server, or use permit_mx_backup if you are lazy (see
# STANDARD_CONFIGURATION_README).
#
# The local machine is always the final destination for mail addressed
# to user@[the.net.work.address] of an interface that the mail system
# receives mail on (see the inet_interfaces parameter).
#
# Specify a list of host or domain names, /file/name or type:table
# patterns, separated by commas and/or whitespace. A /file/name
# pattern is replaced by its contents; a type:table is matched when
# a name matches a lookup key (the right-hand side is ignored).
# Continue long lines by starting the next line with whitespace.
#
# See also below, section "REJECTING MAIL FOR UNKNOWN LOCAL USERS".
#
mydestination = $myhostname, $mydomain

         :

# Alternatively, you can specify the mynetworks list by hand, in
# which case Postfix ignores the mynetworks_style setting.
#
# Specify an explicit list of network/netmask patterns, where the
# mask specifies the number of bits in the network part of a host
# address.
#
# You can also specify the absolute pathname of a pattern file instead
# of listing the patterns here. Specify type:table for table-based lookups
# (the value on the table right-hand side is not used).
#
mynetworks = 192.168.0.0/24, 127.0.0.0/8
#mynetworks = $config_directory/mynetworks
#mynetworks = hash:/etc/postfix/network_table

         :


SMTP AUTHの設定

以下の設定を "/etc/postfix/main.cf" に追加します。

broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $mydomain
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_unauth_destination,
    permit_auth_destination,
    reject

"SMTP Auth"の利用を許可する。

smtpd_sasl_auth_enable = yes

"anonymous"接続を拒否する。

smtpd_sasl_security_options = noanonymous

OutlookExpressから利用する場合には、以下も加えます。

broken_sasl_auth_clients = yes

SMTPを受け付ける条件を指定する。

smtpd_recipient_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_unauth_destination,
    permit_auth_destination,
    reject
  1. permit_mynetworksは、サーバー内のネットワーク、つまり内部からの利用を許可するものです。
  2. permit_sasl_authenticated は、sasl認証できたものだけ受け入れる。
  3. reject_unauth_destination で、認証できなかったものは、拒否する。
  4. permit_auth_destination で、認証できたものは、受け入れる。
  5. reject で、その他は、拒否する。


認証方法をしている以下の設定ファイルも確認します。

"/usr/lib/sasl2/smtpd.conf"

pwcheck_method:saslauthd

以下のコマンドで設定の確認をします。

# /usr/sbin/postfix check
#

何も出ず、プロンプトが帰ってきたら設定はOKです。


サーバー起動とテスト

# service saslauthd start
# service postfix start

自動起動の設定もしておきます。

# chkconfig saslauthd on
# chkconfig postfix on

以下のように、"250-AUTH"が出ればOKです。

# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 recipemail.co-recipe.com ESMTP Postfix
EHLO localhost
250-recipemail.co-recipe.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH CRAM-MD5 LOGIN DIGEST-MD5 PLAIN
250-AUTH=CRAM-MD5 LOGIN DIGEST-MD5 PLAIN
250 8BITMIME
QUIT
221 Bye
Connection closed by foreign host.
#


クライアントの設定

Beckey!の設定

「詳細」タブの「SMTP認証」にチェックし、「LOGIN」にチェックします。


OutlookExpressの設定

「サーバー」タブで、「送信メールサーバー」の「設定」ボタンをクリックすます。

以下のように、ログインパスワードを入力します。


To previous pageTo home pageMailing to meJump to Top of pageline.gif (927 ツバツイツト)line.gif (927 ツバツイツト)tomo.gif (1144 ツバツイツト)
カスタム検索


Tweet