すべてのローカルメールを単一の外部メールに送信する

すべてのローカルメールを単一の外部メールに送信する

GoogleのSMTPサーバーを使用して、すべてのローカルメールを単一の外部メールに送信しようとしています。

Google の SMTP サーバーを使用すると、mailutils のメールを使用して外部アドレスにメールを送信できるため、機能します。

ローカルメールを外部メールにリダイレクトする機能は機能しません。アカウントでルートとしてメールを送信することをテストするときは、次のようにします。

echo "Body" | mail -s "Test Postfix To Root" root
  • メッセージを受け取ったことがありません。
  • /var/log/mail.err に新しい内容は表示されません。
  • これは/var/log/mail.logに表示されます。
Sep  4 18:48:06 desktop1204test postfix/pickup[5535]: C9326EE26: uid=1000 from=
Sep  4 18:48:06 desktop1204test postfix/cleanup[5702]: C9326EE26: message-id=
Sep  4 18:48:06 desktop1204test postfix/qmgr[5534]: C9326EE26: from=, size=401, nrcpt=1 (queue active)
Sep  4 18:48:06 desktop1204test postfix/local[5704]: C9326EE26: to=, orig_to=, relay=local, delay=0.03, delays=0.02/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
Sep  4 18:48:06 desktop1204test postfix/qmgr[5534]: C9326EE26: removed

私のもの/etc/postfix/main.cf

inet_interfaces = loopback-only
mynetworks = loopback-only
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
virtual_alias_domains = localhost.localdomain
virtual_alias_maps = hash:/etc/postfix/virtual
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

私のものetc/aliases

# See man 5 aliases for format
postmaster:    root

私の/etc/postfix/virtual:

@localhost.localdomain        [email protected]

どのように動作させることができますか?地域の郵便物が地域的に到着したくありません。すべてに送信する必要があります[email protected]


以下のコメントで提案された解決策を試しましたが、うまくいきませんでした。*: [email protected]/etc/aliases

test@desktop1204test:~$ sudo newaliases
test@desktop1204test:~$ cat /etc/aliases
# See man 5 aliases for format
postmaster:    root
*: [email protected]
test@desktop1204test:~$ sudo newaliases 
test@desktop1204test:~$ sudo service postfix restart
 * Stopping Postfix Mail Transport Agent postfix                                                     [ OK ] 
 * Starting Postfix Mail Transport Agent postfix                                                     [ OK ] 
test@desktop1204test:~$ echo "Body" | mail -s "Test Postfix To Root $(date)" root
test@desktop1204test:~$ tail /var/log/mail.err 
test@desktop1204test:~$ tail /var/log/mail.log 
......
Sep  4 22:46:12 desktop1204test postfix/master[7224]: daemon started -- version 2.9.6, configuration /etc/postfix
Sep  4 22:46:23 desktop1204test postfix/pickup[7227]: 859AFF6A8: uid=1000 from=<test>
Sep  4 22:46:23 desktop1204test postfix/cleanup[7235]: 859AFF6A8: message-id=<[email protected]>
Sep  4 22:46:23 desktop1204test postfix/qmgr[7228]: 859AFF6A8: from=<[email protected]>, size=431, nrcpt=1 (queue active)
Sep  4 22:46:23 desktop1204test postfix/local[7237]: 859AFF6A8: to=<[email protected]>, orig_to=<root@desktop1204test>, relay=local, delay=0.02, delays=0.02/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
Sep  4 22:46:23 desktop1204test postfix/qmgr[7228]: 859AFF6A8: removed
test@desktop1204test:~$

ベストアンサー1

(これはAskUbuntuで回答されました。パシソミネン、彼に本当にありがとう! )

これは仮想正規表現(/etc/postfix/virtual-regexp)を介して実行できます。

/.+@.+/ [email protected]

その後、main.cfで:

virtual_maps = hash:/etc/postfix/virtual, regexp:/etc/postfix/virtual-regexp

と地図ファイル:

postmap /etc/postfix/virtual-regexp

これにより、すべてのローカルメールの問題が解決されます。それ以外の場合は、仮想アドレスを指定する必要があります。

おすすめ記事