Quote:
Originally Posted by mek1
Hello,
Just started bash scripting. I'm managed to grep a logfile for system's date and export the results. The issue I am hung up on is a way to pipe the contents to the body of an email.
Here's what I thought would work;
Code:
cat /home/user1/ipReport.txt | mail -s "$hostname" user@domain.com
However I get an email without anything in it. I started trying 'tail' but that wont work either for obvious reasons to me now.
Can someone explain the best method of mailing text?
...woops I probably should have created this in 'Newbie' 
|
cat /path/to/file.txt | /usr/sbin/sendmail -t
emailtogoto@domain.tld
or
cat /path/to/file.txt | /usr/sbin/sendmail -f
fromaddr@domain.tld -F "Persons Name"
toaddr@domain.tld
file.txt should look something like... (you can skip first line if you specify them on cmd line, and realistically even the To line, but it generally gives a better end result if you include them.)
Code:
From: "Persons Name" <fromaddr@domain.tld>
To: "To Addr" <toaddr@domain.tld>
Subject: Hello To!
Hi To,
How's life been treating you, get in touch.
Persons
You can use mail or a variety of other tools to send it out, I just used sendmail as an example, but you need to know what the tool you're using expects and provide it.