I already done sending email with HTML template, I want to add a attachment(PDF) in email but I got an error. AttributeError: 'int' object has no attribute 'attach'. Can you give me an Idea on how to add attach file in sending email via send_email in django?Thank you
Tree
├── Folder
│ ├── management
│ ├── templates
│ │ └── p.pdf
My send_mail command are inside the management folder
send email code
subject = 'Management Automated Email- ' + (item.emp)
html_message = render_to_string('email.html',data)
plain_message = item.emp
recipient_list = [item.email]
from_email = <email@gmail.com>'
toaddrs = recipient_list
mail = send_mail(subject, plain_message, from_email, toaddrs, html_message=html_message, fail_silently=False)
mail.attach('papers.pdf', 'pdf/plain')
mail.send()