«

»

May 31

Sending a file as an email attachment using mutt command

In this article, we are going to look at way to sending a file as an email attachment using mutt command on Linux environment. There are many options and commands are available on Linux, but in here, mutt command is used. It is very simple than you are thinking. Try below shell script for that. You are to change email address and location of the attachment accordingly.

#!/bin/bash
FROM_ADDRESS="From address <from@abc.com>"
TO_MAIL=to@abc.com

echo "" > $emailPath
echo "This is message body" >> $emailPath
echo "" >> $emailPath
echo "more message body" >> $emailPath

export EMAIL=$FROM_ADDRESS && mutt -a /report/location/testreport.csv -s "This is Email Title" $TO_MAIL < $emailPath

Leave Your Thought Here