2👍
✅
I’d say that catch an Exception
is a very final approach. Since both SMTPException
and socket.error
are children of IOError
you can catch an IOError
instead. If you’ll ever catch something else – you can add this to your catch list later.
Source:stackexchange.com