1 2 3 4 5 6 7 8 9 |
# ... everything as before... mail -s "$subject" -r "$from" -S smtp="smtp://${smtpserver}:${smtpport}" \ -S smtp-auth=login \ -S smtp-auth-user="$user" \ -S smtp-auth-password="$password" \ -S sendwait \ "${attargs[@]}" "$to" <<< "$body" # use the correct value for smtp-auth, and also -S smtp-use-starttls to do TLS |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#!/bin/bash # This needs heirloom-mailx from="sender@example.com" to="recipient@example.org" subject="Some fancy title" body="This is the body of our email" declare -a attachments attachments=( "foo.pdf" "bar.jpg" "archive.zip" ) declare -a attargs for att in "${attachments[@]}"; do attargs+=( "-a" "$att" ) done mail -s "$subject" -r "$from" "${attargs[@]}" "$to" <<< "$body" |