Austin Linux EnthusiastsHow to read and send email on your new linux machine. |
|
|
|
Additional resources, the great thing about GNU/Linux is that there are answers to nearly every question:
|
|||
Note: This is a text file I wrote as a handout a long time ago, and it surely needs updates, but for now I have placed it on the web as is. RGR 29 May 2003.
Robert G. Ristroph
This file is aimed at the brand-new linux user, who has just installed linux for the first time and is wondering the second of the first two questions they all ask: "How to I read my email?" (The first is "How do I surf the web?" and the answer is type "lynx" or "links" if you are not in X-windows mode, or try typing "mozilla&" or "galeon&" if you are in graphical mode.) There are thousands of email readers. This file presents a simple solution, enough to get you started, so that you do the basics, and you will have to educate yourself if you want to customize things. Pretty much any feature of mail reading that you can imagine is available in some mail program or another under linux. I try to explain how to get email from your ISP, where it is stored while you have not yet read it, and where it is stored long term after you have read it. This should allow you to figure out which step of the process is failing if you can't get your email, and what files to back up to preserve your email.
0) OverviewIf your machine is directly on the internet, with a DNS name, (as is the case with most broadband connections) then sending mail to your linux username (remember to create an account not just use root) should probably put the mail into the right place. For example, joeuser@cs123456.austin.rr.com should work if your computer is on and connected.This is usually problamatic because those types of names change regularly, due to the way RoadRunner and other ISP's break their own networks. One solution is to use a service like DynDNS.org to create a name that will always go to your ip address, even if that ip address changes. For example, you could set up joeuser.dyndns.org to always go to your machine, and send mail to youraccountname@joeuser.dyndns.org. If you do this (consult the dyndns.org pages for how) you can skip straight to step 2, "I think mail got to my machine", and then to step 3, "How do I read my mail." Usually a brand-new linux user has another email address already, and just wants to read that email without worrying about machine names and the other details. Sending mail directly may also be unsuitable for dial-up users, who are not connected all the time, or for people who wish for their DSL or cable modem connection not be on all the time. In this case, getting a free email account at yahoo.com and reading it on your linux machine is one of the common options. This scenario is what is described in the rest of this document. The rest of this document presumes an external pop account, so it works with many ISP's or work-related email accounts also. I recommend getting an account at freeshell.org. This is what I personally use. For a one dollar validation fee you can get a shell account that you can ssh to in order to read mail on their computers, and pop access so that you can easily get mail to your own computer.
1) Getting mail to my machine1 a) Yahoo, or the external accountYou must set up the Yahoo account to allow the mail to be retrieved by pop. (Note: since I first wrote this document pop access on yahoo is no longer free. I have added a section below about how to use a free yahoo account without pop, but I advise that you get an account at freeshell.org and use the pop access to that email address.) This is under the "Options" section on the web page. You should know the pop server machine name (pop.mail.yahoo.com in yahoo's case) your username and password. You have to know the alternative machine name if you are reading your mail from a different pop server. 1 b) Fetchmail Fetchmail is the program you will use to retrieve mail from the pop server. It has a man page, and a home page with a FAQ. You will have to make sure it is installed on your distribution (it most likely is) and you should look over the homepage ( http://catb.org/~esr/fetchmail/ ) and the "man fetchmail" output before continuing, even though you may not understand everything (or anything ;) ). 1 c ) Example .fetchmailrc Use your favorite editor (if you are brand-new to linux try emacs or nano, or mcedit) and create a file ~/.fetchmailrc which which has this line in it: poll pop.mail.yahoo.com with protocol pop3 user "myusernameatyahoo" password "secretepass" is localusername The "myusernameatyahoo" should be your account name at yahoo, in quotes. For example, for me it would be "rgristroph". Not "rgristroph@yahoo.com", just "rgristroph". The "secretepass" would be the password with quotes added around it. "pop.mail.yahoo.com" would change to something else if you are using another pop server, such as your ISP. The "localusername" string should be the name of the account you created on your linux machine. It could be the same as the account name at yahoo or on the pop server, or different. Don't use root, create a user account. ( NOTE: if you use X-windows you should be able to use a program called "fetchmailconf" to create the ~/.fetchmailrc file in a GUI way, sort of like a Wizard in Windows. Unfortunately, I have not yet made a .fetchmailrc file in this way that didn't need to be edited by hand, but feel free to check it out. ) 1 d) Running fetchmail Just type "fetchmail" at the prompt. Don't do it as root, do it as the user. If there are errors look at the ~/.fetchmailrc and see if you need to edit it. If it works, fetchmail will simply give you a prompt back. If fetchmail does find mail to get, it should print out some messages saying so. ( NOTE: rather than typing "fetchmail" by hand each time you dial in, which is fine for most people, someone connected to perment connection might wish for fetchmail to run automatically every few minutes and be started automatically on boot up, and get all mail for all users on the machine. These issues are covered in the documention of fetchmail; this document only aims to get you far enough along that you can email for help and read the answer.) 1 e) YoSucker This is a new section I added since Yahoo stopped offering pop access with the free account. In order to get email from a yahoo account with no pop access you can use the tool YoSucker. Follow the directions on that page; the gist is that you unpack the files, run the command EncPasswd to make a scrambled version of you password, which you cut and paste into one of the .conf files (and remove or hide the rest), and run the command YoSucker in the place of fetchmail to move your email to the local spool file. I will update this section further later. RGR 29 May 2003
2) I think mail got to my machine. Where is it ?Mail to be delivered to the user "username" will be in this file:/var/spool/mail/username You can view that file with the less command -- as in "less /var/spool/mail/username", to see if fetchmail put any mail there. If you are sending mail directly to the machine with it's username, or from one account on the machine to another, it should also appear in this file. This file is in the general place for new mail for a user to appear. But you generally do not read your mail here; instead you use a mail reader program that automatically looks here for new mail, and copies the mail out of this file to a local mailbox. The spool file is the temporary storage, and the file or directory you would copy to back up all your long term email is different.
3) How do I read my mail ?There are a number of mail reading programs. The new user should try several of these, and pick the one that seems simplest to learn and use. Expect that as you become more expert, you may switch. This document is not meant to teach you everything you need to know about mail, just enough so that the new user with a brand new account doesn't feel locked out and unable to use the machine.On most newly installed linuxes, at least one of the following choices will work: a) mutt Mutt is a simple text-based mailer that understands attachments. It is very popular, so you will probably be able to find other users who can answer your questions. I recommend it for the new user. Glance over the page "man mutt". It will have far more information than you can understand quickly. Then simply try to run the "mutt" command, and see if you can figure out what to do from the menus. You should be able to figure out the basics of reading and sending an email. Somewhere in your startup scripts, set the variable "EDITOR" to the program you wish to use to write emails. On some systems the default is vi, which is not friendly to newbies. You can put the line "export EDITOR=emacs" in your ~/.bash_profile. Change "emacs" to whatever you are most comfortable with; "nano" and "mcedit" are good options. When you use mutt as your reader, your email will be stored in ~/mbox. b) VM VM is one of a number of mail readers written in elisp to be run in an emacs. In a new linux distribution, VM is likely to available only in the xemacs variant of emacs. To use it, type "xemacs" at the prompt, followed by "M-x vm". The "M-x" is pronounced "meta-x", which usually mean holding the alt or windows key down and pressing the "x" key, and then releasing both (then type "v" and then "m"). In VM, you read a message by hitting the space bar when the cursor is on the summary line of that message. Compose a message by type "m", and send it when you are done with "Cntrl-c Cntrl-c". More information on VM can be found in the usual place for emacs documentation, which is by doing "M-x info" and looking for a node labeled "vm" and hitting enter while the cursor is on it. When you use VM, unless you configure it otherwise, it will keep your mail in ~/INBOX. c) elm Elm is simple and test based, very like mutt. Just run the command "elm", and follow the directions. When you use elm, unless you configure it otherwise, it will keep your mail in ~/Mail/received. d) rmail Rmail is one of a number of email readers written to be run in an emacs. It should be available in both emacs and xemacs. "M-x rmail" should start it. Space reads messages, and "m" composes a new mail. When you use rmail, it keeps your mail in the file ~/RMAIL. e) nmh - "inc, show, comp, scan" Nmh is a mail system that doesn't use a single monolithic program to read and compose mail. Rather, it is a set of small simple programs for each part of dealing with mail. It stands for "new mh", because there was a previous version called mh. It may still be called mh on some systems. "inc" stands for incorporate; it moves the mail from /var/spool/mail/username to ~/Mail/inbox, which is a directory in which each email is kept as an individual file. "show" displays the current message, or you can give it a number to display a particular message. "comp" launches an editor to compose and send a message. Like mutt, you have to set the EDITOR variable appropriately (emacs) or else it may try to use vi. "scan" lists all your messages. You can give it arguments to list only a subrange of your messages. "prev" moves to the previous message. "next" moves to the next message. Each of these commands has it's own little man page. When you use nmh, all of your mail is stored in ~/Mail/inbox, in a separate numbered file. Note: I have not listed email readers which require one to use X windows here. I may add a few later, but in general I advise new users not to do this because they may find it difficult to get X working again after switching monitors or videocards, and find themselves trapped with a linux problem and no way to email questions for help. Also, it is easier for new users to learn to use ssh and putty to read mail remotely, than for them to set up VNC or a remote X server.
4) How do I send email ?The simplest way is to send it directly from your machine, that is, simply compose the message in whatever mailer you choose and execute the send function.Any of these mailers should be configurable to tell them to use yahoo's smtp server. While pop is only for retrieving mail, smtp is for sending it, and your ISP or yahoo may offer an smtp server so mail is routed through there. If your ISP has problems with their own customers sending spam, they may have blocked out going mail that doesn't come from their smtp server. In this case you have to use the remote smtp server. Since I originally wrote this document, AOL has stopped accepting email from people's personal computers and only accepts email from ISP's smtp servers. So I have to set up my email to use my ISP's smtp server instead of sending it directly (or running an smtp server on my own) if I want to send email to AOL users. My solution is to just use the web mail accounts when I have to send email to AOL accounts (at least for now).
5) Why is some guy complaining that his spam filter blocks my mail ?When you send email directly from your machine, the headers of the email may contain a reference to "localhost", or the machine name you are using via dyndns.org, if you use that system. Some mail receivers flag messages as spam, if those messages have machine names that can't be resolved to an IP address in their header.If you are using a dyndns.org name, and you still have "localhost" somewhere in your mail headers, then look at the manpage for "hostname", and figure out how to use that command to tell your machine what it's name is, and experiment with that until the command "uname -a" does not have the string "localhost" in it. If you are not, you may want to configure your mailer to use the external smtp mail sender. Or, you can gently suggest to the complainer that they put in a special rule to not flag mail as spam if it is coming from you. If your outgoing email is reasonably configured and they still complain to you, it may be necessary to politely remind them that they are responsible for filtering their own email to their own satisfaction.
|