Mail a file to Email Addressee via Telnet

I have a large file in my ISP server, can I send this file to my friend as a email via Telnet?
So that I don't need to download the large file to my local machine and save time.

I am beginner in unix, would you show me how to do this?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

mail < largefile
stAuthor Commented:
Can I make the large file as a attachment in the email?
Because it is a binary file. Thanks.
uuencode filename < filename | mail

There may be other ways to do it, depending on your mail program and what's available on your unix system.
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

stAuthor Commented:
Great! But how can I specify my name,To (Can it do more than one addreesee), Suject, etc? Thanks.
Yes, you can, check the man page of the mail program (type: man mail), you will see all the options available.
Since I'm not sure what mail program you're using, I'll answer in terms of /usr/lib/sendmail, which should exist on your system:

(echo 'Subject: Mail a file to Email Addressee'; echo ''; uuencode filename < filename ) | /usr/lib/sendmail
usually e-mail programs in UNIX have line options, lets say in an hypotetic example that I write something like:
mail -S"This is the subject" -C"This is a carbon copy" -T"" etc, etc. This could be easier, clearer and documented in only one man page. Notice this is just an example, you have to find out the exact option for your program.
stAuthor Commented:
ozo, your answer is quit good that I can send to more that one person, but the addressee can't not found the "To:","CC:" in the message. Moreover, how can I change "From:" instead of the email address of current ISP and how can I include my comment in the message?

I can raise some points for answering these if you need. Thanks.
Again, it might be easier to answer, (and easier to do) knowing which mail program you're using.
Many of them support command line options, or Graphical User Interfaces, or have encode/decode features for file attachments, etc,
but not all mail programs exist on all systems, and many have different features and different ways of invoking them so it's hard to give a more specific answer.

You can still do all that with /usr/lib/sendmail, but it wasn't intended as a user-interface routine, other programs usually provide that, and then use sendmail to deliver the formated message.
Although you can still do it yourself, as:

(echo 'Subject: Mail a file to Email Addressee'; echo 'CC:'; echo 'From:'; echo ''; echo 'my comments'; uuencode filename < filename ) |


(cat <<END;  uuencode filename < filename ) | /usr/lib/sendmail
Subject: Mail a file to Email Addressee

my comment in the message

stAuthor Commented:
ozo, I tried the second approach and got this message "Can't << within ()'s."
The first aproach can be success in my mail system, but even I specified the email address in the "TO :" or "CC: ", the addressee can't received my mail, only the email addresses specified in the last of the command line can received the mail.

Moreover, when I specified the "TO : superman", the mail will being "TO :".

Are these normal in my unix system? Can I change them? Thanks.
Not only are there different mail programs with different, but different shells with different syntax too.
I thought I tested (cat <<END; ...) in both sh and csh, but it looks like I only checked it in sh, sorry.

In mail messages, there's a distinction between the "envelope", used by the delivery agent,
the "headers" used by the mail readers, and the "body", the actual text of the message.
You can use the -t switch
sendmail -t
to tell sendmail to gather recipient addresses from the headers in addition to the command line.
(normally your mail program would take care of all of these details for you, and you wouldn't have to worry about it)

Doing things with just the command line is handy for quick little commands, but it can get increasingly unweildy for longer more complicated things.
Do you have a file editor on your system you can use?  Maybe emacs or vi or some other?

If not we can still always use cat:
cat >mail.header
To: superman
From: st

my comments in the body of the message after a blank line
terminated with a control-D (assuming you haven't redefined youe EOF character)

(cat mail.header;  uuencode filename < filename ) | /usr/lib/sendmail -t

(If you don't specify the site for a user, it usually assumes user@mysite)
stAuthor Commented:
ozo, thank you very much for your answer. How can give the "points" to you?
If you're happy with the answer, you can grade it.
Otherwise, you can reopen the question and see if you can get a better answer.
(like if you want to know about using any particular mail program)

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
I interpreted your last comment to mean that you were happy with the information you've recieved.
If I misunderstood, please Reopen the question, and add a comment to tell us how else we may help you.
stAuthor Commented:
Your posting is very helpful! Thanks.
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.