Type/to search
Built-in Functions
Global
Log
Market
Trade
Account
Futures
Exchange
IO
Network
HttpQuery
HttpQuery_Go
Dial
Mail
Mail_Go
Storage
Threads
TA
Talib
OS
Structures
Built-in Variables and Constants
Conventions
Exchanges

Asynchronous version of the Mail function. Supported in JavaScript and Rust; not available in Python.

Mail_Go(smtpServer, smtpUsername, smtpPassword, mailTo, title, body)

Examples

Send two emails concurrently, then wait for each result.

javascript
function main() { var r1 = Mail_Go("smtp.163.com", "[email protected]", "password", "[email protected]", "title", "body") var r2 = Mail_Go("smtp.163.com", "[email protected]", "password", "[email protected]", "title", "body") var ret1 = r1.wait() var ret2 = r2.wait() Log("ret1:", ret1) Log("ret2:", ret2) // Output: ret1 and ret2 are both true when sent successfully }
rust
fn main() { let r1 = Mail_Go("smtp.163.com", "[email protected]", "password", "[email protected]", "title", "body"); let r2 = Mail_Go("smtp.163.com", "[email protected]", "password", "[email protected]", "title", "body"); // wait(0) waits until the mail has been sent (JS: wait() with no argument) and returns // Result<bool> let ret1 = r1.wait(0); let ret2 = r2.wait(0); Log!("ret1:", ret1); Log!("ret2:", ret2); }

Returns

TypeDescription

object

The Mail_Go function immediately returns a concurrent object. You can use the wait method of this concurrent object to get the email sending result. Returns a truthy value (e.g., true) if the email is sent successfully, and returns a falsy value (e.g., false) if sending fails. In JavaScript, calling wait again after the result has been taken throws routine N already finished. In Rust, wait returns a Result<bool>, Ok(true) when the mail was sent and Ok(false) when sending failed; while the mail is still being sent it returns Err (routine N not finished) and wait can be called again; once the result has been taken, another wait returns Err (routine N already finished).

Arguments

NameTypeRequiredDescription

smtpServer

string

Yes

Used to specify the SMTP server address of the email sender.

smtpUsername

string

Yes

Used to specify the email address of the email sender.

smtpPassword

string

Yes

The SMTP authorization password for the sender's email account.

mailTo

string

Yes

Used to specify the email address of the email recipient.

title

string

Yes

Email subject.

body

string

Yes

Email body content.

See Also

Remarks

Does not work in the backtesting system.