I have attempted to change the header of my attached pdf from the default "noname" to some other header. Unfortunately the following "add_header" part of my code doesn't change the actual header name. Are there any alternatives without corrupting or altering the contents of the attached file?
fromaddr = 'XXXXX@gmail.com'
toaddrs = 'XXXXX@gmail.com'
username = 'XXXX'
password = 'XXXXX'
msg = MIMEMultipart()
msg['Subject']='Spam'
msg.preamble = 'SDFSFSDF'
file=open(r'XXXXXX.pdf','rb').read()
msg.attach(MIMEApplication(file,'pdf'))
msg.add_header('XXXXXX', 'file', filename = 'XXXXXX.pdf')
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login(username, password)
server.sendmail(fromaddr, toaddrs, msg.as_string())
time.sleep(2)
EDIT
This is the file heading that is attached: