![Postfix/dovecot 使用外部 smtp 服务器发送自动回复](https://linux22.com/image/793243/Postfix%2Fdovecot%20%E4%BD%BF%E7%94%A8%E5%A4%96%E9%83%A8%20smtp%20%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%8F%91%E9%80%81%E8%87%AA%E5%8A%A8%E5%9B%9E%E5%A4%8D.png)
我希望 dovecot 休假扩展使用外部 smtp 服务器发送外出(休假)邮件。
当前设置:我使用 postfix 来接收邮件,使用 dovecot 来接收 imap,所有这些都在 k8s 中运行。一个部署使用 postfix,另一个部署使用 dovecot。
传入主机是 mail.domain.nl 传出(smtp)是 smtp.domain.nl
因此,一封邮件通过 postfix 发来,然后发送到 dovecot,使用别名,在那里我有一个配置文件,它说明何时“收件人”[电子邮件保护]发送休假回复
我研究了一段时间,发现使用 dovecot 你可以指定一个外部 smtp
submission_host = smtp.domain.nl:587
测试时我收到一个身份验证错误:
vacation action: failed to send vacation response to X: <smtp(mail.domain.nl:587): RCPT TO failed: 554 5.7.1 You are not authenticated It is only possible to submit mails over secure authenticated connections Please secure the connection with STARTTL and send a valid username and password before you send "MAIL FROM"> (permanent error)
是否可以为外部 smtp 设置身份验证?或者使用现有的 postfix 部署将邮件发送到外部 smtp?
postfix配置文件
postscreen_upstream_proxy_protocol = haproxy
postscreen_upstream_proxy_timeout = 5s
alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases
smtpd_tls_cert_file=/etc/postfix/ssl/tls.crt
smtpd_tls_key_file=/etc/postfix/ssl/tls.key
smtpd_tls_security_level=may
smtp_tls_CApath=/etc/ssl/certs
smtp_tls_security_level=may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
mydestination = hash:/etc/postfix/mydestinations
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command =
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
virtual_alias_domains = proxy:mysql:/etc/postfix/mysql_virtual_alias_domains.cf,hash:/etc/postfix/local_recipient_maps
virtual_alias_maps = hash:/etc/postfix/local_recipient_maps,mysql:/etc/postfix/mysql_virtual_alias_maps.cf,proxy:mysql:/etc/postfix/mysql_forwards.cf
virtual_mailbox_domains = virtual.tld
virtual_transport = lmtp:dovecot.mail.svc.cluster.local:24
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
spamc_destination_recipient_limit = 1
smtp inet n - n - 1 postscreen
smtpd pass - - n - - smtpd -o content_filter=spamc
pickup unix n - n 60 1 pickup
cleanup unix n - n - 0 cleanup
qmgr unix n - n 300 1 qmgr
#qmgr unix n - n 300 1 oqmgr
tlsmgr unix - - n 1000? 1 tlsmgr
rewrite unix - - n - - trivial-rewrite
bounce unix - - n - 0 bounce
defer unix - - n - 0 bounce
trace unix - - n - 0 bounce
verify unix - - n - 1 verify
flush unix n - n 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - n - - smtp
relay unix - - n - - smtp
-o syslog_name=postfix/$service_name
# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq unix n - n - - showq
error unix - - n - - error
retry unix - - n - - error
discard unix - - n - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - n - 200 lmtp
anvil unix - - n - 1 anvil
scache unix - - n - 1 scache
postlog unix-dgram n - n - 1 postlogd
spamc unix - n n - 200 pipe
flags=DROhu user=nobody argv=/usr/bin/spamc -u ${user} -d spamassassin.mail -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
dovecot配置文件
haproxy_trusted_networks = 10.40.0.0/16
service imap-login {
inet_listener imap {
haproxy = yes
}
inet_listener imaps {
haproxy = yes
}
}
service pop3-login {
inet_listener pop3 {
haproxy = yes
}
inet_listener pop3s {
haproxy = yes
}
}
service lmtp {
executable = lmtp -L
inet_listener {
port = 24
}
}
protocol lmtp {
postmaster_address = [email protected]
info_log_path = /dev/stdout
mail_plugins = sieve
}
submission_host = smtp.domain.nl:587
lda_original_recipient_header = X-Original-To
plugin {
sieve = /sieve/default.sieve
sieve_vacation_use_original_recipient = yes
}
# default.sieve
require ["vacation"];
if header :contains "To" ["X"] {
vacation
:days 1
:subject "Out of Office AutoReply"
"This message is to inform you that I am out of the office.";