I'm trying to send a message to an email address with a pdf attachment. The letter doesn't come on mail. What's wrong in my code, please tell me?
base_path = 'http://127.0.0.1:8000/'
t = render_to_string(
'pdf_template_nds.html',
{
'payment': payment,
'date_pdf': date_pdf,
'count': count,
'sum_pdf': sum_pdf,
'sum_final': sum_final,
'sum_final_capitalize': sum_final_capitalize,
'sum_nds': sum_nds,
}
)
HTML(string=t, base_url=base_path).write_pdf(
f'nds.pdf',
presentational_hints=True
)
email = EmailMultiAlternatives(
'Subject here', 'Here is the message.', '[email protected]',
['[email protected]'])
email.attach_file('nds.pdf')
email.send()