9.0
top
← prev up next →

SMTP ServerπŸ”— i

Bogdan Popa <bogdan@defn.io>

This module module provides a minimal implementation of RFC 5321 [RFC5321] that can receive e-mail messages.

1UsageπŸ”— i

(define stop

The example above starts an SMTP server on localhost port 25 that prints all incoming e-mail to standard out. Calling the stop function terminates any connections in flight and stops the server.

See "example/" in the source code repository for an example with STARTTLS support.

2ReferenceπŸ”— i

value

tls-encode-proc/c :
#:mode'tcp
#:encrypt'tls
#:close-original?#t
The contract for TLS-encoding procedures. See also ports->ssl-ports .

Controls the host name displayed to clients.

struct

(struct envelope (senderrecipientsdata)
#:extra-constructor-namemake-envelope)
sender:bytes?
recipients:(listof bytes? )
data:bytes?
Represents the sender, recipients and contents of a receieved e-mail.

procedure

( start-smtp-server handler
[ #:hosthost
#:portport
#:limitslim
#:tls-encodetls-encode])(-> void? )
handler:(-> envelope? void? )
host:string? ="127.0.0.1"
port:(integer-in 065535)=25
tls-encode:(or/c #ftls-encode-proc/c )=#f
Starts an SMTP server that listens on host and port and returns a function that will stop the server when applied.

Successfully-received e-mails are passed to handler. When the handler raises an exception, the server notifies the client that the message has been rejected.

The #:limits arguments can be used to customize various security limits.

If the optional #:tls-encode argument supplies a tls-encode-proc/c value, the server advertises STARTTLS support and clients may opt in to TLS encryption.

procedure

( smtp-limits? v)boolean?

v:any/c

procedure

( make-smtp-limits [ #:max-connectionsmax-connections
#:max-line-lengthmax-line-length
#:max-envelope-lengthmax-envelope-length
#:session-timeoutsession-timeout])
max-connections:exact-positive-integer? =512
max-line-length:exact-nonnegative-integer? =1024
max-envelope-length : exact-nonnegative-integer?
= (* 1010241024)
session-timeout:(and/c number? positive? )=300
Security limits allow you to configure various security-related limits on an SMTP server.

The #:max-connections argument controls the maximum number of concurrent client connections that the server will accept at a time.

The #:max-line-length argument controls the maximum length in bytes of each line received from a client may be. The server will reject lines longer than this amount.

The #:max-envelope-length argument controls the maximum length of incoming e-mails from clients. The total length of an envlope includes the length in bytes of the sender and the recipients list as well as the message data.

The #:session-timeout argument controls the maximum amount of time, in seconds, that a client session may be open for.

BibliographyπŸ”— i

[RFC5321] J. Klensin, “Simple Mail Transfer Protocol.” 2008. https://www.ietf.org/rfc/rfc5321.html

top
← prev up next →

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /