额外的信息被注入到通过SMTP电子邮件电子邮件、信息、SMTP

2023-09-11 11:49:20 作者:少年已不再年少

我一直有一个很奇怪的问题。我有一个golang服务器,我使用的是网/ SMTP来发送电子邮件。它进行得很顺利,直到我们实现了一些额外的信息已被注入到邮件,和雅虎开始忽略我们的电子邮件。不管怎么说,这被发送出去我们的信息体的信息是:

I've been having a really strange problem. I have a golang server, and I'm using net/smtp to send out emails. It was going well until we realized some extra information was being injected into emails, and that yahoo started ignoring our emails. Anyways, the information that gets sent out for the body of our info is:

From: test@withheld.com
To: me@gmail.com
Subject: Testing
MIME-version: 1.0;
Content-Type: text/html; charset="UTF-8";
<html>
     <b> Testing </b>
</html>

这随后被发送到亚马逊SES,我们用来发送邮件帐户托管在GoDaddy的。 当电子邮件到达时,我展示使用Gmail原邮件正文中,我得到这样的:

That then gets sent to Amazon SES, the account we used to send emails is hosted on godaddy. When the email arrives, and I show the original message body using gmail, I get this:

From: test@withheld.com
To: me@gmail.com
Subject: Testing
MIME-version: 1.0;
Content-Type: text/html; charset="UTF-8";

<html>
    <b> Testing </b>
</html>
Date: Wed, 29 Oct 2014 11:00:56 +0000
Message-ID: <[Lots of Numbers]@email.amazonses.com>
X-SES-Outgoing: [Some Numbers]
Feedback-ID: us-east-1.[numbers]=:AmazonSES

因此​​,那些4个额外的领域获得上涨给我们的邮件正文,这是我presume会导致我们得到标记为垃圾邮件或更糟(雅虎是残酷的。)有谁知道这4条线可能已添加的?肯定看起来像SES,但我相信Godaddy的少了一大堆。

So those 4 additional fields get tacked on to our message bodies, which I presume would lead to us getting mark as spam or worse (yahoo is brutal.) Does anyone know where these 4 lines could have been added on? Definitely seems like SES, but I trust Godaddy a whole lot less.

(在一些情况,我们在我们的身体有不同的间距分,并且信息将接着注入在消息体随机位置)

(There were points where we had different spacing in our bodies, and the information would then inject into random locations in the message bodies)

推荐答案

您需要将头和身体之间添加一个换行符( \ r \ñ)。

You need to add a newline (\r\n) between the header and the body.

如果你想另外一个简单的方法来发送电子邮件中去,你可以使用 Gomail (我敢作者):

Also if you want an easy way to send emails in Go you can use Gomail (I'm the author):

package main

import (
    "gopkg.in/gomail.v2"
)

func main() {
    m := gomail.NewMessage()
    m.SetHeader("From", "test@withheld.com")
    m.SetHeader("To", "me@gmail.com")
    m.SetHeader("Subject", "Testing")
    m.SetBody("text/html", `<html>
     <b> Testing </b>
</html>`)

    d := gomail.NewPlainDialer("smtp.example.com", 587, "user", "123456")
    if err := d.DialAndSend(m); err != nil {
        panic(err)
    }
}