Edvard Rejthar - Tue, 15/11/2022 - 15:57

Permalink

Hi, thanks for your code. Since 2019, all the e-mail related burden might be releaved with the envelope library at https://github.com/CZ-NIC/envelope. No hassle with the magic or attachments or required headers or smtp. Single object call will do all this for you so that you can concentrate on your business logic, not the e-mail implementation details.

Install it with: pip install envelope

Import it and write a single line:

from envelope import Envelope
Envelope().message('Message body\n').subject('Subject').from_('sender@example.com').to(['recipient@example.net', 'cc@example.net', 'bcc@example.net']).attach(path='/path/to/attachment1').attach(path='/path/to/attachment2').smtp('localhost').send(0)

 

CAPTCHA