Tags
#!/bin/bash
# Script Version: 1.2
# Description: Send a file via email to a specified recipient

# Set variables
EMAIL_SUBJECT="File Attachment"
EMAIL_BODY="Please find the attached file."

# Check if both email and file path are provided as arguments
if [ $# -ne 2 ]; then
   echo "Usage: $0 recipient@example.com /path/to/your/file.gz"
   exit 1
fi
RECIPIENT_EMAIL="$1"
ATTACHMENT_PATH="$2"

# Check if the file exists
if [ ! -f "$ATTACHMENT_PATH" ]; then
   echo "Error: File '$ATTACHMENT_PATH' not found."
   exit 1
fi
# Send email with attachment
echo "$EMAIL_BODY" | mutt -s "$EMAIL_SUBJECT" -a "$ATTACHMENT_PATH" -- "$RECIPIENT_EMAIL"

# Check if the email was sent successfully
if [ $? -eq 0 ]; then
   echo "Email sent successfully to $RECIPIENT_EMAIL"
else
   echo "Failed to send email"
   exit 1
fi