Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

how to use "mail" command send mail in internet! tks!

Eric_yuan
Occasional Visitor

how to use "mail" command send mail in internet! tks!

how to use "mail" command send mail in internet! tks!
pls detail.
1 REPLY
OFC_EDM
Respected Contributor

Re: how to use "mail" command send mail in internet! tks!

This all assumes your sendmail is configured and that you're "allowed" to send mail externally to the internet

mailx is my preferred command

Echo body of message
--------------------
echo sometest | mailx -s "subject" emailaddr@somewhere.com

Redirect file with message
--------------------
mailx -s "subject" emailaddr@somewhere.com < file.txt

Attach a file
--------------------
uuencode /tmp/file.txt file.txt | mailx -s "subject" emailaddr@somewhere.com

- in this method you first give the path and name of the file
- then you give the name of the file (allows you to rename it if you like)

So I could also do
uuencode /tmp/file.txt file.doc | mailx -s "subject" emailaddr@somewhere.com

So the file shows up with a .doc extension and can be quickly opened with Word by the user (dbl click) when it's received in Outlook as an example.
The Devil is in the detail.