Email files from server (shell script)
by Danila Vershinin,
GetPageSpeed keeps NGINX and Varnish servers fast and secure: performance modules and builds, plus security fixes within days, all through routine
Free to install; commercial production use requires a subscription.
dnf, yum or apt upgrades. It maintains the largest RPM repository of NGINX module packages and Varnish VMODs, with APT packages for Debian and Ubuntu.
Free to install; commercial production use requires a subscription.
I have compiled a quick script that allows you to send files from a server in zip format. It enables you to email files (or even whole directories) as opposed to downloading them via SFTP or other means.
Pre-requisites: yum install mutt zip
Put the script below under /usr/local/bin/mail-it.sh
Email any file or directory from Linux
Now you can invoke it like this:
mail-it.sh filename email@example.com
You will get email with ZIP file attachment of the file or directory specified. Fast and convenient!
You can also provide third argument to add some descriptive text to your mail message:
mail-it.sh filename email@example.com "Here is the file you requested!"
mail-it.sh
#!/bin/bash
# requires: yum install zip mutt
# invoke: mail-it.sh filename email@example
if [ -z "$1" ]
then
echo " is required"
exit 1
fi
if [ -z "$2" ]
then
echo " is required"
exit 1
fi
file="$1"
to="$2"
msg="$3"
TFILE="/tmp/$(basename $file).zip"
rm -rf $TFILE
zip -jr $TFILE $file
echo "$msg" | mutt -a "$TFILE" -s "ZIP of $file" -- $to
rm -rf $TFILE
echo "Mail sent."