Q:

sending mail with attachment but the attachment is not send only the body is sent

I'm sending a mail with pdf attached in my application but at the receiver end can receive only the body not the attachment
This is the error I received while running the script but the mail is sent
Traceback (most recent call last):
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 138, in run
    self.finish_response()
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 180, in finish_response
    self.write(data)
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 274, in write
    self.send_headers()
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 332, in send_headers
    self.send_preamble()
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 255, in send_preamble
    ('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 453, in _write
    result = self.stdout.write(data)
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\socketserver.py", line 799, in write
    self._sock.sendall(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 141, in run
    self.handle_error()
  File "C:\Result Creater\virtual\lib\site-packages\django\core\servers\basehttp.py", line 116, in handle_error
    super().handle_error()
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 368, in handle_error
    self.finish_response()
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 180, in finish_response
    self.write(data)
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 274, in write
    self.send_headers()
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 331, in send_headers
    if not self.origin_server or self.client_is_modern():
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 344, in client_is_modern
    return self.environ['SERVER_PROTOCOL'].upper() ! = 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\socketserver.py", line 360, in finish_request
    self. RequestHandlerClass(request, client_address, self)
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\socketserver.py", line 720, in __init__
    self.handle()
  File "C:\Result Creater\virtual\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
    self.handle_one_request()
  File "C:\Result Creater\virtual\lib\site-packages\django\core\servers\basehttp.py", line 194, in handle_one_request
    handler.run(self.server.get_app())
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 144, in run
    self.close()
  File "C:\Result Creater\virtual\lib\site-packages\django\core\servers\basehttp.py", line 111, in close
    super().close()
  File "C:\Users\vineet\AppData\Local\Programs\Python\Python37\lib\wsgiref\simple_server.py", line 35, in close
    self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'

My send email function-
def send_email(request):
    subject='Mark Sheet'
    message='You requested for your Marksheet'
    email_from=settings. EMAIL_HOST_USER
    recipient_list=[request.user.email]
    email=EmailMessage(subject,message,email_from,recipient_list,
        headers={'Reply- To':settings. EMAIL_HOST_USER})
    file=str(request.user)+'.pdf'
    email.attach_file=(f"/store/{file}")
    email.send()
    return redirect('home')

My Pdf class for creating pdf
class Pdf(View):

def get(self,request):
    marks=Marks.objects.filter(user_name=request.user).first()
    today=timezone.now()
    params={
        'today':today,
        'marks':marks,
        'request':request
    }
    file=Render.render_to_file('user/pdf.html',params)
    return redirect('send_email')

A:

You have bad syntax here:
email.attach_file=(f"/store/{file}")

attach_file() is a method, and you're assigning to it with = which means the method gets replaced on the object instead of being called.  Change it to:
email.attach_file(f"/store/{file}")

