Skip to content

Instantly share code, notes, and snippets.

@rafaelcpalmeida
Last active May 5, 2022 07:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaelcpalmeida/93161b194f8a22d287048529ea59acb4 to your computer and use it in GitHub Desktop.
Save rafaelcpalmeida/93161b194f8a22d287048529ea59acb4 to your computer and use it in GitHub Desktop.
Send emails with text from a textbox called from crontab
#!/bin/bash
# /usr/local/bin/reportSender.sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export DISPLAY=:0.0
export XAUTHORITY=/home/USER/.Xauthority
MAIL="$(zenity --entry --title="Report Sender" --text="O que é que fizeste hoje?")"
if [ -z "$MAIL" ]
then
zenity --info --title="Report Sender" --text="Texto em branco.\nA ignorar..."
else
swaks --to email1@provider.com,email2@provider.com --from "email1@provider.com" --server smtp.provider.com --auth LOGIN --auth-user "email1@provider.com" --auth-password "Here" -tls --header "Content-Type: text/html; charset=UTF-8\nSubject: Envio de relatório diário\nFrom: John Appleseed <email1@provider.com>" --body "A actividade de hoje foi:<br/><br/><br/>${MAIL}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment