# Class Protocols.SMTP.AsyncClient

Inheritance graph

Description

  Asynchronous (nonblocking/event-oriented) email client class (this lets you send emails).

Inherit AsyncProtocol

  `inherit `AsyncProtocol` : AsyncProtocol`

Inherit ClientHelper

  `inherit ClientHelper : ClientHelper`

Method create

  `Protocols.SMTP.AsyncClient Protocols.SMTP.AsyncClient(`void`|`string`|`object` `server`, `int`|`void` `port`, `function`(:`void`)|`void` `cb`, `mixed` ... `args`)`

Description

  Creates an SMTP mail client and connects it to the the server provided. The server parameter may either be a string with the hostname of the mail server, or it may be a file object acting as a mail server. If server is a string, then an optional port parameter may be provided. If no port parameter is provided, port 25 is assumed. If no parameters at all is provided the client will look up the mail host by searching for the DNS MX record.

  The callback will first be called when the connection is established (`cb(1, @args)`) or fails to be established with an error. The callback will also be called with an error if one occurs during the delivery of mails.

  In the error cases, the `cb` gets called the following ways:

  - `cb(({ 1, errno(), error_string, int(0..1) direct }), @args);`

  - `cb(({ 0, smtp-errorcode, error_string, int(0..1) direct }), @args);`

  Where `direct` is `1` if establishment of the connection failed.