Amazon SES SMTP with Django

前端 未结 7 1731
悲&欢浪女
悲&欢浪女 2021-01-30 05:48

I\'m trying to use Amazon\'s new SMTP service for SES with Django 1.3.1 but I\'m not having much luck.

I\'ve created my SES SMTP credentials and have this in my settings

7条回答
  •  感情败类
    2021-01-30 06:05

    I took like 3 hrs breaking my head over it. Your solution about the smtplib with s.starttls() and then s.login() is good with a python program with all the email credentials in the same file. But I don't think it is a clean way to do it in Django. So I finally figured it out. Irrespective of whether your machine is a 32 or a 64 bit. Just do the following steps:

    1. Install boto

      pip install --upgrade boto

    2. Install django-ses

      pip install django-ses

    3. In your djando settings.py file update the following info.

      EMAIL_BACKEND = 'django_ses.SESBackend'
      AWS_ACCESS_KEY_ID = 'your_username'
      AWS_SECRET_ACCESS_KEY = 'your_password'

    4. In your django file where you want to send an email

      from django.core.mail import send_mail
      send_mail('Test subject', 'This is the body', 'info@abc.com',['hello@abc.com'],fail_silently=False)

提交回复
热议问题