<<

Sending and Reading

Get familiar with , , , and . Creating a Signature file Automatically forwarding incoming messages Announcing an absence with vocation Configuring and managing email with Using the Email

 An email message is identified by a sender and a receipt, both of which appear as headers in the message.  mailx is a mail user agent for moving mails between users on the same host.  Depending upon whether both sender and receipt are on the same host, an can take the following forms: 1. henry – user henry is on the same host 2. henry@saturn – henry is on a different host 3. [email protected] –henryis on the Internet Email Handling (1/3)

 Internet mail handling requires the works of at least three agencies: 1. Mail user agent –for reading the and sending mail, like mailx and . 2. Mail transport agent –for transporting mail between machines 3. Mail delivery agent –for delivering mail to the recipients’ mailboxes.  MUA reads incoming mail from the mailbox and hands over outgoing mail to the MTA.  MTA sends and receives mail. At the sending end, it identifies the recipient’s address and delivers the message directly to the MTA at the other end. At the receiving end, the MTA passes on mail to MDA. Internet Email Handling (2/3)

 MTA’s sending and receiving functions are handled universally by the simple mail transfer protocol (SMTP).  The MTA doesn’t deliver mail. MDA does the delivery, like procmail.  If the user’s host connects to the mail server intermittently, the user typically uses his ISP’s facilities to handle his mail. The ISP stores the user’s mail on the server, and the user fetches the mail using a separate program, such as POP3 () and IMAP (Internet Message Access Protocol). Internet Email Handling (3/3)

 mailx and pine can only view mail that has been delivered to the host on which the clients are running. They can’t receive mail from a POP/IMAP server.  To receive mail from POP/IMAP server, you need to specify the following parameters as part of your client’s setup: 1. The outgoing SMTP server 2. The incoming server that may use POP3 or IMAP. 3. Your user‐id on these servers. ~/.signature and ~/.forward

 Most mailers make use of the signature facility to append some static text to every outgoing message.  The signature message is often saved in $HOME/.signature.  When you travel, you can use the automatic forwarding facility to redirect all your incoming messages to another address.  The forwarding address is simply put in $HOME/.forward, so that MTA forwards the mail.  The forwarding function is a feature of , the program that uses SMTP and delivers most of our mail on the Internet. Multipurpose Internet Mal Extensions (MIME)  The original SMTP protocol has two limitations that disallowed the mailing of binary attachment. 1. Only 7‐bit ASCII characters could form a mail message. 2. The line length could not exceed 1000 characters.  MIME extends the definition of mail to include binary files and multiple data formats in a single message. MIME also imposes no restriction on line length.  MIME requires two additional headers to be sent with the message (in addition to the commonly appeared fields: Subject, Date, From, To, and/or Cc): 1. Content‐Type: application/pdf; name=“inter,pdf” 2. Content‐Transfer‐Encoding: base64 Mailx (1/2)  mailx is the mail utility, a command‐line tool, that POSIX requires all systems to support.  Received mail is deposited in a mailbox. Once a message has been viewed, it moves from the mailbox to .  mailx works in both sending and receiving mode. To send a mail, “mailx email_address” and end with a . or [ctrl‐d]. You may also use it non‐ interactively, as in “mailx ‐s “new system” sjkao < message.txt”. Mailx (2/2)  Incoming mail is appended to the mailbox, a text file named after the user‐id of the recipient.  The mailbox is located in /var/spool/mail (/var/mail in Unix), sjkao’s mail is appended to /var/spool/mail/sjkao.  When you enter the mailx, upon ?, you may use + to print next massage, ‐ to print previous message, d N to delete message N, s filename to save the current message, r N to reply to sender the message N, q to quit mailx, and ! cmd to run command cmd. Use w filename to save the message in separate file, such as “w 1 2 memo”. Internal Commands Used by Mailx

Command Action +Prints the next message

‐ Prints the previous message

N Prints message numbered N

hPrints headers of all messages

dN Deletes message N (the current message if N is not appeared)

u N Un‐deletes message N

s flname Saves current message with headers in flname (or mbox)

w flname Saves current message without headers in flname (or mbox)

m user Forwards mail to user

r N Replies to sender of message N

q Quits mailx

! cmd Runs the Linux command cmd Reading Email with alpine 1. Type alpine to start the program, there will be greeting message. Enter [return] to main screen. 2. Press L to view the folder list, which includes an inbox and other folders you set up. 3. Use the arrow keys to navigate the folder list. 4. Press V to view the selected folder. 5. Use ↑ and ↓ keys to move up and down in the message list. 6. Press [Enter] to read the selected message. 7. Press q to quit. Tips of Using alpine  alpine is case‐insensitive.  alpine –i starts in your inbox.  As you are pursing your email, you can use [tab] to jump to the next unread message.  delete messages by pressing [delete], either when the message is highlighted in the list or when the message is open onscreen.  reply a message by pressing [r] with a message selected or while reading a message. Sending Email with alpine 1. Type alpine 2. Press [] to compose a new massage 3. [tab] to move through the message header fields. 4. Compose your message. 5. When you are ready to send, press [ctrl+x] and confirm sending status (yes or no).  To avoid typing a lengthy email address, you may set up an alias by editing the address book (press [A]).  If you want to send email to multiple addresses, just separate them with commas or spaces. Customizing alpine 1. Type alpine 2. Press [M] to visit the main menu. 3. Press [S] to summon the setup menu. 4. Press [C] to access the configuration setup menu. 5. Scroll through the configuration list using the ↑ and ↓ keys. 6. Press [Enter] to select the option you want to change. 7. Make your selection or fill in the necessary information. 8. [Enter] to exit the configuration menu and return to main menu. You will be prompted to save your changes. Commonly Used Configuration Options Option Description initial-keystroke- Specifies key commands for alpine to use list when starting, just as if you'd typed them in directly. quit-without-confirm Allows you to exit alpine without the "are you sure?" message. signature-at-bottom Puts your automatic signature at the end of the message you're replying to, rather than above it. saved-msg-name-rule Sets alpine to automatically file your saved messages in a specific folder, based on the characteristics (sender, etc.) of the message. fcc-name-rule Sets your file copy of outgoing messages to be saved in a particular folder. We like the by- recipient option, which files messages according to whom we sent them to. use-only-domain-name Sets alpine to send all outgoing messages with just the domain name and not the machine name on the From: line. For example, our messages come from @raycomm.com , not from @frazz.raycomm.com . Reading Email with mutt 1. Type mutt at the shell prompt to start the program. The system might ask you if you want it to create folders for you. 2. Use ↑ and ↓ keys to move up and down in your mailing list. 3. Press [Enter] to open a message to read. 4. Press l to return to the list or press [Spacebar] to scroll down through the current message. 5. Press [q] to quit.

 [D] for delete, [?] for help, [R] for reply, and a specific number for the message.  Configuration file in ~/.muttrc Sending Email with mutt 1. Type mutt 2. Press [M] to start a new massage 3. [tab] to move through the message header fields. 4. Press [Enter] after you entering the information that mutt asks for, such as to: and subject:. 5. When you finished, press [Esc] 6. :wq to save work and exit the editor (vi). 7. Press [Y] to send the message. Creating a Signature File 1. Nano ~/.signature 2. Key in whatever text for your signature 3. Save and exit the file

 Both alpine and mutt automatically include a .signature file in outgoing mail. Automatically Forwarding Incoming Messages 1. vi ~/.forward 2. Key in the address as the first line of the file to which you want your email to be forwarded. 3. Save and close the file

 You can keep the incoming mails as well as forward them to unsuspecting recipients. Typing “\yourid, [email protected]” Announcing an Absence with Vocation 1. vi ~/.vocation.msg 2. Key in the message. E.g. Subject: **** (&msg) 3. Save and close the file. 4. “vocation –I” at the shell prompt to start vocation. 5. “cat ~/.forward”. The .forward file should specify what should happen to your mail upon receipt. Adding text “\yourid, |vocation yourid” in the file. 6. To stop vocation : “mv .forward vocation‐ forward”, or simple delete the reference to vocation. Configuring procmail  A mail‐filtering program, procmail, allows you to handle your incoming emails automatically.  Essentially, you create a .forward file that sends your incoming mail to procmail for processing before you ever see it.  Specify settings for procmail as follows: LOGFILE=$HOME/.maillog PATH=/usr/bin:/usr/local/bin:/bin DEFAULT=/var/spool/mail/yourid (location for incoming mails) =$HOME/Mail (specifies the location of mail program, folders, and information)  Some system requires you to turn on procmail filtering by keying in “| /usr/bin/procmail” to .forward file. Filtering Messages with procmail 1. Vi ~/.procmailrc 2. Move to the end of the file, below the setups. 3. Key in “* ^TOGolfBuddies” for examining the TO line of all incoming messages, and matching the text “GolfBuddies” in receipt field. 4. Key in “$MAILDIR /FriGolfBuddies” for specifying where the filtered mail should go. 5. Save and close the file. Forwarding Mails with procmail 1. nano ~/.procmailrc 2. Adding “:o:” on a new line at the bottom of the file. 3. Including “! [email protected]” 4. Save and close the file. Sample procmail Recipes (1/2) # filter based on the To:, Cc:, and similar headers :o: * ^TO.*awr@.*raycom.com $MAILDIR/interesting

# filter based on the subjects :o: * ^Subject:.*Status Report.* $MAILDIR/status‐reports

# filter based on the sender :o: * ^From:.*[email protected] $MAILDIR/IN.TO‐DELETE Sample procmail Recipes (2/2) # filter directly to garbage based on header :o: * ^From:.*[email protected] /dev/null

# filter based on size (greater than 1000 bytes) :o: * > 1000 $MAILDIR/longish