Linux?
sudo yum install postfix
service sendmail stop chkconfig sendmail off
alternatives --config mta
chkconfig --add postfix chkconfig postfix on
sudo vi /etc/postfix/main.cf
myhostname = mail.example.com
mydomain = example.com
myorigin = $myhostname
inet_interfaces = 127.0.0.1
inet_protocols = ipv4
mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks = 127.0.0.0/8
relayhost = [mail.example.com]
sudo /etc/init.d/postfix start
mail example@example.com
. や .. 、ctrl + d で送信。
sudo apt-get install mailutils
yum install mailx
root : mailaddress@hogehoge.com
sudo newaliases
(2)メールユーザ追加(SSHによるリモート接続もできるようにする場合) ※例としてユーザ名をcentosとする [root@centos ~]# useradd centos ← ユーザ追加 [root@centos ~]# passwd centos ← パスワード設定 Changing password for user centos. New UNIX password: ← パスワード応答 Retype new UNIX password: ← パスワード応答(確認) passwd: all authentication tokens updated successfully. 以下はSMTP-Auth用ユーザ名、パスワードとシステムのユーザ名、パスワードを別々にする場合のみ [root@centos ~]# echo "パスワード" | saslpasswd2 -p -u linux.hoge.com -c centos ← SMTP-Auth用ユーザ/パスワード登録 [root@centos ~]# sasldblistusers2 ← SMTP-Auth用ユーザ名、パスワード確認 centos@linux.hoge.com: userPassword [root@centos ~]# chgrp postfix /etc/sasldb2 ← sasldb2所有グループをpostfixに変更※最初の1回のみ ※SMTP-Auth用ユーザ名、パスワードを削除する場合 [root@centos ~]# saslpasswd2 -d centos -u linux.hoge.com ← SMTP-Auth用ユーザ名、パスワード削除
echo test | mail root
mail mailaddress@example.net
sudo update-alternatives --config mailx
myhostname = mail.tar3.net mydomain = tar3.net myorigin = $mydomain inet_interfaces = all inet_protocols = ipv4 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain mynetworks = 192.168.1.0/24, 127.0.0.0/8 relay_domains = $mydestination relayhost = [smtp.hoge.com]:(portno) 例) [smtp.hoge.com]:587 home_mailbox = Maildir/
#SMTPのVRFYコマンドを使用禁止
#VRFYはアカウントが実在するか確認するコマンド
#でたらめなユーザ問い合わせを行う悪質なプログラムによる
#アカウント流出を防ぐ
disable_vrfy_command = yes
#メール送信時にアカウント名・パスワードをサーバに通知し
#メールサーバから認証を受ける(SASL認証)
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/authinfo
smtp_sasl_mechanism_filter = plain
#sasl認証に対応していないメーラは拒否
broken_sasl_auth_clients = yes
#クライアントに対しての認証設定
smtp_sasl_tls_security_options = noanonymous
smtpd_sasl_security_options = noanonymous
#認証に使用するサーバを指定
smtpd_sasl_local_domain = $myhostname
#ホストの接続に関しての設定
#permit_mynetworks :クライアントIPが $mynetworks に属していた場合は要求を許可
#reject_rbl_client :RBLサイトに登録されているブラックサイトを拒否
#reject_unknown_client:クライアントIPが DNS に PTR レコードを持たない場合等に
# 要求を拒否
smtpd_client_restrictions = permit_mynetworks,
#reject_rhsbl_client rhsbl.ahbl.org,
reject_rbl_client spamcop.net,
reject_rbl_client dynablock.wirehub.net,
reject_rbl_client sbl.spamhaus.org,
reject_unknown_client,
permit
#メール中継の設定
#permit_sasl_authenticated:SMTP_AUTHに認証されたクライアントを許可
#reject_unauth_destination:以下のアドレスにマッチするものは許可
# $inet_interfaces
# $mydestination
# $virtual_alias_domains
# $virtual_mailbox_domains
# 以下のドメイン・サブドメインは許可
# $relay_domains
# 上記以外は全て拒否
smtpd_recipient_restrictions = permit_mynetworks,
permit_sasl_authenticated,
reject_unauth_destination
#message 上限サイズの変更
message_size_limit = 10485760
#tls setting
smtp_use_tls = yes
smtpd_tls_cert_file = /etc/postfix/tls_key/server.crt
smtpd_tls_key_file = /etc/postfix/tls_key/server.key.plain
smtpd_tls_session_cache_database = btree:/var/lib/postfix/smtpd_scachemkdir /etc/skel/Maildir chmod 700 /etc/skel/Maildir
mkdir /home/linux/Maildir
chmod 700 /home/linux/Maildir
chown linux:linux /home/linux/Maildir
(isp smtp server) <- 認証1 <- (lan内 smtp server) <- 認証2 <- PC <- thunderbird
yum install cyrus-sasl
pwcheck_method: auxprop #mech_list: plain login
[smtp.gmail.com]:587 xxxxxxxx:xxxxxxxx
postmap /etc/postfix/authinfo
パスワードを入力 Password: 確認入力(上記のパスワードと同じ物を入れる) Again (for verification):
linux@hoge.com: userPassword
-rw------- 1 root root 12288 7月 21 05:21 /etc/sasldb2 ↑ ↑ グループ読取(なし) グループ(root)
-rw-r----- 1 root postfix 12288 7月 21 05:21 /etc/sasldb2
smtp inet n - n - - smtpd submission inet n - n - - smtpd # -o smtpd_tls_security_level=encrypt # -o smtpd_enforce_tls=yes -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject
chkconfig postfix on chkconfig saslauthd on
service postfix start service saslauthd start
mail_location = maildir:~/Maildir
ssl = yes ssl_cert = </etc/postfix/tls_key/server.crt ssl_key = </etc/postfix/tls_key/server.key.plain #プレインテキスト認証を許可しない disable_plaintext_auth = yes
disable_plaintext_auth = yes auth_mechanisms = plain
service dovecot start
chkconfig dovecot on
※PHP5.4から文字化け関連のトラブルがしんどいです。
自分は諦めてrainloopというWebMailソフトを使用することにしました。
ここのサイトが詳しかったですが、
自分の環境では直りませんでした。。。
cd /usr/share/squirrelmail/ mkdir data chown :[apache group] data/ cd data/ ln -s /etc/squirrelmail/default_pref default_pref
session.save_path = "/var/lib/php/session"
cd /var/lib/php/ chown -R :ApacheGroup session
wget http://repository.rainloop.net/v2/webmail/rainloop-latest.zip
mkdir /var/www/html/rainloop
unzip rainloop-latest.zip -d /var/www/html/rainloop
find /var/www/html/rainloop -type d -exec chmod 755 {} \;
find /var/www/html/rainloop -type f -exec chmod 644 {} \;
chown -R apache. /var/www/html/rainloop
Alias /rainloop /var/www/rainloop <Directory /var/www/rainloop> AllowOverride AuthConfig order allow,deny allow from all </Directory> <Directory /var/www/rainloopi/data> Require all denied </Directory>