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 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 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 ehloCommand(param: string): string {.inline, ...raises: [], tags: [], forbids: [].}
proc expnCommand(param: string): string {.inline, ...raises: [], tags: [], 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 lhloCommand(param: string): string {.inline, ...raises: [], tags: [], forbids: [].}
proc mailCommand(param: string): string {.inline, ...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 resetCommand(): string {.inline, ...raises: [], tags: [], 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 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: [].}