blackhole.smtp
¶Provides the Smtp protocol wrapper.
The class responsible for handling SMTP/SMTPS commands.
Tie a connection to blackhole to the SMTP protocol.
transport (asyncio.transports.Transport) – The transport class.
Get a list of available AUTH mechanisms.
A list of available authentication mechanisms.
Look up a handler for the received AUTH mechanism.
line (str) – A line of data from a client.
A callable authentication mechanism.
blackhole.smtp.Smtp.auth_MECHANISM
Note
Using pass=
as part of the auth data will trigger an authentication pass, using fail=
will trigger an authentication failure.
Send help for AUTH mechanisms.
https://kura.gg/blackhole/communicating-with-blackhole.html#help
Handle an AUTH LOGIN request.
>>> AUTH LOGIN
334 VXNlcm5hbWU6
>>> pass=letmein
235 2.7.0 Authentication successful
>>> AUTH LOGIN
334 VXNlcm5hbWU6
>>> fail=letmein
535 5.7.8 Authentication failed
Note
Using pass=
as part of the auth data will trigger an authentication pass, using fail=
will trigger an authentication failure.
Handle an AUTH CRAM-MD5 request.
>>> AUTH CRAM-MD5
334 PDE0NjE5MzA1OTYwMS4yMDQ5LjEyMzI4NTE2...
>>> pass=letmein
235 2.7.0 Authentication successful
>>> AUTH CRAM-MD5
334 PDE0NjE5MzA1OTYwMS4yMDQ5LjEyMzI4NTE2...
>>> fail=letmein
535 5.7.8 Authentication failed
Note
Using pass=
as part of the auth data will trigger an authentication pass, using fail=
will trigger an authentication failure.
Handle an AUTH PLAIN request.
>>> AUTH PLAIN
334
>>> pass=letmein
235 2.7.0 Authentication successful
>>> AUTH PLAIN
334
>>> fail=letmein
535 5.7.8 Authentication failed
>>> AUTH PLAIN pass=letmein
235 2.7.0 Authentication successful
>>> AUTH PLAIN fail=letmein
535 5.7.8 Authentication failed
Note
Using pass=
as part of the auth data will trigger an authentication pass, using fail=
will trigger an authentication failure.
Timeout a client connection.
Sends the 421 timeout message to the client and closes the connection.
Look up the SMTP VERB against a handler.
line (str) – Look up the command handler to use from the data provided.
A callable command handler.
blackhole.smtp.Smtp.do_VERB, blackhole.smtp.Smtp.auth_MECHANISM, blackhole.smtp.Smtp.help_VERB
Look up a help handler for the SMTP VERB.
https://kura.gg/blackhole/communicating-with-blackhole.html#help
parts (list) – A list of command data, split on spaces.
A callable help handler.
blackhole.smtp.Smtp.help_VERB
Look up a handler for the SMTP VERB.
verb (str) –
A callable command handler.
blackhole.smtp.Smtp.do_VERB
Get a list of HELP handlers for verbs.
https://kura.gg/blackhole/communicating-with-blackhole.html#help
A list of available help handlers.
Send a response to the HELP verb.
https://kura.gg/blackhole/communicating-with-blackhole.html#help
Send help for HELO verb.
https://kura.gg/blackhole/communicating-with-blackhole.html#help
Send help for the EHLO verb.
https://kura.gg/blackhole/communicating-with-blackhole.html#help
Send help for the MAIL TO verb.
https://kura.gg/blackhole/communicating-with-blackhole.html#help
Send response to MAIL TO verb.
Note
Checks to see if SIZE=
is passed, pass function off to have it’s size handled.
Send response to the RCPT TO verb.
https://kura.gg/blackhole/communicating-with-blackhole.html#help
Send help for the DATA verb.
https://kura.gg/blackhole/communicating-with-blackhole.html#help
Process dynamic switch email headers.
Reads x-blackhole-delay and x-blackhole-mode headers and re-configures on-the-fly how the email is handled based on these headers.
https://kura.gg/blackhole/dynamic-switches.html
line (str) – An email header.
Send a response based on the configured response mode.
https://kura.gg/blackhole/dynamic-switches.html#dynamic-delay-switcheshttps://kura.gg/blackhole/configuration.html#mode
Response mode is configured in configuration file and can be overridden by email headers, if enabled.
Send response to DATA verb and wait for mail data.
This method will also implement timeout management and handling after receiving the DATA command and no new data is received.
This method also implements the delay functionality, delaying a response after the final ‘rn.rn’ line. – https://kura.gg/blackhole/configuration.html#delayhttps://kura.gg/blackhole/dynamic-switches.html#dynamic-delay-switches
This method implements restrictions on message sizes. – https://kura.gg/blackhole/configuration.html#max-message-size
Send help for the NOOP verb.
https://kura.gg/blackhole/communicating-with-blackhole.html#help
Send help for the RSET verb.
https://kura.gg/blackhole/communicating-with-blackhole.html#help
Send help for the VRFY verb.
https://kura.gg/blackhole/communicating-with-blackhole.html#help
Send response to the VRFY verb.
>>> VRFY pass=user@domain.tld
250 2.0.0 <pass=user@domain.tld> OK
>>> VRFY fail=user@domain.tld
550 5.7.1 <fail=user@domain.tld> unknown
>>> VRFY user@domain.tld
252 2.0.0 Will attempt delivery
Note
If the request contains ‘pass=’, the server will respond with code 250. If the request contains ‘fail=’, the server will respond with code 550. And finally, if neither flag is found, the server will respond with code 252.
Send help for the EXPN verb.
https://kura.gg/blackhole/communicating-with-blackhole.html#help
Handle the EXPN verb.
>>> EXPN fail=test-list
550 Not authorised
>>> EXPN list1
250-Shadow <shadow@blackhole.io>
250-Wednesday <wednesday@blackhole.io>
250 Low-key Liesmith <low-key.liesmith@blackhole.io>
>>> EXPN list2
250-Jim Holden <jim.holden@blackhole.io>
250-Naomi Nagata <naomi.nagata@blackhole.io>
250-Alex Kamal <alex.kamal@blackhole.io>
250 Amos Burton <amos.burton@blackhole.io>
>>> EXPN list3
250-Takeshi Kovacs <takeshi.kovacs@blackhole.io>
250-Laurens Bancroft <laurens.bancroft@blackhole.io>
250-Kristin Ortega <kristin.ortega@blackhole.io>
250-Quellcrist Falconer <quellcrist.falconer@blackhole.io>
250-Virginia Vidaura <virginia.vidaura@blackhole.io>
250 Reileen Kawahara <reileen.kawahara@blackhole.io>
>>> EXPN all
250-Shadow <shadow@blackhole.io>
250-Wednesday <wednesday@blackhole.io>
250-Low-key Liesmith <low-key.liesmith@blackhole.io>
250-Takeshi Kovacs <takeshi.kovacs@blackhole.io>
250-Laurens Bancroft <laurens.bancroft@blackhole.io>
250-Kristin Ortega <kristin.ortega@blackhole.io>
250-Quellcrist Falconer <quellcrist.falconer@blackhole.io>
250-Virginia Vidaura <virginia.vidaura@blackhole.io>
250-Reileen Kawahara <reileen.kawahara@blackhole.io>
250-Jim Holden <jim.holden@blackhole.io>
250-Naomi Nagata <naomi.nagata@blackhole.io>
250-Alex Kamal <alex.kamal@blackhole.io>
250 Amos Burton <amos.burton@blackhole.io>
>>> EXPN list-does-not-exist
550 Not authorised
Note
If EXPN contains ‘fail=’ or does not specify a mailing list the command will return a 550 code. Valid lists are: list1, list2, list3 and all.
Send help for the ETRN verb.
https://kura.gg/blackhole/communicating-with-blackhole.html#help
Send help for the QUIT verb.
https://kura.gg/blackhole/communicating-with-blackhole.html#help
Close the connection from the client.
Client connection is closed or lost.
exc (exc) – Exception.
Called when some data is received.
The argument is a bytes object.
Called when the other end calls write_eof() or equivalent.
If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol.
Adapt internal flags for the transport in use.
Called when the transport’s buffer goes over the high-water mark.
Pause and resume calls are paired – pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark.
Note that if the buffer size equals the high-water mark, pause_writing() is not called – it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero.
NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() – if it were, it would have no effect when it’s most needed (when the app keeps writing without yielding until pause_writing() is called).
Called when the transport’s buffer drains below the low-water mark.
See pause_writing() for details.
Wait for data from the client.
A line of received data.
Note
Also handles client timeouts if they wait too long before sending data. – https://kura.gg/blackhole/configuration.html#timeout
Delay after the DATA command completes.
Value is in seconds, with a maximum value of 60 seconds.
https://kura.gg/blackhole/configuration.html#delayhttps://kura.gg/blackhole/dynamic-switches.html#dynamic-delay-switches
How to respond to an email, based on configuration.
Response is configured in the configuration file or configured from email headers, if configured to allow that option.
https://kura.gg/blackhole/configuration.html#modehttps://kura.gg/blackhole/dynamic-switches.html#dynamic-mode-switches
A response mode.