?
Solved

mail command in linux

Posted on 2000-03-24
13
Medium Priority
?
426 Views
Last Modified: 2013-11-13
I want to send an attached file using the mail command.

I have tried

mail somebody@somewhere.com -s 'File Attachement' < file.txt

This sends the file but not as an attachement, instead when you click on the mail, the file contents are displayed directly in the browser.

I have also tried

uuencode file.txt | mail -s 'File Attachement' somebody@somewhere.com

This attaches a file, but I am unable to view it when I click on.

Would somebody know what I am doing wrong, or possibly suggest a solution to this problem

Marlise

0
Comment
Question by:marliseb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
13 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 2653157
That's because the "mail" utility can't generate multi-part messages, which is what you need to send a message with an attached file. Any of the more advanced clients can, such as pine, Netscape, etc., but not from the command line.
0
 
LVL 4

Expert Comment

by:kiffney
ID: 2653314
Try 'mailto', which allows you to add a file by just hitting ~* in the body of the text - you have to type in the file name, and specify the type - like image/gif, or application/octet-stream, or whatever, but it works.  If you don't have 'mailto', check www.rpmfind.net.
0
 

Author Comment

by:marliseb
ID: 2653384
I want to be able to embed this command in a shell script that will be used by the cron utility to automate a certain task.  As a result the mail / mailto command will not be able to have any user interaction.  

Will this be possible???

I tried the mailto command, but it didn't work, can you give me more details please.


0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:marliseb
ID: 2653427
I want to be able to embed this command in a shell script that will be used by the cron utility to automate a certain task.  As a result the mail / mailto command will not be able to have any user interaction.  

Will this be possible???

I tried the mailto command, but it didn't work, can you give me more details please.


0
 
LVL 4

Expert Comment

by:kiffney
ID: 2653621
when you said 'I tried it but it didn't work' do you mean, you don't have a mailto program?  If so, do you have redhat?  there's an rpm called 'metamail' that contains the mailto program - install that with
rpm -U -p metamail
(filling in the path to the RPMS directory and the full name of the metamail package).  Or download it from
ftp://thumper.bellcore.com/pub/nsb/mm2.7.tar.Z, extract it with 'tar xzf mm2.7.tar.Z', read the INSTALL or README to find out how to install it, and then try it out.   Actually, mailto runs from an interactive shell, so you don't want to use that, but the metasend program will run from a shell script, so try that.
0
 

Author Comment

by:marliseb
ID: 2653742
No the mailto program is actually installed on Linux.

Can someone tell me more about metasend?
0
 
LVL 4

Expert Comment

by:kiffney
ID: 2653839
Yeah, you just do

metasend -F sendername -f filename -s subject -t recipient  -m Mime-type-of-file

There are more options and you might not have to specify mime-type.  Install the metamail package - metasend is in there and will do what you want.  I'd forget about mailto, that was a mistake on my part to suggest it as it won't work from a script.  But metasend will.
0
 

Author Comment

by:marliseb
ID: 2653865
No the mailto program is actually installed on Linux.

Can someone tell me more about metasend?
0
 

Author Comment

by:marliseb
ID: 2653956
I tried the metasend, but it does the same thing as the others, it doesn't include the file as an attachment, instead it embeds the file in the mail subject.

I can't seem to work around this problem!
0
 
LVL 4

Expert Comment

by:kiffney
ID: 2654111
I don't know, they work for me.  Maybe there is something wrong with your mail reader.  I don't see how the file would wind up in your mail subject - that just doesn't make any sense.
0
 

Author Comment

by:marliseb
ID: 2654258
Sorry I mean the file doesn't get attached, when I click on the mail, the file is display in the mail.
0
 
LVL 4

Expert Comment

by:kiffney
ID: 2654914
Well, if it's a txt file, maybe that's the reason. Try a gif file and specify its mime type as image/gif.
0
 
LVL 1

Accepted Solution

by:
philiph_elvis earned 30 total points
ID: 2669982
metasend -b -s "heres the file" -m application/postscript -f /tmp/foo.ps -t user@foo.bar

I tested this and it attaches the file correctly.  The tricky part is specifying the mime type correctly, you have to do that manually.  If you were sending a gif, the entry after -m would be image/gif.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Monitor input from a computer is usually nothing special.  In this instance it prevented anyone from using the computer.  This was a preconfiguration that didn't work.
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…
Suggested Courses
Course of the Month14 days, 3 hours left to enroll

801 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