Solved

Sending an email with attachemtn via cron

Posted on 2014-12-06
4
149 Views
Last Modified: 2014-12-14
Hi,

I want to send a txt file as an attachment via a cron command.

/usr/lib/sendmail email@domain.com < /path/to/file.txt

When I use the following command, the contents of the file are in the body and it is not an attachment.

How can I have the text file be an attachment?

Thanks!
0
Comment
Question by:Computer Guy
  • 2
4 Comments
 
LVL 3

Author Comment

by:Computer Guy
ID: 40484696
This is a log file I want to email so I can view the errors if they occur. I want it sent once an hour which I have setup if that helps.
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 40484773
try this

 /usr/bin/uuencode /path/to/file.txt  file.txt | /usr/lib/sendmail email@domain.com

This will send /path/to/file.txt as attachment "file.txt"
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 40484774
Please add above as crontab job. Do you need help in that?
0
 
LVL 34

Accepted Solution

by:
Seth Simmons earned 500 total points
ID: 40484965
i had issues with uuencode; found mutt to work better

mutt -s "subject" -a filename.tar.gz user@domain.com < message-body.txt

if not installed, do yum install mutt (fedora/red hat/centos) or apt-get install mutt (debian/ubuntu/mint)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now