Send faxes received from HylaFAX to an email address as PDFs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1.1 KiB

#!/bin/bash
# HylaFAX recieved directory
TARGET=/var/spool/hylafax/recvq
# Directory you will have converted pdfs stored
PROCESSED=/home/username/pdfs
# Edit your SMTP server info as needed
SMTPFROM=user@email.org
SMTPTO=user2@email.org
SMTPSERVER=mail.email.org:587
SMTPUSER=user@email.org
SMTPPASS=mysupersecurepassword
MESSAGEBODY="New Fax Recieved. Say whatever you want here."
SUBJECT="New Fax, or something"
# Watch the target directory for new files, wait 5
# minutes (about 20 pages worth), then convert to pdf and email the file.
inotifywait -m -e create --format "%f" $TARGET \
| while read FILENAME
do
echo Detected $FILENAME, converting to pdf and emailing
sleep 5m
tiff2pdf -o "$PROCESSED/$FILENAME.pdf" "$TARGET/$FILENAME"
wait
sleep 10s
sendEmail -f $SMTPFROM -t $SMTPTO -u $SUBJECT -m $MESSAGEBODY -s $SMTPSERVER -xu $SMTPUSER -xp $SMTPPASS -a "$PROCESSED/$FILENAME.pdf"
done