File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Linux / UNIX and the fly likes Sending File through email Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Sending File through email " Watch "Sending File through email " New topic

Sending File through email

Ranch Hand

Joined: May 29, 2002
Posts: 198

Can anybody tell me the command to send logs (files) through e mail in UNIX.Assume file is residing in UNIX dir.

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

We have a strict policy on display names, which must be a real first and last name with a space between.

Please go here and fix your display name up, pronto. Thanks, pardner!

[Jess in Action][AskingGoodQuestions]
Lewin Chan
Ranch Hand

Joined: Oct 10, 2001
Posts: 214
Well, on Linux that depends on which MTA you have installed. There are quite a few choices I think, sendmail/postfix etc etc. Commonly sendmail is installed for the local user to run from the commandline. Here's an example of using that...

echo "To: Me <>"
echo "From: You <>"
echo "Subject: Here's the file I really wanted to send you"
cat the_file_you_wanted_to_send
)> /usr/lib/sendmail -t

So basically here, you are using cat to print the file you wanted to send to the screen, this is redirected to the sendmail program

The -t option on sendmail is to "read message for recipients" so it parses the To/From/ lines for that info. You don't have to use it in that fashion of course, you can specify all those things on the commandline.

I have no java certifications. This makes me a bad programmer. Ignore my post.
I agree. Here's the link:
subject: Sending File through email
It's not a secret anymore!