Solved

Sending an email with attachemtn via cron

Posted on 2014-12-06
4
152 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
AWS RDS 3 66
AWS vpc peering connection 1 42
php ssh2_scp_send 1 47
networking details on centos 6.6 4 50
This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

911 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

17 Experts available now in Live!

Get 1:1 Help Now