在Debian系統上配置郵件轉發通常涉及設置郵件傳輸代理(MTA),如Postfix、Exim或Sendmail。以下是使用Postfix配置郵件轉發的基本步驟:
對于Debian/Ubuntu系統,使用以下命令安裝Postfix:
sudo apt-get update
sudo apt-get install postfix
編輯Postfix的主配置文件 /etc/postfix/main.cf
。找到以下行并進行相應更改:
myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
inet_protocols = ipv4
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
home_mailbox = Maildir/
要將郵件轉發到另一個郵箱,請添加一個新的 relay_domains
指令,如下所示:
relay_domains = example.org, anotherdomain.net
這將允許從 example.org
和 anotherdomain.net
發送的郵件被轉發到您的服務器。
4. 重啟Postfix服務:
對于Debian/Ubuntu系統:
sudo systemctl restart postfix
對于RHEL/CentOS系統:
sudo service postfix restart
現在,您需要配置客戶端(如Outlook、Thunderbird等)以將發件人地址設置為 example.org
或 anotherdomain.net
。這樣,發送到這些域名的郵件將被轉發到您在Postfix中指定的目標郵箱。
請注意,以上步驟僅適用于使用Postfix作為郵件傳輸代理的情況。如果您使用的是Exim或其他郵件傳輸代理,配置步驟可能會有所不同。