So this code works for gmail, when i tried it on yahoo mail i get this error, (550, b'Request failed; Mailbox unavailable')
mail = imaplib.IMAP4_SSL(imap_server)
mail.login(emaill, pwd)
# select the label to work on
print('selecting inbox folder')
try:
mail.select('INBOX')
_, data = mail.search(None, '(UNSEEN)')
mail_ids = data[0]
id_list = mail_ids.split()
for mess in id_list:
_, data = mail.fetch(mess, '(RFC822)')
for response in data:
if isinstance(response, tuple):
print('preparing email body.........')
msg = email.message_from_string(response[1].decode('ISO-8859-1'), policy=email.policy.default)
# open_links(msg)
body_of_email = 'Hi'
email_from = msg['from']
email_to = msg['to']
subject = msg['subject']
mssg = MIMEText(body_of_email, 'plain')
mssg['Subject'] = subject
mssg['From'] = email_from
mssg['To'] = email_to
mssg['Message-ID'] = msg['Message-ID']
try:
# msg.add_header('reply-to', email_to)
s = smtplib.SMTP_SSL(host=smtp_server, port=port)
# .starttls()
s.login(user=emaill, password=pwd)
s.sendmail(emaill, msg['From'], mssg.as_string())
the above code won't work but I change the message to let say 'hey you, it works, so am thinking there is a problem with the MIMETest construction, any help please