Humanity

Edit the world by your favorite way

Postfixで受信したメールを全てGMailへ転送

tyru@hoge.localdomain→tyru.exe+tyru-at-hoge@gmail.com
みたいにしてどこから送られてきたかもアドレスに含める設定。

/etc/postfix/main.cf

mydomain = localdomain
myhostname = hoge.localdomain
myorigin = $myhostname

# Relay to GMail
mydestination =
relayhost = [smtp.gmail.com]:587

# Append this host's domain to a mail w/o domain.
append_at_myorigin  = yes
# Append '.localdomain' to a locally-sent mail.
append_dot_mydomain = yes
# Rewrite envelope-from of a local mail.
smtp_generic_maps = regexp:/etc/postfix/generic

# SMTP
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/gmail
smtp_use_tls = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_sasl_mechanism_filter = plain

# postmap /etc/postfix/generic

# Replace any address to tyru.exe@gmail.com
#/.*/   tyru.exe@gmail.com

# $1: user, $2: hostname
/([^@]+)@(\w+).localdomain/     tyru.exe+$1-at-$2@gmail.com

# chown root:root /etc/postfix/sasl/gmail
# chmod 600 /etc/postfix/sasl/gmail
# postmap /etc/postfix/sasl/gmail

[smtp.gmail.com]:587    tyru.exe@gmail.com:password_of_gmail


で、他のホストからも

mydestination =
relayhost = [hoge]:25

とかしてホストhogeにメールを転送すればGMailに転送される。はず

参考URL

全て日本語で情報が得られるのはうれしい。