setup virtual mail on aws(2/4)

投稿日:

前回の続き

3. postfixのinstall

yum でpostfixのinstall。
% sudo yum install postfix

4. postfixのvirtual用unix user作成

virtual mail 受取用のunix user「vhost」を作成。 ここでは、user idを「5000」とする。
% sudo useradd -u 5000 vhosts 

5. postfixのsetup

ファイルのそれぞれ修正する。例は、「sample.com」。

/etc/postfix/main.cf

myhostname = mail.sample.com 
myhostname = mail.sample.com
myorigin = $mydomain
inet_interfaces = all
#mydestination = $myhostname, localhost.$mydomain, localhost
home_mailbox = Maildir/
 
# add
virtual_mailbox_domains = sample.com
virtual_mailbox_base = /var/vhosts
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_minimum_uid = 100
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
# smtp auth on ssl
disable_vrfy_command = yes
smtpd_use_tls = yes
smtpd_tls_auth_only = yes
tls_random_source = dev:/dev/urandom
smtpd_tls_cert_file = /etc/pki/tls/certs/postfix.crt
smtpd_tls_key_file = /etc/pki/tls/certs/postfix_nopass.key
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
virtual_alias_maps = hash:/etc/postfix/valias_map

/etc/postfix/master.cf

smtps     inet  n       -       n       -       -       smtpd
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING

/etc/postfix/virtual

sample.com anything

6. postfix用認証情報の作成

% cd /etc/pki/tls/certs
% sudo make postfix.key
% sudo make postfix.csr
% sudo make postfix.crt

さらに、posfix.keyのpassphraseなし版を作成。

% sudo openssl rsa -in postfix.key -out postfix_nopass.key