The send() coroutine and SMTP.__init__() accept a timeout keyword argument of a numerical value in seconds. This value is used for all socket operations (initial connection, STARTTLS, each command/response, etc), and will raise SMTPTimeoutError if exceeded.


Note that because the timeout is on socket operations, as long as there is no period of inactivity that exceeds it (meaning no individual bytes sent or received), the timeout will not be triggered. This means that if you set the timeout to 1 second (for example), sending an entire message might take much longer than that without a timeout occurring.

Timeout values passed directly to SMTP command methods will override the default passed in on initialization.

The default timeout is 60 seconds.