xoxys.scan2mail/templates/usr/local/bin/scan2mail.j2

17 lines
419 B
Plaintext
Raw Normal View History

2019-08-25 18:18:43 +00:00
#jinja2: lstrip_blocks: True
2020-02-12 18:36:08 +00:00
#!/usr/bin/env bash
2019-08-25 18:18:43 +00:00
{{ ansible_managed | comment }}
2020-02-12 18:36:08 +00:00
set -eo pipefail
2019-08-25 18:18:43 +00:00
FILEPATH=$1
FILENAME=$2
FROM_ADDR="{{ scan2mail_from_address }}"
2020-02-12 18:36:08 +00:00
TO_ADDRESS=$(basename "${FILEPATH}")@{{ scan2mail_mail_domain }}
ATTACHMENT="${FILEPATH}/${FILENAME}"
2019-08-25 18:18:43 +00:00
sleep 10
2020-02-12 18:36:08 +00:00
echo "{{ scan2mail_message | default('') }}" | mail -s "{{ scan2mail_subject }}" -a "From: ${FROM_ADDR}" -A "${ATTACHMENT}" "${TO_ADDRESS}"