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()

最新文章

  1. Equals和ReferenceEquals
  2. SDK Manager 中 没有 Support Library怎么弄?
  3. VS2012未找到与约束ContractName...匹配的导出
  4. ruby -- 问题解决(七)ActionController::InvalidAuthenticityToken解决办法
  5. Java操作Excel(读、写、搜索关键字、插入图片)
  6. Android调用WebService(转)
  7. openNebula 模板实例化成虚拟机【参数名为VM_NAME】
  8. c 语言练习__求到N的阶乘的和。
  9. 获取某月第一天,最后一天的sql server脚本 【转】http://blog.csdn.net/chaoowang/article/details/9167969
  10. Bigcommerce:intershop编程经验总结
  11. uva 12207 - That is Your Queue
  12. Enable OWIN Cross-origin Request
  13. zookeeper分布式锁避免羊群效应(Herd Effect)
  14. TransactionTemplate编程式事务管理方式的进阶使用---自定义拓展模板类
  15. OC调用c++函数
  16. 理解JavaScript中的属性描述符
  17. nodeJs配置
  18. Splay的初步学习
  19. Qt编译错误“GL/gl.h:No such file or directory”的解决方法
  20. Win10 下 VMware 的安装,以及 VMware 里安装 Ubuntu 18

热门文章

  1. HDU-敌兵布阵
  2. 深入浅出 - Android系统移植与平台开发(四)- Android启动流程
  3. SpringMVC整合Shiro
  4. Bone Collector(01背包)
  5. 关于web前端(知乎上收集)
  6. [LintCode] Generate Parentheses 生成括号
  7. odoo XMLRPC 新库 OdooRPC 尝鲜
  8. css 实现三角形的原理
  9. [转]Oracle数据库ASH和AWR的简单介绍
  10. jsp页面向后台传值出现乱码的问题