Why doesn't a message appear when sending an email? - smtplib - Python

For some reason when trying to send an email no message appears, when I pass the string msg

Here's the code I'm using:

import smtplib

server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login("my_email", "my_password")

msg = "my message"
server.sendmail("[email protected]", "[email protected]", msg)
server.quit()

Any alternative methods or solutions would be great.

Edit:

When I send the e-mail(to myself) no message appears just an empty e-mail appears in my inbox. Is there an alternative 'built-in' library that I can use?

Upvotes: 3

Views: 2458

Answers (1)

The answer to my above question is:

The variable my_message just needs \nbefore the text to separate it from the header.

Upvotes: 7

Related Questions