client.login(user, passwd)
client.select('INBOX')
status, data = client.fetch(msgid, '(RFC822)')
email_data = data[0][1]
client.close()
client.logout()
message = email.message_from_string(email_data)
message.replace_header('From', from_addr)
message.replace_header('To', to_addr)
smtp = smtplib.SMTP(smtp_host, smtp_port)
smtp.starttls()
smtp.login(user, passwd)
smtp.sendmail(from_addr, to_addr, message.as_string())
smtp.quit()
Forwarding an email with python smtplib