name: 'Notify Email' description: 'Send Gitea Actions run result via SMTP (163/126 compatible)' author: 'gitea_admin' inputs: smtp_host: description: 'SMTP host (e.g. smtp.126.com)' required: true smtp_port: description: 'SMTP SSL port' required: false default: '465' smtp_user: description: 'SMTP user (full email address)' required: true smtp_pass: description: 'SMTP authorization code' required: true from: description: 'From address' required: false default: ${{ inputs.smtp_user }} to: description: 'Recipient(s), comma separated' required: true subject: description: 'Email subject' required: true body: description: 'Email body (plain text)' required: true runs: using: 'composite' steps: - name: Send email via SMTP shell: bash env: SMTP_HOST: ${{ inputs.smtp_host }} SMTP_PORT: ${{ inputs.smtp_port }} SMTP_USER: ${{ inputs.smtp_user }} SMTP_PASS: ${{ inputs.smtp_pass }} FROM_ADDR: ${{ inputs.from }} TO_ADDR: ${{ inputs.to }} SUBJECT: ${{ inputs.subject }} BODY: ${{ inputs.body }} run: | set -u # 构造 --mail-rcpt 参数(每个收件人一个) RCPT_ARGS="" IFS=',' for addr in $TO_ADDR; do RCPT_ARGS="$RCPT_ARGS --mail-rcpt $(printf '%s' "$addr" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" done unset IFS # shellcheck disable=SC2086 if ! printf '%s' "$BODY" | curl -fsS --ssl \ --url "smtps://${SMTP_HOST}:${SMTP_PORT}" \ --user "${SMTP_USER}:${SMTP_PASS}" \ --mail-from "${FROM_ADDR}" \ $RCPT_ARGS \ -H "Subject: ${SUBJECT}" \ -H "From: ${FROM_ADDR}" \ -H "To: ${TO_ADDR}" \ -H "Content-Type: text/plain; charset=UTF-8" \ --max-time 15 --retry 2 \ --upload-file -; then echo "::warning::Email send failed (non-fatal)" fi