如何設定postfix發送郵件到外部SMTP伺服器?

如何設定postfix發送郵件到外部SMTP伺服器?

我有一台機器http://phabricator.org/在其上進行設置,我想設置 postfix 以啟用電子郵件發送到我公司的郵箱(對於來自例如的通知電子郵件[email protected])。

假設 SMTP 伺服器是smtp.company.net

我需要做什麼才能允許postfix在沒有帳戶的情況下向該伺服器發送電子郵件?跟relayhost裡面的配置有關係嗎/etc/postfix/main.cf

我在該網路中的另一台機器上設定了 Jenkins,我唯一需要設定的是 SMTP 的主機名稱(此處smtp.company.net)和用於發送電子郵件的管理員電子郵件(但沒有該電子郵件的帳戶)在STMP 伺服器上)。

我已經設定了 Jenkins 和 phabricator LDAP 身份驗證,但由於某種神奇的原因 Jenkins 可以工作,我在以下位置收到此錯誤/var/log/maillog

Oct  6 16:36:22 hostname_machine postfix/smtp[15077]: fatal: open database /etc/postfix/sasl_passwd.db: No such file or directory
Oct  6 16:36:23 hostname_machine postfix/master[14965]: warning: process /usr/libexec/postfix/smtp pid 15077 exit status 1
Oct  6 16:36:23 hostname_machine postfix/master[14965]: warning: /usr/libexec/postfix/smtp: bad command startup -- throttling

我可以sasl_passwd.db用以下方法創建這個

postmap /etc/postfix/sasl_passwd

但這不是重點,因為我有 LDAP 身份驗證,並且沒有這個「通知電子郵件發送者」的帳戶,並且......它在 Jenkins 上神奇地工作。

筆記 將我的個人帳戶憑證手動新增到sasl_passwd

echo "smtp.company.net myusername:mypassword" > /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
service postfix restart

我得到這個postmap /etc/postfix/sasl_passwd

Oct  6 16:42:28 hostname_machine postfix/pickup[15611]: 9237FE4E6E: uid=0 from=<root>
Oct  6 16:42:28 hostname_machine postfix/trivial-rewrite[15650]: warning: database /etc/postfix/virtual.db is older than source file /etc/postfix/virtual
Oct  6 16:42:28 hostname_machine postfix/cleanup[15648]: 9237FE4E6E: message-id=<[email protected]>
Oct  6 16:42:28 hostname_machine postfix/qmgr[15612]: 9237FE4E6E: from=<[email protected]>, size=545, nrcpt=1 (queue active)
Oct  6 16:42:29 hostname_machine postfix/smtp[15614]: 9237FE4E6E: to=<[email protected]>, relay=smtp.company.net[10.115.11.11]:25, delay=0.51, delays=0.16/0/0.17/0.18, dsn=2.0.0, status=sent (250 2.0.0 s96DgSY3016471 Message accepted for delivery)
Oct  6 16:42:29 hostname_machine postfix/qmgr[15612]: 9237FE4E6E: removed

相關內容