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?
LVL 1
stAsked:
Who is Participating?
 
ozoConnect With a Mentor Commented:
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)
0
 
ozoCommented:
mail friend@ISP.com < largefile
0
 
stAuthor Commented:
Can I make the large file as a attachment in the email?
Because it is a binary file. Thanks.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
ozoCommented:
uuencode filename < filename | mail friend@ISP.com

There may be other ways to do it, depending on your mail program and what's available on your unix system.
0
 
stAuthor Commented:
Great! But how can I specify my name,To (Can it do more than one addreesee), Suject, etc? Thanks.
0
 
jlmsCommented:
Yes, you can, check the man page of the mail program (type: man mail), you will see all the options available.
0
 
ozoCommented:
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 friend@ISP.com st@ISP.com
0
 
jlmsCommented:
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"abc@xxx.com" 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.
0
 
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.
0
 
ozoCommented:
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: abc@xxx.com'; echo 'From: st@experts-exchange.com'; echo ''; echo 'my comments'; uuencode filename < filename ) |
     /usr/lib/sendmail friend@ISP.com st@ISP.com

or

(cat <<END;  uuencode filename < filename ) | /usr/lib/sendmail friend@ISP.com st@ISP.com
Subject: Mail a file to Email Addressee
CC: abc@xxx.com
From: st@experts-exchange.com

my comment in the message
END

0
 
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 : superman@my_isp.com".

Are these normal in my unix system? Can I change them? Thanks.
0
 
ozoCommented:
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
Cc: abc@xxx.com
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)
^D

(cat mail.header;  uuencode filename < filename ) | /usr/lib/sendmail -t friend@ISP.com superman@krypton.dccomics.com

(If you don't specify the site for a user, it usually assumes user@mysite)
0
 
stAuthor Commented:
ozo, thank you very much for your answer. How can give the "points" to you?
0
 
ozoCommented:
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.
0
 
stAuthor Commented:
Your posting is very helpful! Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.