zoukankan      html  css  js  c++  java
  • 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()

  • 相关阅读:
    链表数据-PHP的实现
    关于go的init函数
    socket小计
    很随笔
    go获取当前项目下所有依赖包
    关于synergy的问题
    二叉树的最大路径和
    大数求和
    重载<<运算符第二个参数必须加上const
    表达式求值
  • 原文地址:https://www.cnblogs.com/cmsd/p/5167339.html
Copyright © 2011-2022 走看看