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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With