Skip to content

Instantly share code, notes, and snippets.

@viniroger
Last active July 10, 2019 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viniroger/962b7e46b397a740eeaf1798866d3a9a to your computer and use it in GitHub Desktop.
Save viniroger/962b7e46b397a740eeaf1798866d3a9a to your computer and use it in GitHub Desktop.
Shell script to send e-mail with attachments and body to mails list
envio_email(){
# Escrever corpo do e-mail
echo "Seguem anexos" >> $arq_email
printf "\n" >> $arq_email
# Arquivo de texto no corpo de e-mail
cat $arq_descr >> $arq_email
# Criar lista de e-mails a partir de arquivo
readarray -t lista_emails < <(cat $DIR/helpers/destinatarios_teste.txt | grep $grupo | awk -F',' '{print $1}')
# Enviar e-mails para clientes
for mail in ${lista_emails[@]}; do
echo enviando e-mail com anexo para $mail
cat $DIR/saida/corpo_email.txt | mutt -e 'my_hdr Reply-To:teste@teste.com.br,teste2@teste.com.br' -s "Assunto ${data}" -a "$DIR/saida/arquivo.zip" -- $mail
done
}
envio_email
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment