I am trying to write a program that logins with a Gmail id and sends a mail to a provided id.
import smtplib
email = input('Enter your email\n')
password = input('Enter your password\n')
reciever = input("To whom you want to send?\n")
content = input("Enter content below:\n")
mail= smtplib.SMTP('smtp.gmail.com',587)
mail.ehlo()
mail.starttls()
mail.login(email,password)
mail.send_message(email,reciever,content)
But when I execute the program I get this error...
Enter your email
soham.nandy2006@gmail.com
Enter your password
x
To whom you want to send?
soham.nandy@outlook.com
Enter content below:
HELLOOOO
Traceback (most recent call last):
File "c:/Users/soham/Desktop/Python Crack/main.py", line 15, in <module>
mail.send_message(email,reciever,content)
File "C:\Users\soham\AppData\Local\Programs\Python\Python38-32\lib\smtplib.py", line 928, in send_message
resent = msg.get_all('Resent-Date')
AttributeError: 'str' object has no attribute 'get_all'
PS C:\Users\soham\Desktop\Python Crack>
P.S- I am writing x instead of my password for security issue (In the program the password is correct)