输入/搜索内容
内置函数
Global
Log
Market
Trade
Account
Futures
Exchange
IO
Network
HttpQuery
HttpQuery_Go
Dial
Mail
Mail_Go
Storage
Threads
TA
Talib
OS
结构体
内置变量与常量
通用约定
交易所

发送邮件。

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

示例

通过163邮箱的SMTP服务发送一封邮件。

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"); }

返回值

类型描述

bool

邮件发送成功时返回真值,例如true;发送失败时返回假值,例如false。

参数

名称类型必填描述

smtpServer

string

是

用于指定邮件发送方的SMTP服务器地址。

smtpUsername

string

是

用于指定邮件发送方的邮箱地址。

smtpPassword

string

是

用于指定邮件发送方邮箱的SMTP服务密码。

mailTo

string

是

用于指定邮件接收方的邮箱地址。

title

string

是

邮件标题。

body

string

是

邮件正文。

参考

备注

smtpPassword参数设置的是SMTP服务的密码,而非邮箱登录密码。

设置smtpServer参数时,如需更改端口,可直接在smtpServer参数中附加端口号。例如:QQ 邮箱的smtp.qq.com:587端口经测试可用。

如果出现报错unencryped connection,则需要修改Mail函数的smtpServer参数,其格式为ssl://xxx.com:xxx。例如,QQ 邮箱SMTP的ssl方式为ssl://smtp.qq.com:465,或使用smtp://xxx.com:xxx。

该函数在回测系统中不起作用。