chronos_smtp

Search:
Group by:

Types

AuthMethod = enum
  AuthLogin, AuthPlain
Message = object
ReplyError = object of SmtpError
Smtp = ref object
  closed*: bool
  extensions*: seq[string]
  timeout*: Duration
  logs*: seq[string]
SmtpClientScheme {.pure.} = enum
  NonSecure, Secure
SmtpError = object of AsyncError

Procs

proc `$`(msg: Message): string {....raises: [], tags: [], forbids: [].}
stringify for Message.
proc auth(smtp: Smtp; username, password: string;
          authMethod: AuthMethod = AuthLogin): Future[void] {....stackTrace: false,
    raises: [], gcsafe, tags: [RootEffect], forbids: [].}
Sends an AUTH command to the server to login as the username using password. May fail with ReplyError.
proc authLoginCommand(): string {.inline, ...raises: [], tags: [], forbids: [].}
proc authPlainCommand(username, password: string): string {.inline, ...raises: [],
    tags: [], forbids: [].}
proc checkReply(smtp: Smtp; reply: string; quitWhenFailed: bool = true): Future[
    void] {....stackTrace: false, raises: [], gcsafe, tags: [RootEffect],
            forbids: [].}
proc close(smtp: Smtp; quit: bool = true): Future[void] {....stackTrace: false,
    raises: [], gcsafe, tags: [RootEffect], forbids: [].}
Disconnects from the SMTP server and closes the stream.
proc connect(smtp: Smtp; host: string; port: Port; flags: set[TLSFlags] = {};
             helo: bool = true; quitWhenFailed: bool = true): Future[void] {.
    ...stackTrace: false, raises: [], gcsafe, tags: [RootEffect], forbids: [].}
Establishes a connection with a SMTP server.
proc createMessage(mSubject, mBody: string; mTo, mCc: seq[string];
                   otherHeaders: openArray[tuple[name, value: string]]): Message {.
    ...raises: [ValueError], tags: [TimeEffect], forbids: [].}

Creates a new MIME compliant message.

You need to make sure that mSubject, mTo and mCc don't contain any newline characters. Failing to do so will raise AssertionDefect.

proc createMessage(mSubject, mBody: string; mTo: seq[string] = @[];
                   mCc: seq[string] = @[]): Message {....raises: [ValueError],
    tags: [TimeEffect], forbids: [].}

Alternate version of the above.

You need to make sure that mSubject, mTo and mCc don't contain any newline characters. Failing to do so will raise ValueError.

proc dataCommand(): string {.inline, ...raises: [], tags: [], forbids: [].}
proc dial(host: string; port: Port; useTls: bool = false;
          flags: set[TLSFlags] = {}; helo: bool = true;
          quitWhenFailed: bool = true; timeout = InfiniteDuration): Future[Smtp] {.
    ...stackTrace: false, raises: [], gcsafe, tags: [RootEffect], forbids: [].}
proc ehlo(smtp: Smtp): Future[bool] {....stackTrace: false, raises: [], gcsafe,
                                      tags: [RootEffect], forbids: [].}
Sends EHLO request. Return true if server supports EHLO, false otherwise. When successful, server-advertised extensions are stored in extensions.
proc ehloCommand(param: string): string {.inline, ...raises: [], tags: [],
    forbids: [].}
proc expnCommand(param: string): string {.inline, ...raises: [], tags: [],
    forbids: [].}
proc helo(smtp: Smtp): Future[void] {....stackTrace: false, raises: [], gcsafe,
                                      tags: [RootEffect], forbids: [].}
proc heloCommand(param: string): string {.inline, ...raises: [], tags: [],
    forbids: [].}
proc helpCommand(param: string): string {.inline, ...raises: [], tags: [],
    forbids: [].}
proc kind(smtp: Smtp): SmtpClientScheme {....raises: [], tags: [], forbids: [].}
proc lhlo(smtp: Smtp): Future[void] {....stackTrace: false, raises: [], gcsafe,
                                      tags: [RootEffect], forbids: [].}
Sends the LHLO request (for LMTP)
proc lhloCommand(param: string): string {.inline, ...raises: [], tags: [],
    forbids: [].}
proc mailCommand(param: string): string {.inline, ...raises: [], tags: [],
    forbids: [].}
proc newSmtp(useTls: bool = false; timeout = InfiniteDuration): Smtp {.
    ...raises: [], tags: [], forbids: [].}
proc noopCommand(): string {.inline, ...raises: [], tags: [], forbids: [].}
proc quitCommand(): string {.inline, ...raises: [], tags: [], forbids: [].}
proc rcptCommand(param: string): string {.inline, ...raises: [], tags: [],
    forbids: [].}
proc read(smtp: Smtp): Future[string] {....stackTrace: false, raises: [], gcsafe,
                                        tags: [RootEffect], forbids: [].}
Return all lines of a (possibly multiline) SMTP response. Multiline responses use "xxx-" for continuation and "xxx " for the final line.
proc readLine(smtp: Smtp): Future[string] {....stackTrace: false, raises: [],
    gcsafe, tags: [RootEffect], forbids: [].}
proc resetCommand(): string {.inline, ...raises: [], tags: [], forbids: [].}
proc send(smtp: Smtp; cmd: string): Future[void] {....stackTrace: false,
    raises: [], gcsafe, tags: [RootEffect], forbids: [].}
proc sendMail(smtp: Smtp; fromAddr: string; toAddrs: seq[string]; msg: string): Future[
    void] {....stackTrace: false, raises: [], gcsafe, tags: [RootEffect],
            forbids: [].}

Sends msg from fromAddr to the addresses specified in toAddrs. Messages may be formed using createMessage by converting the Message into a string.

You need to make sure that fromAddr and toAddrs don't contain any newline characters. Failing to do so will raise ValueError.

proc startTls(smtp: Smtp; flags: set[TLSFlags] = {}): Future[void] {.
    ...stackTrace: false, raises: [], gcsafe, tags: [RootEffect], forbids: [].}
Put the SMTP connection in TLS (Transport Layer Security) mode. May fail with ReplyError
proc starttlsCommand(): string {.inline, ...raises: [], tags: [], forbids: [].}
proc supportsExtension(smtp: Smtp; name: string): bool {....raises: [], tags: [],
    forbids: [].}
Check if the server advertised a given ESMTP extension. The comparison is case-insensitive and matches the extension keyword (e.g. "STARTTLS", "AUTH").
proc vrfyCommand(param: string): string {.inline, ...raises: [], tags: [],
    forbids: [].}