send_mail('Subject here', 'Here is the message.', '[email protected]', ['[email protected]'], fail_silently=False)
mail = send_mail('Subject here', 'Here is the message.', '[email protected]', ['[email protected]'], fail_silently=False)
mail.attach('AP_MODULE_bugs.ods','AP_MODULE_bugs.ods','application/vnd.oasis.opendocument.spreadsheet')
mail.send()
I'm using Django send_mail class for sending mail. Here I want to send mail with attachment, my attachment File (.ods) is in local storage.
You have to use EmailMessage
)
mail.send()
Alternatively, you can pass attach() three arguments: filename, content and mimetype. filename is the name of the file attachment as it will appear in the email, content is the data that will be contained inside the attachment and mimetype is the optional MIME type for the attachment. If you omit mimetype, the MIME content type will be guessed from the filename of the attachment.
Eg: message.attach('design.png', img_data, 'image/png')