When I used this in my Python script, the emails received come with a warning "Be careful with this message
The sender hasn't authenticated this message so Gmail can't verify that it actually came from them. Avoid clicking links, downloading attachments, or replying with personal information."
This warning is apparently related to setting the message["from"] attribute, commenting out the following line fixes it so messages are sent without the authentication warning:
message["from"] = sender
