django使用gmail
POSTED ON 02 JUL 2007 IN DEVELOPMENT DJANGO PYTHON WEB
Did a bit of running around today to get Django sending email via Gmail. It’s simple once you figure it out.
If you’re running 0.96, upgrade to the latest development version or apply the patch from ticket #2897. 0.96 does not support TLS, which Gmail requires. Then add the appropriate values to settings.py:
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'youremail@gmail.com'
EMAIL_HOST_PASSWORD = 'yourpassword'
EMAIL_PORT = 587
You can use the shell to test it:
>>> from django.core.mail import send_mail
>>> send_mail('Test', 'This is a test', to=['youremail@somewhere.com'])
Edit: Bryan commented that send_mail is deprecated. Use EmailMessage instead:
>>> from django.core.mail import EmailMessage
>>> email = EmailMessage('Hello', 'World', to=['youremail@somewhere.com'])
>>> email.send()
最新文章
- Equals和ReferenceEquals
- SDK Manager 中 没有 Support Library怎么弄?
- VS2012未找到与约束ContractName...匹配的导出
- ruby -- 问题解决(七)ActionController::InvalidAuthenticityToken解决办法
- Java操作Excel(读、写、搜索关键字、插入图片)
- Android调用WebService(转)
- openNebula 模板实例化成虚拟机【参数名为VM_NAME】
- c 语言练习__求到N的阶乘的和。
- 获取某月第一天,最后一天的sql server脚本 【转】http://blog.csdn.net/chaoowang/article/details/9167969
- Bigcommerce:intershop编程经验总结
- uva 12207 - That is Your Queue
- Enable OWIN Cross-origin Request
- zookeeper分布式锁避免羊群效应(Herd Effect)
- TransactionTemplate编程式事务管理方式的进阶使用---自定义拓展模板类
- OC调用c++函数
- 理解JavaScript中的属性描述符
- nodeJs配置
- Splay的初步学习
- Qt编译错误“GL/gl.h:No such file or directory”的解决方法
- Win10 下 VMware 的安装,以及 VMware 里安装 Ubuntu 18