SMTP在发送邮件时没有包含发件人地址

huangapple go评论80阅读模式
英文:

SMTP not including from address in sent mail

问题

抱歉,如果这是一个愚蠢的问题,但是当使用smtp.SendMail时,我似乎无法包含发件人地址。
我正在使用https://code.google.com/p/go-wiki/wiki/SendingMail作为大纲。

我已经努力了几个小时了,所以任何帮助都将是很好的。

我可以正常发送消息,只是发件人地址似乎保持为空白;这在与Gmail等一起使用时效果不好,因为它们只会将其视为垃圾邮件。

发件人地址是否应该是特殊的东西?(第一次做这个,所以可能只是缺少一些领域知识)....

我注意到smtp.PlainAuth中的用户名与示例中的发件人地址不同;我一直在同时使用相同的字符串。

英文:

Sorry if this is a stupid question, but I can't seem to get smtp to include the from address when using smtp.SendMail.
I'm using https://code.google.com/p/go-wiki/wiki/SendingMail as an outline.

Have been struggling to do so for hours, so any help would be great.

I can send messages fine, just the from address seems to stay blank; which doesn't work well with gmail and etc, as they just consider it spam.

Is the from address meant to be something special or something? (first time doing this, so might just be missing some domain knowledge)....

I've noted that the username in smtp.PlainAuth is not the same as the from address in the example given; I've been using the same string for both..

答案1

得分: 4

SMTP模块期望的正文实际上是用户提供的标题和正文内容。它们由两个换行符分隔。

因此,您提供给SMTP的正文应该类似于以下内容:

From: Me <me@me.com>
Subject: This is a test email from me

Hello this is a test email!
英文:

The body that the SMTP module is expecting is actually both user supplied headers and the body content. They're separated by two newlines.

So the body you supply to smtp should look something like this:

From: Me <me@me.com>
Subject: This is a test email from me

Hello this is a test email!

huangapple
  • 本文由 发表于 2013年4月28日 13:29:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/16259928.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定