Solved

Mail a file to Email Addressee via Telnet

Posted on 1998-03-06
15
259 Views
Last Modified: 2010-04-21
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
Comment
Question by:st
  • 7
  • 6
  • 2
15 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 2008950
mail friend@ISP.com < largefile
0
 
LVL 1

Author Comment

by:st
ID: 2008951
Can I make the large file as a attachment in the email?
Because it is a binary file. Thanks.
0
 
LVL 84

Expert Comment

by:ozo
ID: 2008952
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
 
LVL 1

Author Comment

by:st
ID: 2008953
Great! But how can I specify my name,To (Can it do more than one addreesee), Suject, etc? Thanks.
0
 
LVL 4

Expert Comment

by:jlms
ID: 2008954
Yes, you can, check the man page of the mail program (type: man mail), you will see all the options available.
0
 
LVL 84

Expert Comment

by:ozo
ID: 2008955
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
 
LVL 4

Expert Comment

by:jlms
ID: 2008956
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 1

Author Comment

by:st
ID: 2008957
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
 
LVL 84

Expert Comment

by:ozo
ID: 2008958
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
 
LVL 1

Author Comment

by:st
ID: 2008959
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
 
LVL 84

Expert Comment

by:ozo
ID: 2008960
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
 
LVL 1

Author Comment

by:st
ID: 2008961
ozo, thank you very much for your answer. How can give the "points" to you?
0
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 2008962
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
 
LVL 84

Expert Comment

by:ozo
ID: 2008963
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
 
LVL 1

Author Comment

by:st
ID: 2008964
Your posting is very helpful! Thanks.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now