diff options
| author | sigoden <sigoden@gmail.com> | 2024-07-06 05:40:52 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-06 05:40:52 +0800 |
| commit | e68aa0c04366fb7b5dd648b2d2e619175ea7d922 (patch) | |
| tree | eb5c3d8f74ffb6b2ded50a436684ccf994b671ad | |
| parent | 9b1f21c5a4b85a69867f6d7d4f23f379909ccee7 (diff) | |
| download | llm-functions-docker-e68aa0c04366fb7b5dd648b2d2e619175ea7d922.tar.gz | |
refactor: tools/send_mail.sh with curl (#61)
| -rwxr-xr-x | tools/send_mail.sh | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/tools/send_mail.sh b/tools/send_mail.sh index 6ce3ad0..2645552 100755 --- a/tools/send_mail.sh +++ b/tools/send_mail.sh @@ -2,14 +2,28 @@ set -e # @describe Send a email. -# @meta require-tools mutt -# @option --recipient The recipient of the email. -# @option --subject The subject of the email. -# @option --body The body of the email. +# @env EMAIL_SMTP_ADDR! The SMTP Address, e.g. smtps://smtp.gmail.com:465 +# @env EMAIL_SMTP_USER! The SMTP User, e.g. alice@gmail.com +# @env EMAIL_SMTP_PASS! The SMTP Password +# @env EMAIL_SENDER_NAME The sender name +# @option --recipient! The recipient of the email. +# @option --subject! The subject of the email. +# @option --body! The body of the email. main() { - mutt -s "$argc_subject" "$argc_recipient" <<<"$argc_body" + sender_name="${EMAIL_SENDER_NAME:-$(echo "$EMAIL_SMTP_USER" | awk -F'@' '{print $1}')}" + printf "%s\n" "From: $sender_name <$EMAIL_SMTP_USER> +To: $argc_recipient +Subject: $argc_subject + +$argc_body" | \ + curl -fsS --ssl-reqd \ + --url "$EMAIL_SMTP_ADDR" \ + --user "$EMAIL_SMTP_USER:$EMAIL_SMTP_PASS" \ + --mail-from "$EMAIL_SMTP_USER" \ + --mail-rcpt "$argc_recipient" \ + --upload-file - + echo "Email sent successfully" } eval "$(argc --argc-eval "$0" "$@")" - |
