views:

133

answers:

1

Hi All, I curius about how to send activated email with username, password by using django-registration. First I think about modify registrationform but I need some example.

+1  A: 

Hi,

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.

Martin Eve