Sending Email via a Shell
Contents |
Mutt
Mutt is one of many text based email clients that are available on SHellium. Below is a sample configuration file that users may download to their home directory to get mutt up and running quickly. It is noted Mutt is already installed on the shell, and you can check this by running "ls /bin/usr/mutt*". Or you may simply run the program by typing "mutt" at the command prompt.
Configuring mutt
- Copy this file into your home directory and rename it to ".muttrc"
cd $HOME; wget http://shellium.org/~bryan/muttrc (no longer valid)
- Rename the file to .muttrc and create a .signature file for your outgoing mail signature and an .mailcap file
mv muttrc .muttrc && touch .signature .mailcap
You do not need to edit the file if you don't have any previous experience with mutt. Just create the files and edit the .signature file to add a signature to your outgoing mail and you are finished.
Using mutt
- Type 'mutt' at the command prompt and you'll see a menu at the top indicating basic commands to use.
- To send mail type 'm'
- Enter the to: address ex yourfriend@shellium.org (Hit enter key )
- Enter the subject (Hit enter key )
- Press "ESCAPE+I" to enter the insert mode. Its similar to vi.
- Then type your message, once done press "ESCAPE"
- Cursor moves to the bottom of the page with ":" in front of it.
- Type "wq!" and the message is saved and written.
- You're taken to a new screen; press "y" to send.
- It shows you a message that mail has been sent.
Using Mail command
This is how to send mail via the mail command. Perhaps a shell script can use this command some automated email
- First type mail email_address_you_want_to_send_the_mail_to (hit enter)
- Subject will appear , type your subject (see example below). Then hit enter.
- On the next line enter the body of the message.
- On a new line put a single DOT (.) and hit enter
- Enter whom you want to cc the mail to and hit enter.
- The message is sent.
An example is below
08:13:16 keeganpatrao:~$ mail keeganpatrao@shellium.org Subject: hi Hello Keegan this is a test message . CC:
Sample Configuration
Below is a copy of the sample .muttrc that we have provided in the link above
# .muttrc
set folder=~/Maildir
set arrow_cursor
set attribution="%d, %n wrote:"
set copy=yes
set edit_headers
set editor="vim"
set folder_format="%t%N %-30.30f %8s"
set index_format="%4C %Z %{%b %d} %-31.31F %N (%4c) %s"
set mailcap_path="~/.mailcap"
set menu_scroll
# set mail_check=5
set mbox=+mbox
set mime_forward=ask-no
set postponed=+drafts
set print=ask-yes
set print_command=lpr
set record=+sent
set signature="~/.signature"
# set show_alt
set pager_stop
set send_charset="us-ascii:iso-8859-1:koi8-r:windows-1251:utf-8"
set sort=threads
set sort_aux=reverse-date-received
set sort_browser=reverse-date
set spoolfile='~/Maildir'
set from="$USER <$USER@shellium.org>"
Forwarding
Forwarding your e-mail to another address is accomplished with a .forward file in your home directory. The syntax is:
some@email.address.com, another@email.address.com, and@another.email.com
If you would like to keep a copy of the mail on your shell's email account, put in your username prefixed with a backslash:
\username, email@forwarded.com