Update main.yml
This commit is contained in:
35
.github/workflows/main.yml
vendored
35
.github/workflows/main.yml
vendored
@@ -33,21 +33,32 @@ jobs:
|
|||||||
EMAIL_PASS: ${{ secrets.EMAIL_PASS }}
|
EMAIL_PASS: ${{ secrets.EMAIL_PASS }}
|
||||||
TO_EMAIL: 1627832236@qq.com
|
TO_EMAIL: 1627832236@qq.com
|
||||||
run: |
|
run: |
|
||||||
# 1. 构建邮件内容
|
# 2. 修复邮件头格式:加编码、明确From为邮箱格式、Subject转义
|
||||||
email_content=$(cat <<EOF
|
email_content=$(cat <<EOF
|
||||||
From: $EMAIL_USER
|
From: "${EMAIL_USER}" <${EMAIL_USER}> # QQ要求From必须是“名称<邮箱>”格式
|
||||||
To: $TO_EMAIL
|
To: ${TO_EMAIL}
|
||||||
Subject: 推送仓库成功
|
Subject: =?UTF-8?B?${base64_subject}?= # 解决中文主题乱码+协议错误
|
||||||
通知:有新的内容已推送到仓库「toutoukan」的main分支,
|
Content-Type: text/plain; charset=UTF-8 # 明确编码,避免特殊字符问题
|
||||||
可登录GitHub查看具体更新。
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
通知:有新的内容已推送到仓库「toutoukan」的main分支!
|
||||||
|
仓库地址:https://github.com/mayimingperson/toutoukan # 替换为实际仓库地址
|
||||||
|
触发时间:$(date +"%Y-%m-%d %H:%M:%S") # 增加动态时间,便于排查
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
# 2. 用curl发送邮件
|
# 3. 中文主题转Base64(QQ邮箱要求,否则可能触发协议错误)
|
||||||
curl -v "smtps://$SMTP_SERVER:$SMTP_PORT"
|
base64_subject=$(echo -n "推送仓库成功" | base64)
|
||||||
--mail-from "$EMAIL_USER"
|
|
||||||
--mail-rcpt "$TO_EMAIL"
|
# 4. 修复curl命令:明确smtps协议、加超时重试、输出详细日志
|
||||||
--user "$EMAIL_USER:$EMAIL_PASS"
|
curl -v \
|
||||||
-T <(echo "$email_content")
|
--connect-timeout 10 \ # 超时时间,避免卡壳
|
||||||
|
--max-time 20 \ # 最大执行时间
|
||||||
|
--smtp-ssl \ # 强制启用SSL(适配QQ邮箱)
|
||||||
|
--mail-from "${EMAIL_USER}" \
|
||||||
|
--mail-rcpt "${TO_EMAIL}" \
|
||||||
|
--user "${EMAIL_USER}:${EMAIL_PASS}" \
|
||||||
|
"smtps://${SMTP_SERVER}:${SMTP_PORT}" \
|
||||||
|
-T <(echo -e "${email_content}") # -e 处理换行符,确保格式正确
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user