TypeError: sendmail() missing 1 required positional argument: 'msg'
from smtplib import SMTP
def signin():
email='[email protected]'
password='password'
conn.ehlo_or_helo_if_needed()
conn.starttls()
conn.login(adresa,lozinka)
def write_send_message():
message=dict()
message['From:']='[email protected]'
message['To:']='[email protected]'
message['Subject:']='Test message'
message['Message:']=r'''Test message from Python interpeter'''
print('Sending the message...:')
for key in message:
print(unos,poruka[unos])
SMTP.sendmail(message['From:'],message['To:'],message['Message:'])
host='smtpserver.smtp.com'
port=587
conn=SMTP(host,port)
signin()
write_send_message ()
I'm not sure where did I make the mistake. Third argument (message['Message']) is my variable containing the text of the message (the value of key 'Message' of the same named dictionary). What do you suggest me to change ? There's a simallar question (about 6 years old now, was programmed with Tkinter) with the same error. That didn't help here.
https://docs.python.org/3/library/smtplib.html \n
In Python's documentation it says that 'msg' should be a string which is true in my case. I've tried with sendmail
but since I've established a connection with the server successfully with ehlo
method, it actually wasn't needed.
I think you need conn.sendmail
rather than SMPT.sendmail
.