Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send activate-email with django-registration

I am curious if there's a way to send activated email with username, password by using django-registration. First I thought about modifying registration form but I need some example.

like image 907
vernomcrp Avatar asked May 24 '10 04:05

vernomcrp


2 Answers

django-registration uses the following code, internally, to handle sending emails:

send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [self.user.email])

If you want to work, you will have to specify the value DEFAULT_FROM_EMAIL in your settings.py.

Also, note the following:

Mail is sent using the SMTP host and port specified in the EMAIL_HOST and EMAIL_PORT settings. The EMAIL_HOST_USER and EMAIL_HOST_PASSWORD settings, if set, are used to authenticate to the SMTP server, and the EMAIL_USE_TLS setting controls whether a secure connection is used.

So, to give an example, here's what I've used in a settings.py file to use a gmail account:

EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 465
EMAIL_USE_TLS = True

EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'my_emails_password'

django-registration should then be able to send emails.

like image 172
Martin Eve Avatar answered Sep 21 '22 04:09

Martin Eve


EMAIL_PORT = 465 was working some year ago. Now you need to use port 587 with gmail. Reason: Django does not support SMTP with SSL from the beginning. Only STARTTLS command is supported AFTER plain-text connection is set up. Gmail, however, no longer supports this option on port 465.

like image 39
knaperek Avatar answered Sep 22 '22 04:09

knaperek