7. SMTP server
There are multiple extensions to the language, which provides context specific variables and functions. The smtpd process implements the connect, proxy, HELO, AUTH, MAIL FROM, RCPT TO, end-of-DATA and disconnect context. These scripts operates on an SMTP connection. The $transaction["id"]
variable is set when connecting and may be regenerated upon the client sending a RSET command. There is also a $context
variable which is bound to a connection and may be used in any script, which is useful for passing data (only string, number, boolean, null and array types are supported) between phases.
.--------------------------------. <-- connect context
< | 220 example.org ESMTP |
> | HELO example.com | <-- HELO context
< | 250 OK |
| ... |
> | AUTH LOGIN | <-- AUTH context
| ... |
< | 250 OK |
> | MAIL FROM: <[email protected]> | <-- MAIL FROM context
< | 250 OK |
> | RCPT TO: <[email protected]> | <-- RCPT TO context
< | 250 OK |
> | DATA |
< | 354 Feed me |
> | Subject: Lunch |
> | |
> | Lunch on friday? |
> | . | <-- end-of-DATA context
< | 250 Accepted |
> | QUIT |
< | 250 Bye |
`--------------------------------´ <-- disconnect context
|
,-------> queue
| | <-- Pre-delivery context
| delivery attempt
| | <-- Post-delivery context
\__________/ \______ done