英文:
Go on Google App Engine returns error: API error 1 (mail: INTERNAL_ERROR): Internal error
问题
我有点迷失。通过GAE发送电子邮件似乎不起作用。抛出的错误是:无法发送电子邮件:API错误1(mail: INTERNAL_ERROR):内部错误
。
我尝试了几个不同的发件人地址,但似乎没有一个能够始终工作。有时它可以工作,有时它不行。在本地一切似乎都没问题(当然没有发送邮件,但日志显示发送了假设的电子邮件)。
代码:
func (coinflip *Coinflip) mailParticipants(context appengine.Context, key *datastore.Key) {
participants, _, _ := coinflip.fetchParticipants(context)
for i := range coinflip.Participants {
msg := &mail.Message{
Sender: "X...@gmail.com",
ReplyTo: "X...@gmail.com",
To: []string{participants[i].Email},
Subject: "What will it be? " + coinflip.Head + " or " + coinflip.Tail + "?",
Body: fmt.Sprintf(confirmMessage, "http://www.flipco.in/register/" + key.Encode() + "?email=" + participants[i].Email),
}
if err := mail.Send(context, msg); err != nil {
context.Errorf("Couldn't send email: %v", err)
}
}
}
const confirmMessage = `
有人与您创建了一个抛硬币游戏。
请点击下面的链接确认您的电子邮件地址:
%s
`
完整的代码可以在Github上找到:https://github.com/haarts/flipco.in
感谢您的帮助!
顺祝商祺,
英文:
I'm a bit lost. Sending email via GAE does not appear to work. The error thrown is:
Couldn't send email: API error 1 (mail: INTERNAL_ERROR): Internal error
I have tried several different Sender addresses but non seem to work consistently. Sometimes it works sometimes it doesn't. Locally every seems OK (no mail send of course but the log shows send hypothetical emails).
The code:
func (coinflip *Coinflip) mailParticipants(context appengine.Context, key *datastore.Key) {
participants, _, _ := coinflip.fetchParticipants(context)
for i := range coinflip.Participants {
msg := &mail.Message{
Sender: "X...@gmail.com",
ReplyTo: "X...@gmail.com",
To: []string{participants[i].Email},
Subject: "What will it be? " + coinflip.Head + " or " + coinflip.Tail + "?",
Body: fmt.Sprintf(confirmMessage, "http://www.flipco.in/register/" + key.Encode() + "?email=" + participants[i].Email),
}
if err := mail.Send(context, msg); err != nil {
context.Errorf("Couldn't send email: %v", err)
}
}
}
const confirmMessage = `
Someone created a coin toss with you.
Please confirm your email address by clicking on the link below:
%s
`
The complete code can be found on Github: https://github.com/haarts/flipco.in
Thanks for your help!
With kind regards,
答案1
得分: 2
你的appid是什么?已知问题是,如果你的appid与用于创建应用程序的gmail帐户名称相同,邮件发送将失败。请参阅此处:http://code.google.com/p/googleappengine/issues/detail?id=5320
英文:
What's your appid? There's a known problem that if your appid is the same as the gmail account name used to create the app, mail sending will fail. See here: http://code.google.com/p/googleappengine/issues/detail?id=5320
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论