2016-04-08 3 views
0

すべてのメールをGmailのメールアドレスに転送するように設定された[email protected]というメールがあります。 Gmailメールボックスからの返信[email protected]からメールを送信します。 これまでのgmailでは、簡単な設定 - >アカウントとインポート - >あなたの所有する別のメールアドレスを追加して、自分が所有していることを確認するための確認コード付きのメールを送信するオプションを許可しました。しかし、今すぐ利用可能なオプションは "あなたのSMTPサーバー経由でメールを送信する"ですpostfixをGmailのsmtpリレーとして安全に設定する方法

私は後置されたサーバーを持っています。 postfixは、このサーバから発信された電子メールを送信するためにのみ使用されます。 iptablesは異なるPC /サーバからのpostfixへの接続を許可しないので、誰も私のサーバから電子メールを送信できないため、安全です。

私はたくさん探していましたが、smtp.gmail.comでメールを送信するようにpostfixを設定する方法がたくさんありました。 しかし、私はそれを逆にする必要があります - gmailは安全な方法で私のpostfix smtpサーバーを通して電子メールを送信する必要があります。

これを達成する方法に関する調査結果を教えてください。

答えて

0

SASL構成

https://wiki.debian.org/PostfixAndSASL#Implementation_using_Cyrus_SASL

sudo apt-get install sasl2-bin 

sudo nano /etc/postfix/sasl/smtpd.conf 
pwcheck_method: saslauthd 
auxprop_plugin: sasldb 
mech_list: PLAIN LOGIN 
#------------- 

cp /etc/default/saslauthd /etc/default/saslauthd-postfix 

sudo nano /etc/default/saslauthd-postfix 
START=yes 
DESC="SASL Auth. Daemon for Postfix" 
NAME="saslauthd-postf"  # max. 15 char. 
# Option -m sets working dir for saslauthd (contains socket) 
OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd"  # postfix/smtp in chroot() 
#-------------- 

sudo dpkg-statoverride --add root sasl 710 /var/spool/postfix/var/run/saslauthd 
sudo adduser postfix sasl 

#sudo saslpasswd2 -c -u mydomain.com support 

ユーザーがサポートしていませ、ログイン名として[email protected]を指定する必要があります。 は、残念ながら、レルムなし オプションは動作しません、それはあなたのサーバーの折返しのDNSを明示的レルムが働く状態が、2番目は動作しません

sudo saslpasswd2 -c gmail 

# list all users 
sudo sasldblistusers2 

# to get password which may be used in telnet 
# echo -ne '\0username\0pswd' | openssl enc -base64 

sudo services saslauthd start 

#sudo testsaslauthd -u support -p pswd -r mydomain.com 
#sudo testsaslauthd -u [email protected] -p pswd 

まずバリアントとしてデフォルト設定されます、このバリアントを続行することができませんでした。したがって、バリアントを選んだ分野ずに25ポートの

sudo testsaslauthd -u gmail -p pswd 

# delete user 
sudo testsaslauthd -d username  

sudo service saslauthd restart 

POSTFIXリレー

http://www.admin-hints.com/2009/04/how-to-limit-amount-of-messages-per.html

nano /etc/postfix/main.cf 
#Clients that are excluded from connection count (default: $mynetworks) 
smtpd_client_event_limit_exceptions = $mynetworks 
#The time unit over which client connection rates and other rates are calculated. (default: 60s) 
anvil_rate_time_unit = 86400s 
#How frequently the server logs peak usage information. (default: 600s) 
anvil_status_update_time = 120s 
#The maximal number of message delivery requests that any client is allowed to make to this service per time unit. (default: 0) To disable this feature, specify a limit of 0. 
smtpd_client_message_rate_limit = 200 

smtpd_sasl_auth_enable = yes 
smtpd_sasl_local_domain = $myhostname 
smtpd_tls_security_level=may 
smtpd_sasl_security_options = noanonymous 
smtpd_client_restrictions=permit_mynetworks,permit_sasl_authenticated,reject 

sudo nano /etc/postfix/master.cf 
# at the line where commented "#submission inet n" starts 
submission inet n  -  -  -  -  smtpd 
    -o syslog_name=postfix/submission 
    -o smtpd_tls_security_level=encrypt 
    -o smtpd_sasl_auth_enable=yes 
    -o smtpd_sasl_security_options=noanonymous 
    -o smtpd_reject_unlisted_recipient=no 
    -o smtpd_client_restrictions=permit_sasl_authenticated,reject 
    -o smtpd_relay_restrictions=permit_sasl_authenticated,reject 

チェック(587はTLSを使用しています)、私のサーバーのみ587ポートおよび25は、iptablesの

によってブロックされて明らかになりました

telnetによるテスト

telnet mydomain.com 25 
ehlo dummy 
auth plain ARdtYW4sAGRdY1d4cyM9ZnRn      # how to get auth plain with your password read above 
MAIL FROM: [email protected] 
RCPT TO: [email protected] 
DATA 
354 End data with <CR><LF>.<CR><LF> 
Subject: test subject 

Hello, 

This is test message 
. 
# dot at the end 
quit 

予期しないものがここでエラーを探す場合

tail -f /var/log/mail.log 
関連する問題