Let me explain the situation: I send a letter using smtplib
(code below) to ServiceDesk
. The letter looks like this:
Subject: ~Bot~ subject
Body:
~~OPERATION=AddRequest~~
~~REQUESTER=FULL NAME~~
It is written in the parameters of ServiceDesk
that it parses the information that is in ~
. If you send a letter from mail (Outlook
for example), then ServiceDesk
parses everything normally, but if through smtplib
it does not parse at all, the subject remains ~Bot~ subject
instead of subject
, and the sender is not substituted from the REQUESTER
parameter.
Code:
import smtplib
from email.mime.text import MIMEText
to = 'servicedesk@my-domain.com'
gmail_user = 'servicedesk@my-domain.com'
gmail_pwd = 'password'
smtpserver = smtplib.SMTP("smtp.office365.com", 587)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo
smtpserver.login(gmail_user, gmail_pwd)
subject = "~Bot~ 123"
msg = MIMEText("~~OPERATION=AddRequest~~\r\n~~REQUESTER=FIO~~")
msg['From'] = gmail_user
msg['To'] = to
msg['Subject'] = subject
smtpserver.sendmail(gmail_user, to, msg.as_bytes())
smtpserver.close()
I tried to change the encoding when sending a message, but it didn't help. I also tried another library for sending letters, which also turned out to be unsuccessful. Perhaps I lack competence and I simply do not indicate some required parameter.
Tell me what the problem might be and how it can be fixed. Thank you!
from ServiceDesk parsing email sent using smtplib
No comments:
Post a Comment