脚本:
代码语言:javascript复制#!/bin/bash
SENDGRID_API_KEY=""
EMAIL_TO=""
FROM_EMAIL=""
FROM_NAME=""
SUBJECT=""
bodyHTML="<p>端口被墙啦。</p>"
maildata='{"personalizations": [{"to": [{"email": "'${EMAIL_TO}'"}]}],"from": {"email": "'${FROM_EMAIL}'",
"name": "'${FROM_NAME}'"},"subject": "'${SUBJECT}'","content": [{"type": "text/html", "value": "'${bodyHTML}'"}]}'
curl --request POST
--url https://api.sendgrid.com/v3/mail/send
--header 'Authorization: Bearer '$SENDGRID_API_KEY
--header 'Content-Type: application/json'
--data "'$maildata'"
请根据提示输入自己的sendgrid相关API信息。
将代码存为shell文件,将上一个文件的echo输出改成执行此文件即可自动推送到邮箱。