邮件
通知目标格式
Section titled “通知目标格式”email://[<user>:<password>@]<host>[:<port>]/?to=<recipient>[&to=<recipient>...]import { send } from 'statocysts'
await send( 'email://smtp.example.com:587/?from=alerts@example.com&to=operator@example.com', { title: 'Deployment complete', body: 'Production is healthy.' },)默认端口是 587。用户名、密码和查询参数中的特殊字符必须进行 URL 编码。
| 参数 | 描述 |
|---|---|
to |
必填收件人,可重复指定。 |
cc |
抄送收件人,可重复指定。 |
bcc |
密送收件人,可重复指定。 |
from |
发件人地址,默认依次使用 defaultFrom 和 SMTP 用户名。 |
subject |
覆盖作为邮件主题的通知标题。 |
ssl |
true 启用 SSL,默认为 false。 |
tls |
除 false 外的值都会启用 TLS;端口 587 默认启用。 |
提供方专属选项
Section titled “提供方专属选项”import { email } from 'statocysts'
await email.send( 'email://smtp.example.com/?to=operator@example.com', { title: 'SMTP test' }, { defaultFrom: 'alerts@example.com', smtpConfig: { timeout: 10000 }, },)defaultFrom 可以在通知目标之外提供发件人;smtpConfig 会将部分 EmailJS SMTP 连接选项合并到从 URL 派生的配置上。
邮件通知仅支持纯文本,不支持附件或自定义消息头。