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

Send an email.

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

Examples

Send an email through 163 Mail's SMTP service.

javascript
function main(){ Mail("smtp.163.com", "[email protected]", "password", "[email protected]", "title", "body") }
python
def main(): Mail("smtp.163.com", "[email protected]", "password", "[email protected]", "title", "body")
rust
fn main() { Mail("smtp.163.com", "[email protected]", "password", "[email protected]", "title", "body"); }

Returns

TypeDescription

bool

Returns a truthy value, such as true, when the email is sent successfully; returns a falsy value, such as false, when sending fails.

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

Used to specify the SMTP service password of the email sender's mailbox.

mailTo

string

Yes

Used to specify the email address of the email recipient.

title

string

Yes

The email subject.

body

string

Yes

The email body.

See Also

Remarks

The smtpPassword parameter sets the password for the SMTP service, not the mailbox login password.

When setting the smtpServer parameter, if you need to change the port, you can append the port number directly in the smtpServer parameter. For example: the smtp.qq.com:587 port of QQ Mail has been tested and works.

If the error unencryped connection occurs, you need to modify the smtpServer parameter of the Mail function to the format ssl://xxx.com:xxx. For example, the ssl method for QQ Mail SMTP is ssl://smtp.qq.com:465, or use smtp://xxx.com:xxx.

This function does not work in the backtesting system.