Guest User

Untitled

a guest
Aug 10th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. Is there a way to use django send_mail but the sender is based on a specific field in a django model?
  2. EMAIL_HOST = 'smtp.gmail.com'
  3. EMAIL_PORT = 587
  4. EMAIL_HOST_USER = 'sample@gmail.com'
  5. EMAIL_HOST_PASSWORD = 'samplepass'
  6. EMAIL_USE_TLS = True
  7.  
  8. #models.py
  9. class Business_Profile(models.Model):
  10. ...
  11. contact_email_address = models.EmailField()
  12. ...
  13.  
  14. from django.core.mail import send_mail
  15.  
  16. profile = BusinessProfile.objects.get(pk=1)
  17.  
  18. send_mail('Subject here', 'Here is the message.', profile.contact_email_address,
  19. ['to@example.com'], fail_silently=False)
Add Comment
Please, Sign In to add comment