英文:
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!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论