I'm confused about content-type in email when sending email.I know the attachment file type is related to content-type.For some reason,I can't use "application/octet-stream". For example,I want to send "pdf" attachment.
msg = MIMEMultipart()
msg['From'] = ""
msg['Subject'] = ""
part = MIMEApplication(open(attachment_path, 'rb').read())
filetype = os.path.splitext(attachment_path)[-1][1:]
newfilename = 'resume' + '.' + filetype
if filetype=="pdf":
part["Content-Type"] ="application/pdf"
elif filetype=="doc" or filetype=="docx":
part['Content-Type']="application/msword"
else:
pass
part.add_header('Content-Disposition', 'attachment', filename=newfilename)
msg.attach(part)
The infomation is below :
The two content-type : smtp header infomation and attachment header ? Will they influence each other? And "docx" ---can use application/msword? Please forgive me for asking this silly question! Thanks for any help!