django メールの送信テストを行う

django でメール送信するテストを行う。

settings.py の設定

// project/settings.py

EMAIL_HOST = 'smtp.yourdomain.com'
EMAIL_HOST_USER = 'your-username@yourdomain.com'
EMAIL_HOST_PASSWORD = 'your-password'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"

django < 1.4 未満の場合

python manage.py shell
>>> from django.core.mail import send_mail
>>> send_mail('test email', 'hello world', to=['test@example.com'])

django 1.4 以上の場合

python manage.py shell
>>> from django.core.mail import send_mail
>>> send_mail('test email', 'hello world', 'your@email.com', ['test@email.com'])

http://stackoverflow.com/questions/6914687/django-sending-email