GXM100
GXM100

Reputation: 467

Send Email From Logged in User Django

Let’s suppose I have an app where all users have an email address and password in the User model. And let’s also also assume that all the users use the same email host and port. Is it possible to set the EMAIL_HOST_USER and EMAIL_HOST_PASSWORD shown below to be variables that pull from the user model?

This way when a logged in user uses an email sending functionality, it comes from their email instead of some single email account defined in settings.py as shown below?

‘’’

EMAIL_HOST = 'smtp.sendgrid.net' EMAIL_PORT = 587 EMAIL_HOST_USER = 'parsifal_app' EMAIL_HOST_PASSWORD = 'mys3cr3tp4ssw0rd' EMAIL_USE_TLS = True

‘’’

Upvotes: 0

Views: 285

Answers (1)

Hemant
Hemant

Reputation: 1156

After assuming all the things your mentioned

This can definitely be done, however you will still need to enable less secure apps access in all those accounts manually(as its an security measure) which will make your email vulnerable.

more on less secure apps here less secure apps

Besides that you will need to store passwords in original form(non-encrypted) for this requirement and storing user password in non-hashed/encrypted form is not recommended at all.

you should definitely consider Gmail API for this purpose

Upvotes: 0

Related Questions