Answer the question
In order to leave comments, you need to log in
How to handle dictionary with smtplib.SMTPRecipientsRefused (Python3) error?
The script sends letters, and does processing if everything is ok, then returns the address, if not, then the error and the address, but the error has the format smtplib.SMTPRecipientsRefused({'[email protected]': (550, b'non-local recipient verification failed' ))
class type 'smtplib.SMTPRecipientsRefused'
output {'[email protected]': (550, b'non-local recipient verification failed')}
but how to handle this error so that it outputs it as a dictionary type so that you can work with it
error handling code:
try:
mailsender.sendmail(LOGIN, RECIPIENT, msg.as_string())
# list_mail.append(RECIPIENT)
# print('письмо отправлено', RECIPIENT)
mailsender.quit()
return RECIPIENT
except BaseException as err:
# list_mail.append(err)
print(type(err))
pass
mailsender.quit()
return f'{err} {RECIPIENT}'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question