Debian 預設採用 Exim4 作為 MTA。本文說明透過 dpkg-reconfigure exim4-config 互動式設定兩種常見發信模式:直接 SMTP 發送與透過 Smarthost(如 Gmail)轉發,並補充 Web 服務呼叫 Exim4 的權限與日誌注意事項。
dpkg-reconfigure exim4-config
依序選擇:
admin@ip)127.0.0.1(僅本機)、*(全開)、192.168.0.0/24(指定網段)前 6 步相同,第 2 步選擇 「使用 Smarthost 發送;無本地郵件」,第 7 步填入真實 SMTP 伺服器:
smtp.gmail.com
/etc/exim4/passwd.client —— SMTP 認證帳密:
stu.xjtu.edu.cn:flowaters@stu.xjtu.edu.cn:password
gmail-smtp.l.google.com:admin@vixp.net:password
/etc/email-addresses —— 系統發信預設寄件者:
user: admin@ip
update-exim4.conf
service exim4 restart
mail 群組,才有發信權限。/var/mail/<username>/ 下。mail() 或 sendmail -t 介面,確保 sendmail_path 指向 /usr/sbin/sendmail(Exim4 提供的相容連結)。