简体   繁体   English

如何从Google App Engine中的django App发送电子邮件

[英]How to send emails from django App in Google App Engine

I have created one Django Application,also hosted it on the google app engine. 我创建了一个Django应用程序,也在谷歌应用程序引擎上托管它。 I can send emails from django application, but after hosting it to app engine I cant do that.I really stuck with this problem, so please tell me if there is any solution for using django email functions in Google app engine. 我可以从django应用程序发送电子邮件,但在将其托管到应用程序引擎后我无法做到这一点。我真的遇到了这个问题,所以请告诉我是否有任何解决方案在谷歌应用程序引擎中使用django电子邮件功能。

I have tried appengine_django but it not working. 我尝试了appengine_django,但它没有用。

Django version 1.3.1 Django版本1.3.1

python version 2.6.5 python版本2.6.5

By default Django comes with an email backend that uses sendmail to send email. 默认情况下,Django附带一个使用sendmail发送电子邮件的电子邮件后端。 Sendmail is not available on App Engine. App Engine上没有Sendmail。

If you use Django-nonrel, it comes with an email backend that uses GAE's email service. 如果您使用Django-nonrel,它会附带一个使用GAE电子邮件服务的电子邮件后端。 https://github.com/django-nonrel/djangoappengine , look in mail.py https://github.com/django-nonrel/djangoappengine ,查看mail.py

As far as I know, it's only been tested to work with the entire Django-nonrel framework. 据我所知,它只是经过测试才能使用整个Django-nonrel框架。 If you're using it without the rest of Django-nonrel, some hackery is required. 如果你在没有剩下Django-nonrel的情况下使用它,那么就需要一些hackery。

Yeah appengine_django does not work. 是的appengine_django不起作用。 you need to use djangoappengine.mail.EmailBackend so your settings.py should have: 你需要使用djangoappengine.mail.EmailBackend所以你的settings.py应该有:

EMAIL_BACKEND = 'djangoappengine.mail.EmailBackend'

Then you can use django's native send_mail function to send emails. 然后你可以使用django的本机send_mail函数来发送电子邮件。 I have myself tested it to work. 我自己测试了它的工作原理。

Google only allows you to send emails from a domain name that they control in the google app engine. Google只允许您从他们在Google应用引擎中控制的域名发送电子邮件。 So you will either have to send it from the test domain they give you, a gmail account, or you need to use their name servers for your domain name. 因此,您必须从他们提供给您的测试域,gmail帐户发送它,或者您需要将他们的名称服务器用于您的域名。

Problem solved. 问题解决了。

Just follow the link. 只需点击链接即可。 http://andialbrecht.de/blog/2009/11/04/pluggable-app-engine-e-mail-backends-for-django.html http://andialbrecht.de/blog/2009/11/04/pluggable-app-engine-e-mail-backends-for-django.html

I think this is the easiest method for using Django email functions in Google App Engine. 我认为这是在Google App Engine中使用Django电子邮件功能的最简单方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM