pmclanahan / django-celery-email

A Django email backend that uses a celery task for sending the email.
BSD 3-Clause "New" or "Revised" License
477 stars 110 forks source link

Specify which account to send mail #51

Open Kianoosh76 opened 6 years ago

Kianoosh76 commented 6 years ago

Hi, is it possible to specify the account we want to send mail from it? Because we may need different sender accounts(but their mail hosts are same) I mean Something similar to auth_user auth_password input parameters in django builtin send_mail function

simondrabble commented 6 years ago

You can pass auth_user and auth_password to send_mail, so just determine what those should be and pass them in:

if some_condition():
   auth_user = 'user1'
   auth_pass = 'pass1'

else:
  auth_user = 'user2'
  auth_pass = 'pass2'

mail.send_mail(..., auth_user=auth_user, auth_password=auth_pass, ...)