Update main.yml
This commit is contained in:
32
.github/workflows/main.yml
vendored
32
.github/workflows/main.yml
vendored
@@ -33,38 +33,36 @@ jobs:
|
|||||||
EMAIL_PASS: ${{ secrets.EMAIL_PASS }}
|
EMAIL_PASS: ${{ secrets.EMAIL_PASS }}
|
||||||
TO_EMAIL: 1627832236@qq.com
|
TO_EMAIL: 1627832236@qq.com
|
||||||
run: |
|
run: |
|
||||||
# 验证SMTP参数是否正确(调试用,可删除)
|
# 1. 修复URL格式(核心)
|
||||||
echo "SMTP服务器: $SMTP_SERVER"
|
smtp_url="smtps://${SMTP_SERVER}:${SMTP_PORT}"
|
||||||
echo "SMTP端口: $SMTP_PORT"
|
smtp_url=$(echo "$smtp_url" | tr -d '[:space:]') # 强制移除所有空白字符
|
||||||
echo "发件人: $EMAIL_USER"
|
echo "最终SMTP URL: [$smtp_url]" # 调试用,确认格式
|
||||||
|
|
||||||
# 检查URL格式是否正确(调试用,可删除)
|
# 2. 中文主题编码
|
||||||
smtp_url="smtps://$SMTP_SERVER:$SMTP_PORT"
|
base64_subject=$(echo -n "推送仓库成功" | base64 | tr -d '\n')
|
||||||
echo "SMTP URL: $smtp_url"
|
|
||||||
|
|
||||||
# 中文主题Base64编码
|
# 3. 构建邮件内容
|
||||||
base64_subject=$(echo -n "推送仓库成功" | base64)
|
email_content=$(cat <<-EOF
|
||||||
|
From: "${EMAIL_USER}" <${EMAIL_USER}>
|
||||||
# 构建邮件内容
|
To: ${TO_EMAIL}
|
||||||
email_content=$(cat <<EOF
|
Subject: =?UTF-8?B?${base64_subject}?=
|
||||||
From: "$EMAIL_USER" <$EMAIL_USER>
|
|
||||||
To: $TO_EMAIL
|
|
||||||
Subject: =?UTF-8?B?$base64_subject?=
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
|
||||||
通知:有新的内容已推送到仓库「toutoukan」的main分支
|
通知:有新的内容已推送到仓库「toutoukan」的main分支
|
||||||
推送时间: $(date +"%Y-%m-%d %H:%M:%S")
|
推送时间: $(date +"%Y-%m-%d %H:%M:%S")
|
||||||
|
推送作者: $(git log -1 --pretty=format:'%an')
|
||||||
|
提交信息: $(git log -1 --pretty=format:'%s')
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
# 发送邮件(修复URL格式)
|
# 4. 发送邮件(修复认证和URL)
|
||||||
curl -v \
|
curl -v \
|
||||||
--connect-timeout 10 \
|
--connect-timeout 10 \
|
||||||
--max-time 20 \
|
--max-time 20 \
|
||||||
--mail-from "$EMAIL_USER" \
|
--mail-from "$EMAIL_USER" \
|
||||||
--mail-rcpt "$TO_EMAIL" \
|
--mail-rcpt "$TO_EMAIL" \
|
||||||
--user "$EMAIL_USER:$EMAIL_PASS" \
|
--user "$EMAIL_USER:$EMAIL_PASS" \
|
||||||
"$smtp_url" \ # 使用预定义的URL变量,避免格式错误
|
"$smtp_url" \
|
||||||
-T <(echo -e "$email_content")
|
-T <(echo -e "$email_content")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user