I have a shell script that uses sendmail function to send email the code is as follows
mailalert(){
sendmail -F Sender-Name -it <<END_MESSAGE
To: Recipient@example.com
Subject: Subject
Message
END_MESSAGE
}
It gets executed whenever I call this function. Now I have a text file which I want to send using sendmail as attachment or as message in the email it sends. How can I do that? I have tried alot of tricks but nothing seems to work. Please Help.
Best Answer
Type
uuencode /path/filename.txt | sendmail -s "subject" user@domain
in your terminal to send mail.this is the actual process to send mail with attachment.
add
uuencode /path/filename.txt
before sendmail command in your script. I mean modify it ashope that can help you.