• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 279
  • Last Modified:

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?
0
st
Asked:
st
  • 7
  • 6
  • 2
1 Solution
 
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
 
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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:
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:
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 7
  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now