django-mailer icon indicating copy to clipboard operation
django-mailer copied to clipboard

Add attachment integrated features

Open gaeldb opened this issue 4 years ago • 4 comments

Changes proposed in this PR:

  • Added attachment options for HTML mails in send_html_mail()
  • Added attachment function for plaintext mail : send_attachment_mail()

Plaintext attachment feature is in a specific function in order to keep the Django standard send_mail() syntax unchanged.

I'm not confident with your unit tests system/writing. Can someone guide me on how to write it?

gaeldb avatar Feb 23 '21 09:02 gaeldb

Coverage Status

Coverage decreased (-2.8%) to 83.693% when pulling e18edbf408eb5b542fa6e46d496a921aa896d8d9 on elixir-sante:master into 9b0cce811cf7414360a9365ca983dc324c709c2e on pinax:master.

coveralls avatar Feb 23 '21 09:02 coveralls

django-mailer's current functionality is to provide just a mail queue. It looks like everything here can be achieved using EmailMessage, so there isn't a need for this to be in django-mailer. See also the discussion on https://github.com/pinax/django-mailer/issues/119

spookylukey avatar Feb 24 '21 07:02 spookylukey

I probably deeply misunderstood send_html_mail() usage in this case. How can we access the EmailMessage after putting it in the mail queue, in order to add an attachment?

gaeldb avatar Mar 10 '21 15:03 gaeldb

I probably deeply misunderstood send_html_mail() usage in this case. How can we access the EmailMessage after putting it in the mail queue, in order to add an attachment?

You add the attachment before putting it on the queue, not after. Use EmailMessage directly, and its send() method, don't use send_html_mail.

spookylukey avatar Mar 10 '21 16:03 spookylukey