I have site in production and I’m using EmailMultiAlternatives
and EmailMessage
to send emails.
Sometimes I add new or update existing email sending procedures or templates.
Then I don’t want to bother client with getting test emails so I change email settings to send from test SMTP sender and after testing I change email settings back to default STMP sender.
But this is very annoying to do every time so…
Is there an easy way to switch from sending emails to logging only without changing other code and settings ?
Here is example how my sending mail functions look like:
def send_email_newsletter_subscriber_created(newsletter_subscriber_id):
# prepare all needed info...
msg = EmailMultiAlternatives(subject=subject, body=text_content, to=[to])
msg.attach_alternative(html_content, "text/html")
# add images, prepare some other info...
msg.send()
def send_email_contact_message_created(contact_message_id):
# prepare all needed info...
msg = EmailMessage(subject=subject, body=text_content, to=[to], headers={'Content-Type': 'text/plain'},)
msg.send()