13
Nov.2011
While I was learning how to use django-registration app, I discover in the tutorial that I need to know how to send an email for the user to activate the registration.
我找到了这个指南,教我学习如何去使用 django-registration app,如何为用户发送电子邮件,以激活注册。
Thanks to folk at the Django chatroom, they advice me to google 'django gmail' and I discover a post at nathanostgard.com that show roughly how to do it. Here I'm going to extend a little on how to test it using shell.
1. Create a project, 创建一个项目
2. Edit settings.py with code below: 在settings.py 中添加如下代码
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'youremail@gmail.com'
EMAIL_HOST_PASSWORD = 'yourpassword'
EMAIL_PORT = 587
3. Run interactive mode, 运行交互模式
4. Import the EmailMessage module, 导入EmailMessage模块
5. Send the email, 发送邮件测试
email = EmailMessage('Subject', 'Body', t=['mickeyckm@mangoorange.com'])
email.save()
Hope it help someone :) Reference here and here.
希望能帮助别人, :) 参考资料: here and here.
我找到了这个指南,教我学习如何去使用 django-registration app,如何为用户发送电子邮件,以激活注册。
Thanks to folk at the Django chatroom, they advice me to google 'django gmail' and I discover a post at nathanostgard.com that show roughly how to do it. Here I'm going to extend a little on how to test it using shell.
1. Create a project, 创建一个项目
django-admin.py startproject gmail
2. Edit settings.py with code below: 在settings.py 中添加如下代码
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'youremail@gmail.com'
EMAIL_HOST_PASSWORD = 'yourpassword'
EMAIL_PORT = 587
3. Run interactive mode, 运行交互模式
python manage.py shell
4. Import the EmailMessage module, 导入EmailMessage模块
from django.core.mail import EmailMessage
5. Send the email, 发送邮件测试
email = EmailMessage('Subject', 'Body', t=['mickeyckm@mangoorange.com'])
email.save()
Hope it help someone :) Reference here and here.
希望能帮助别人, :) 参考资料: here and here.
相关日志
SAE Python Django试用笔记(二)
CentOS上使用nginx+uwsgi部署django
SAE Python Django试用笔记(一)
django flatpages单页面安装
在使用django-userprofile的时候报错:GoogleDataAPINotFound at 的解决方法
SAE Python Django试用笔记(二)
CentOS上使用nginx+uwsgi部署django
SAE Python Django试用笔记(一)
django flatpages单页面安装
在使用django-userprofile的时候报错:GoogleDataAPINotFound at 的解决方法
