Sending email using unix's command mail problem

Dear all,,

Can anyone tell me how to send an email with aa file attachment by using unix's command mail?


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You don't give flavor of unix but I use mailx to send attachments.

Example: mailx username
Subject: here's your file

Enter whatever text you need to and then to attach the file type:

~r filename

To complete the message and send it, type a . on a new line.

I also know that pine can send attachments but am not real familiar with it.
benson031397Author Commented:
OK!  Thanks!
~r does not make an attachement, it just "includes" into the normal body
There is no standard (command-line) mail program to do this.
You either need a more sophisticated one like pine, or use perl with MIME::Lite;
As ahoffmann explained above, ~r does not make attachments, just reads files.

However, most modern versions of mailx do understand attachments.  Read the main page for mailx on your system.  If yours doesn't however, there are still a few good ways to go.

As ahoffmann pointed out above, pine will do the job, but it's really designed for interactive use and isn't very good in scripts.  The perl mechanism pointed out by ahoffmann above works much better in scripts.  Finally, you can also use Bellcore's Metamail program, which is available from, among other places,

Some good backgrounds on the subject include the comp.mail.mime FAQ, available from, among other places, and the University of Indiana' page at

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.