Home > other >  TypeError: getsockaddrarg: AF_INET address must be the tuple, not email STR Python prompt error
TypeError: getsockaddrarg: AF_INET address must be the tuple, not email STR Python prompt error

Time:09-27

The import smtplib
From email. Mime. The text import MIMEText
From the email. The header import header
From_addr='[email protected]'
Enter your authorization code password=input (' : ')
To_addr='[email protected]'
Smtp_server='smtp.qq.com'
MSG=MIMEText (' the send by python ', 'plain', 'utf-8)
MSG=[' From '] Header (from_addr)
MSG=[' To '] Header (to_addr)
MSG=[' Subject '] Header (' python test ')
Server=smtplib. SMTP_SSL (smtp_server)
Server. The connect (smtp_server, 465, 'utf-8)
Server. The login (from_addr, password)
Server. The sendmail (from_addr to_addr, MSG. As_string ())
Server. The quit ()

Prompt error:
Traceback (the most recent call last) :
The File "c:/Users/sohpia/Desktop/test/qq. Py", line 13, the in & lt; module>
Server. The connect (smtp_server, 465, 'utf-8)
The File "C: \ Users \ sohpia \ AppData \ Local \ designed \ Python \ Python37 \ lib \ smtplib py", line 336, in the connect
The self. The sock=self. _get_socket (host, port, the self. The timeout)
The File "C: \ Users \ sohpia \ AppData \ Local \ designed \ Python \ Python37 \ lib \ smtplib py", line 1037, in _get_socket
Self. Source_address)
The File "C: \ Users \ sohpia \ AppData \ Local \ designed \ Python \ Python37 \ lib \ socket py", line 715, in create_connection
The sock. Bind (source_address)
TypeError: getsockaddrarg: AF_INET address must be a tuple, the not STR

CodePudding user response:

Server. The connect (smtp_server, 465, 'utf-8)
This line of code removed
  • Related