gpt4 book ai didi

go - 如何通过 `exim -t` 发送密件抄送电子邮件? ["sendmail look alike"模式]

转载 作者:数据小太阳 更新时间:2023-10-29 03:03:16 26 4
gpt4 key购买 nike

我正在使用 golang 通过以下方法通过 exim 发送电子邮件

const sendmail = "/usr/sbin/exim"

func submitMail(m *gomail.Message) (err error) {
cmd := exec.Command(sendmail, "-t")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

pw, err := cmd.StdinPipe()
if err != nil {
return
}

err = cmd.Start()
if err != nil {
return
}

var errs [3]error
_, errs[0] = m.WriteTo(pw)
errs[1] = pw.Close()
errs[2] = cmd.Wait()
for _, err = range errs {
if err != nil {
return
}
}
return
}

as Answered on here

问题是 Exim 使用 -t

删除了 Bcc

If Exim is called with the -t option, to take recipient addresses from a message's headers, it removes any Bcc: header that may exist (after extracting its addresses), unless the message has no To: or Cc: header, in which case a Bcc: header with no addresses is left in the message, in accordance with RFC 822. If -t is not present on the command line, any existing Bcc: header is not removed.

If Exim is called to receive a message with the recipient addresses given on the command line, and there is no Bcc:, To:, or Cc: header in the message, it normally adds a To: header, listing the recipients. Some mailing list software is known to submit messages in this way, and in this case the creation of a To: header is not what is wanted. If the always_bcc option is set, Exim adds an empty Bcc: header instead in this circumstance.

found in Spec here

最佳答案

-t 的“Sendmail look alike”模式删除 Bcc: header 处理后
-t 模式下 Bcc: header 内容将附加到 (SMTP) 收件人列表中 BUT 收件人将看不到/接收 Bcc : header 。

风格指南建议:如果您在“sendmail look alike”(命令行比较模式)中使用另一个 SMTP/MTA 软件(例如 Exim)那么 使用他们提供的 sendmail 程序/二进制文件。
const sendmail = "/usr/sbin/sendmail"

关于go - 如何通过 `exim -t` 发送密件抄送电子邮件? ["sendmail look alike"模式],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49962086/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com