2011-08-20 121 views
1

我试图在我的网站上使用应用引擎邮件发送服务。 目前,我已经把一些简单的:Google应用引擎发送邮件服务引发异常

message = mail.EmailMessage(sender="Subhranath Chunder <[email protected]>", \ 
            subject="Your account has been approved") 
message.to = "Subhranath Chunder <[email protected]>" 
message.body = "Just another message" 
message.send() 

但每一次的代码处理程序提出了这样的错误:

2011-08-20 04:44:36.988 
ApplicationError: 1 Internal error 
Traceback (most recent call last): 
    File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 703, in __call__ 
    handler.post(*groups) 
    File "/base/data/home/apps/s~subhranath/0-2.352669327317975990/index.py", line 71, in post 
    message.send() 
    File "/base/python_runtime/python_lib/versions/1/google/appengine/api/mail.py", line 895, in send 
    raise e 
ApplicationError: ApplicationError: 1 Internal error 

我作为一个不同版本的代码,而不是默认的一个。我无法将此版本更改为默认版本,除非此错误得到解决。任何想法为什么发生这种情况?

回答

0

似乎是一个应用程序引擎系统故障。现在相同的代码正在工作,没有任何新的部署。

0

发件人必须拥有特权或是登录用户。所以[email protected]应该对你的位置拥有管理员权限,或者是登录用户来运行你的代码。

最基本的例子将只是一个HTTP GET发送电子邮件:

def get(self):  
    message = mail.EmailMessage(sender='[email protected]', subject='Email') 
    message.to='[email protected]' 
    message.body = os.environ.get('HTTP_HOST')  
    message.send() 

如果你想发送电子邮件作为登录的用户,你可以发送一个变量:

senderemail = users.get_current_user().email() if users.get_current_user() else '[email protected]' 

我认为你发布的错误消息不是很清楚,如果它仍然存在,我建议使用日志记录和异常来获取有关错误消息的更多信息。

+0

用户'[email protected]'是应用程序的唯一管理员,这是我。 :) 相同的代码刚开始工作几个小时后。我甚至没有进行新的部署。 :( –