Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Is there a way to use django send_mail but the sender is based on a specific field in a django model?
- EMAIL_HOST = 'smtp.gmail.com'
- EMAIL_PORT = 587
- EMAIL_HOST_USER = 'sample@gmail.com'
- EMAIL_HOST_PASSWORD = 'samplepass'
- EMAIL_USE_TLS = True
- #models.py
- class Business_Profile(models.Model):
- ...
- contact_email_address = models.EmailField()
- ...
- from django.core.mail import send_mail
- profile = BusinessProfile.objects.get(pk=1)
- send_mail('Subject here', 'Here is the message.', profile.contact_email_address,
- ['to@example.com'], fail_silently=False)
Add Comment
Please, Sign In to add comment