Object built-in object

ObjectSmtp

SMTP object

inheritance relationship

Constructor

Smtp

Smtp object constructor

1
new Smtp();

member properties

timeout

Integer, query and set timeout unit milliseconds

1
Integer Smtp.timeout;

socket

Stream, Query the current connection of the Smtp objectSocket

1
readonly Stream Smtp.socket;

member function

connect

Create to specified server

1
Smtp.connect(String url) async;

Call parameters:

  • url: String, specifies the connection protocol, which can be: tcp://host:port orssl://host:port

command

Send the specified command and return the response. If the server reports an error, an error will be thrown.

1 2
String Smtp.command(String cmd, String arg) async;

Call parameters:

  • cmd: String, command name
  • arg: String, parameter

Return results:

  • String, if successful, return the server response

hello

Send the HELO command and throw an error if the server reports an error.

1
Smtp.hello(String hostname = "localhost") async;

Call parameters:

  • hostname: String, host name, default is "localhost"

login

Log in to the server with the specified user and password. If the server reports an error, an error will be thrown.

1 2
Smtp.login(String username, String password) async;

Call parameters:

  • username: String, username
  • password: String, password

from

Specify the sender's mailbox. If the server reports an error, an error will be thrown.

1
Smtp.from(String address) async;

Call parameters:

  • address: String, sender's mailbox

to

Specify the recipient's mailbox. If the server reports an error, an error will be thrown.

1
Smtp.to(String address) async;

Call parameters:

  • address: String, recipient's mailbox

data

Send text to the recipient, throw an error if the server reports an error

1
Smtp.data(String txt) async;

Call parameters:

  • txt: String, the text to be sent

quit

Exit and close the connection. If the server reports an error, an error will be thrown.

1
Smtp.quit() async;

toString

Returns the string representation of the object. Generally, "[Native Object]" is returned. The object can be re-implemented according to its own characteristics.

1
String Smtp.toString();

Return results:

  • String, returns the string representation of the object

toJSON

Returns a JSON format representation of the object, generally returning a collection of readable properties defined by the object.

1
Value Smtp.toJSON(String key = "");

Call parameters:

  • key: String, not used

Return results:

  • Value, returns a value containing JSON serializable