ユーザ用ツール

サイト用ツール


01_linux:03_mail:postfix_virtual

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
01_linux:03_mail:postfix_virtual [2014/10/30 00:18] – [postfixインストール] matsui01_linux:03_mail:postfix_virtual [2014/10/30 00:49] (現在) matsui
行 1: 行 1:
 +====== Postfix Virtual Dovecot ======
  
 +単純なpostfixでバーチャルドメインの設定
 +
 +====== postfixインストール ======
 +<code console>
 + # yum install postfix dovecot
 +</code>
 +
 +
 +<code console>
 +# cat /etc/postfix/main.cf
 +
 +queue_directory = /var/spool/postfix 
 +command_directory = /usr/sbin
 +daemon_directory = /usr/libexec/postfix
 +mail_owner = postfix
 +myhostname = example.com
 +mydomain = example.com
 +myorigin = $mydomain
 +inet_interfaces = all
 +mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
 +unknown_local_recipient_reject_code = 550
 +mynetworks = 127.0.0.0/8
 +alias_maps = hash:/etc/aliases
 +alias_database = hash:/etc/aliases
 +home_mailbox = Maildir/
 +smtpd_banner = $myhostname ESMTP unknown
 +debug_peer_level = 2
 +debugger_command =
 + PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
 + xxgdb $daemon_directory/$process_name $process_id & sleep 5
 +sendmail_path = /usr/sbin/sendmail.postfix
 +newaliases_path = /usr/bin/newaliases.postfix
 +mailq_path = /usr/bin/mailq.postfix
 +setgid_group = postdrop
 +html_directory = no
 +manpage_directory = /usr/share/man
 +sample_directory = /usr/share/doc/postfix-2.3.3/samples
 +readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES
 +smtpd_sasl_auth_enable = yes 
 +smtpd_sasl_type = dovecot 
 +smtpd_sasl_path = private/auth 
 +smtpd_sasl_local_domain = $myhostname 
 +smtpd_client_restrictions =
 + reject_rbl_client spamcop.net,
 + reject_rbl_client dynablock.wirehub.net,
 + permit
 +smtpd_sender_restrictions =
 + reject_non_fqdn_sender,
 + reject_unknown_sender_domain,
 + permit
 +smtpd_recipient_restrictions = 
 + permit_mynetworks, 
 + permit_sasl_authenticated,
 + #check_client_access hash:/etc/postfix/pop-before-smtp,
 + reject_unlisted_recipient,
 + reject_non_fqdn_recipient,
 + reject_unauth_destination 
 +virtual_alias_maps= hash:/etc/postfix/virtual
 +</code>
 +
 +====== Dovecotインストール ======
 +<box 70% left round orange>
 +  # cat /etc/dovecot.conf
 +  
 +  mail_location = maildir:~/Maildir
 +  protocols = imap imaps pop3 pop3s
 +  protocol imap {
 +  }
 +    
 +  protocol pop3 {
 +  }
 +  protocol lda {
 +    postmaster_address = postmaster@example.com
 +  }
 +  auth default {
 +    mechanisms = plain
 +    passdb pam {
 +    }
 +    userdb passwd {
 +    }
 +   socket listen {
 +    client {
 +     path = /var/spool/postfix/private/auth
 +     mode = 0660
 +     user = postfix
 +     group = postfix
 +    }
 +   }
 +    user = root
 +  }
 +  dict {
 +  }
 +  plugin {
 +  }
 +</box>
 +
 +====== ヴァーチャルファイル作成 ======
 +<box 70% left round orange>
 +# vi /etc/portfix/virtual \\
 +admin@aaaa.com   admin \\
 +\\
 +# postmap /etc/portfix/virtual
 +</box>
 +
 +
 +===== mailの送信元アドレスにホスト名が入る =====
 +
 +mailコマンドを使ってメールを送信すると送信元アドレスが [アカウント]@[ホスト].[ドメイン] となってしまう。
 +
 +本当はmailコマンドで送った時、[アカウント]@[ドメイン]となって欲しい
 +main.cfでは、myorigin をちゃんと$mydomainを指定している。
 +
 +<code console>
 +# cat /etc/postfix/main.cf
 +myorigin = $mydomain
 +</code>
 +
 +=== 原因 ===
 +mailコマンドが使用するmta設定がsendmailのままとなっていると、@以下に/etc/sysconf/networkのHOSTNAMEを使用する仕様
 +
 +# ls -l /etc/alternatives/mta
 +lrwxrwxrwx 1 root root 26 Oct 30 09:38 /etc/alternatives/mta -> /usr/sbin/sendmail.postfix
 +
 +
 +=== 対応方法 ===
 +
 +下記のコマンドで、MTAを切り替えてあげればOK
 +これで、ただしく@以下がmyorigin で送信されます。
 +
 +<code console>
 +# alternatives --config mta
 +2 プログラムがあり 'mta' を提供します。
 +  選択       コマンド
 +-----------------------------------------------
 +*+ 1           /usr/sbin/sendmail.sendmail
 +             /usr/sbin/sendmail.postfix
 +Enter to keep the current selection[+], or type selection number:
 +</code>
 +
 +<code console>
 +# ls -l /etc/alternatives/mta
 +lrwxrwxrwx 1 root root 26 Oct 30 09:38 /etc/alternatives/mta -> /usr/sbin/sendmail.postfix
 +</code>