Skip to content

Mail round trip (mail_roundtrip) ​

Sends a message whose subject carries a unique tag over SMTP mail submission, waits for it to appear in the account's mailbox read over IMAP or POP3, reports how long that took, and deletes it. This is the check that mail really gets through, not only that the services answer.

What it looks like ​

The page of a mail_roundtrip sensor in the light theme

The page of a mail round trip sensor after a few polls, sending over submission with STARTTLS and reading back over IMAP on a lab server. In the dark theme: the sensor's page. The form for adding it, with its parameters filled in: light, dark.

What one poll does ​

  1. Signs in to the mailbox (IMAP or POP3). A wrong password or a missing mailbox fails here, before anything is sent.
  2. Deletes the messages whose subject starts with the sensor's prefix and whose tag is older than cleanup_after_secs. They are the leftovers of runs that failed.
  3. Sends the message from and to address over submission (STARTTLS and AUTH by default), with a subject <prefix>-<unix time>-<random>, an Auto-Submitted: auto-generated header and a body that says what it is.
  4. Looks at the mailbox every poll_interval_ms until the tag appears, or until about four fifths of the poll timeout have passed.
  5. Deletes the message, signs out, and reports. On a timeout it looks once more, deletes the message if it has arrived by then, and fails with kind timeout; a message that still arrives later is deleted by the next run as a leftover.

Nothing piles up, and the sensor only deletes messages whose subject starts with its own prefix. Two sensors that watch the same mailbox can share a prefix: a run never touches a message younger than cleanup_after_secs that is not its own. A POP3 mailbox is a snapshot taken at sign-in, so the sensor signs in again for every look, and deletions take effect when it signs out.

Channels ​

KeyNameUnitDefault limits
roundtrip_msRound trip (from the start of sending until the message was found)mswarning above 15000, error above 45000
send_msTime to send (connecting, TLS, signing in and the server accepting the message)mswarning above 5000, error above 15000
delivery_msDelivery (the server accepted it until it was found)msnone
removedOld messages removednone

Parameters ​

ParameterDefaultMeaning
addressrequiredThe address the message is sent from and to: the account whose mailbox is read back, which the login credential belongs to.
smtp_port, smtp_security587, starttlsSubmission. With smtp_security tls the port defaults to 465.
retrievalimapimap or pop3.
retrieval_port, retrieval_security993, tlsThe mailbox connection; 995 for POP3 over TLS, 143 or 110 without.
mailboxINBOXIMAP only: where the message arrives.
subject_prefixprobeward-roundtripWhat every subject starts with; 1 to 64 letters, digits, -, _ or .. Messages with this prefix are the sensor's own.
cleanup_after_secs900Messages with the prefix older than this are deleted. At least 60.
poll_interval_ms1000Between looks at the mailbox, 200 to 10000.
allow_plaintext_loginfalseAllow none for either connection, which sends the password in the clear.
helo_namethe probe's address in bracketsWhat to say in EHLO.
verify_tls, tls_fingerprint, server_nameas for SMTPThe certificate rules, for both connections: they must be to the same server and certificate.

Suggested interval: 300 seconds. Credential: a login credential, required; one account does the sending and the reading. Set the poll timeout well above the delivery time you expect, for example 30 to 60 seconds: the default of 10 seconds is shorter than a slow mail system needs, and the interval must stay above the timeout.

On the target ​

An account that can submit mail (AUTH on the submission port) to its own address and read and delete in its mailbox. Mail to that address must be delivered to that mailbox; a filter that moves or discards mail from the account to itself defeats the check.

Failures ​

MessageMeaning
the message was accepted (...) but did not appear in the mailbox within N s (kind timeout)Delivery is slow or broken. The reply of the server is quoted, which usually carries the queue id.
the server rejected the login (kind auth_failed)At the mailbox, before sending, or at submission.
SMTP refused the sender, ... refused the recipient (kind protocol)Submission refused the message; relay rules or the sender address.
the connection and certificate failures of SMTP and IMAP

Testing ​

The live tests in crates/probeward-sensors/tests/mail_ftp_live.rs run against a real mail server when these variables are set, and print one line and return when they are not:

VariableMeaning
PROBEWARD_TEST_MAIL_HOSTThe server's address.
PROBEWARD_TEST_MAIL_NAMEThe name its certificate carries, sent as the TLS server name.
PROBEWARD_TEST_MAIL_USER, PROBEWARD_TEST_MAIL_PASSWORDAn account on it.
PROBEWARD_TEST_MAIL_ADDRESSThat account's mail address.
PROBEWARD_TEST_MAIL_CA_FILEThe PEM file of the authority that issued the certificate.
sh
cargo test -p probeward-sensors --test mail_ftp_live -- --nocapture

The protocol steps themselves (STARTTLS and its downgrade and injection cases, AUTH PLAIN and LOGIN, IMAP literals, POP3 deletion on sign-out) are tested against scripted servers in tests/mail_proto.rs, and the sensors' own judgement against scripted clients in tests/sensors_mail_ftp.rs, without a network.

AGPL-3.0-only