One linux command available from most linux distro is mailx.
In general, mailx is a simnple command line mail sending and receiving facility. Mailx tool, when invoked with correct CLI parameter, is capable of checking emails, sending and receiving mails from command line terminal. Mailx is a powerful tool which can offer a flexible and various command line options down from composing emails, sending attachment files, checking emails and receiving incoming mails. You can see more of its man pages.
With Fedora and RedHat, Mailx binary is part of redhat-lsb rpm package.
MailX Options:
==============
How to check emails using mailx from command line terminal?
-------------------------------------------------
As root, simply issue from terminal:
~~~~~~~~~~~~~~~~~~~
# mailx
~~~~~~~~~~~~~~~~~~~
You can access more mailx command options and help by pressing ?
Several interactive key commands inside mailx facility are:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
t
n goto and type next message
e
f
d
s
u
R
r
pre
m
q quit, saving unresolved messages in mbox
x quit, do not remove system mailbox
h print out active message headers
! shell escape
cd [directory] chdir to directory or home if none given
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To quit mailx facility, simply type q and hit enter key.
How to compose and send an email using mailx via terminal?
------------------------------~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The below samples sends an email to root@localhost using mailx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# mailx -v root@localhost
Subject: linux sysad blog
and this is my email body
.
Cc: [ENTER]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
After hitting the ENTER key, mailx mail facility shows a more verbose logging from mail handshake to mail delivery status.
Alternatively, to send an email using mailx from terminal, simply issue
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# echo "Body of Email" | mailx -v -s "Linux Blog Subject" root@localhost -c root@google.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
How to inject or insert a text file as an email body to mailx mail message?
-------------------------------------------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# cat body.txt
Hello, How are you ?
# cat body.txt | mailx -v -s "Linux Blog Subject" root@localhost -c root@google.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As shown above, the file body.txt is a text file that would be appended into the email message serving as the body of that particular email message.
How to attach and append a text file inside mailx mail facility via terminal?
------------------------------------------------------------------------------
To attach a text file from the email using mailx, this can be done inside the mailx mail facility by specifying ~r interactively. The ~r format should be followed by a text filename separated by a space like so
# cat text.txt
~~~~~~~~~~~~~~~~~~~~~
Hello, How are you ?
~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# mailx -v -s "Linux Blog Subject" root@localhost
I am typing the body of email, now I will attach a text file using the below command
~r text.txt
.
Cc: root@google.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note that ~r parameter works only with text file. Yes, you need a separate character encoding mechanism when attaching any non-text files using mailx mail facility. This can be done using a separate linux binary then.
How to send and attach non-binary file as email attachments from terminal?
--------------------------------------------------------------------------
To achieve this, as an alternative to mailx mail facility, you can use the linux mail binary command on sending non-binary email attachments from terminal.
For further sample of mail binary command, refer to previous posting here.
Hope this helps.
Subscription
Categories
- HowTos (612)
- Linux Devices (40)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
▼
2007
(340)
-
▼
November
(39)
- HowTo: Strip directory path and filename suffix
- HowTo: Get the Filename Extension Only
- Tailf - watch the linux log file grows
- Fedora 8 with Enlightenment Window Manager
- HowTo: ScreenCasts & Desktop Records via Istanbul
- HowTo: Record Desktop Session via Byzanz
- Linux Scorched 3D Tank Game
- Linux Atomic Battle Tank Game
- HowTo: Display a Tree of Linux Processes
- Howto: 3 Easy Install Steps of Microsoft Fonts in ...
- Howto: Convert PDF to HTML/XML/PNG in Linux
- Livna Repository on Fedora 8
- Linux Action Flight Simulator Game
- Splitting and Merging Multiple Linux Files
- Sort Nth Position of Nth Column of a File in Linux
- Stop, Pause, and Continue A Linux Process
- File Creation without File Opening in Linux
- Concatenate Multiple Files in Linux
- Renaming Files in Linux
- Linux Power Consumption Analysis Tool
- Tail and Head Few Lines of Text Files
- Three Easy Steps for Opera on Fedora 8
- Alternative Search and Replace Tool
- Display Lines Beginning with a Given String
- Spell Check Files via Terminal - Install Howto
- Display Linux Session Jobs
- Get Linux Disk Space and Usage
- Change Linux RunLevels Howto
- Audacious - Install Howto
- Amarok - Howto Install
- Sun Java on Fedora 8 Install HowTo
- My Fedora 8 Diary
- Chikka on Kopete Messenger Howto
- Linux Files and Folders Local Copying
- Linux folders and directories recursive removal
- MailX - Mail Facility via Terminal
- Time zone values interpretation
- Retrieving Linux Standard Base and Distro Information
- Fedora Firstboot
-
▼
November
(39)
Tuesday, November 13, 2007
MailX - Mail Facility via Terminal
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy
0 comments:
Post a Comment