Q:

How to send pdf file as an attachment in Django

I have a form where the user can ask for an document. They need to enter the name and the email address and the document will be sent to that email address. 
How to do that?
My code is as follows:
if download_form.is_valid():
        ln_go = get_lang_code(request, request.GET.get('lang'))
        file_to_be_sent = "/assets/documents/case_study" + ln_go + ".pdf"
        name = request.POST.get('name')
        email = request.POST.get('email')

        msg = EmailMultiAlternatives('Het aangevraagde document',
                                     'Geachte {0}, <br/><br />In bijlage sturen wij u het aangevraagde document door. <br /><br />Met vriendelijke groeten, <br /><br /> Het Autralis team'.format(name),
                                     'no-reply@autralis.com',
                                     [email, ], # TO
                                     ['some-email-address@gmail.com', ]) # cc
        msg.content_subtype = "html"  # Main content is now text/html
        msg.attach("case_study.pdf", file_to_be_sent, "application/pdf")
        msg.send()

And the project tree where those documents are is as follows:

I have two problems:

First problem: email = request.POST.get('email') is myemail@hotmail.com, but the email has not been send to that email, the cc email address some-email-address@gmail.com get the mail but the attachment is not correct
Second problem is the attachment. My attachment is 1.2MB but I do not get what it should be. I get something as follows: 

Any idea how to solve it?

A:

you should put content in the attach method:
import os
from django.conf import settings

file_to_be_sent = "assets/documents/case_study{}.pdf".format(ln_go)
file_to_be_sent = os.path.join(settings.BASE_DIR, file_to_be_sent)
with open(file_to_be_sent) as f:
    msg.attach("case_study.pdf", f.read(), "application/pdf")

or use the attach_file method
msg.attach_file(file_to_be_sent)

details for the methods in the EmailMessage

