kirankumar
kirankumar

Reputation: 37

Sending(From) Mail configuration in django

I was configured email SMTP configurations in settings.py file as below

Now its working fine but my problem is after deploying the project how can I change any parameter like from_mail/password by user input form...Simply I need to update/change email or password.

Upvotes: 0

Views: 889

Answers (2)

gerdemb
gerdemb

Reputation: 11477

First, the Django documentation specifically says you shouldn't alter settings at runtime.

https://docs.djangoproject.com/en/2.2/topics/settings/#altering-settings-at-runtime

Fortunately, the send_mail() method allows the default EMAIL_* settings to overridden by using the auth_user and auth_password arguments.

send_mail(
 'Subject here',
 'Here is the message.',
 '[email protected]',
 ['[email protected]'],
 fail_silently=False,
 auth_user='new_user',
 auth_password='new_password',
)

Documentation: https://docs.djangoproject.com/en/2.2/topics/email/#send-mail

Upvotes: 0

Nadin Hermann
Nadin Hermann

Reputation: 49

You can always change the parameter at the function call of the django email function:

send_mail(
 'Subject here',
 'Here is the message.',
 '[email protected]',
 ['[email protected]'],
 fail_silently=False,
)

How to set the auth_user/auth_password is explained here: Django Docs Sending email

Upvotes: 0

Related Questions