![]() |
Search |
| Home |
Desktop FreeBSD Part 4: Internet Mail SetupBy Ed Hurst |May 18, 2007 at 21:40:9The one thing that really fired up the development of the Internet as we know it today was e-mail. The protocols were designed back when the system itself was highly difficult to access, and security wasn't a significant issue. Since then, even your average household pet has heard of Internet security problems. How many times have we read popular pronouncements not to use a certain popular e-mail program that is highly vulnerable to attacks hidden in messages? Those attacks are possible because the program is designed to make things so easy. It does everything for you. It's too easy for folks to forget the danger, because that's the software that came with their systems. That sort of large, do-it-all software takes up lots of resources, too. There is a better way. It requires changing how you view Internet mail, going back to the original intent. In this case, it also means using what came with your system -- your FreeBSD system. However, be aware, if you do not have a mail server account with your ISP, or some other provider, you will probably have a difficult time using a built-in system mail server to send mail across the Net. Most mail services to whom you try to send mail will probably be blocking mail from dialup and DSL connections. If you cannot work this out, while you may learn a lot, you'll still be stuck using a regular mail client. We will install Postfix and Fetchmail. You should already have Mutt
for console email. None of these work directly from the
graphical user interface (GUI), so we will spend some
more time getting used the command line interface
(CLI) environment. Recall the previous lesson on installing software
from ports. Login as root and navigate to
To make sure Postfix is ready to run, we'll follow the instructions
from the configuration file itself. Using Joe, open
Then type these commands:
Hopefully, you'll see some messages about Sendmail stopping after the first one, and Postfix starting up after the second. By the way, there is a reason we users of FreeBSD love the CLI. Aside from all the elitist talk of "pure computing" there is a very practical issue involved. If there is one thing likely to crash on any computer system, it is the GUI. GUI hardware is more likely to work poorly than any other hardware, so the software for it is much more difficult to write. Since we know Open Source systems run the GUI on top of the real heart of the computer, it is important that every computer user be able to work a little bit without the GUI, because you can still get most of your work done. It just requires knowing some things you haven't bothered to learn yet. If something in your system breaks, your best chance of getting by until it's fixed is to be ready to work in the CLI. Even better, some of the best software that exists works only in the CLI. And you may be surprised to learn that the mail server software in FreeBSD takes less power, and works better and more safely, than those big bloated GUI e-mail programs. THE E-MAIL SYSTEMThere are three parts to a proper e-mail system:
Nowadays, you can add to the list a filtering agent if you need to deal with lots of different kinds of messages or have lots of spam. However, the main three can do that to some degree internally. The first two in our list above are the backbone of what mail servers all over the world do. We've already discussed how you shouldn't run Open Source systems without using the MTA, so it is built into every one of them. The system depends on it. THE MTA: POSTFIXWe've already done a few things to make sure Postfix runs for us internally, but not to make it work with the Internet. Here's where Postfix shines as being simple to setup: you need to change only one thing to make it work "out of the box." It's been my experience that whatever configuration you get when you install Postfix is ready to go, but it needs only to know the name of your ISP's mail server. You see, Postfix is a mail server on your machine, and it speaks the same language as almost every other mail server out there on the Internet. Unless your ISP does really weird things, it should quite willingly accept your outgoing mail just like it came from within their own internal mail system in their office. Login as root, and navigate to
These lines are examples that you can copy, but the hashmark (#) at the front of each one prevents Postfix from reading those lines as something it needs to use. The second one is your model for most connections. Your ISP should be able to tell you the specific name of the computer that handles mail on their system. Most of them use "mail.something.com" or a similar name. Recall from the installation tutorial that this is the usual nomenclature for giving a computer an identifiable name for the Internet. At any rate, whatever your ISP tells you is what goes here. If they just give you an IP number, you can use that, too, by using the last line as your model. Just replace the letters with the digits, keeping the square brackets. For now, all IP addresses are a series of numbers divided into four sections by periods or dots. It's probably a good idea for your own sake simply to add a new line
below these four, but without the hash mark. Finally, for
dialup connections, we have to tell the mail system to hang on to
outgoing mail until there's a live connection. At the the bottom of
your
Save the file and close. If it turns out you need to authenticate with your mail server in order to send anything, such as ATT/Yahoo and most other providers now do, use the following model. Be sure to ask your provider which mail relayhost is correct. 1. Note the relayhost here in brackets. At the
bottom of your
2. Create a file called
With many providers, you'll have to make sure to use the full email
address as your authentication name. Now change permissions so others
can't read it, and run
Now, at the command line type:
It should tell you that it has reloaded and restarted. If it says
anything else, you'll need to find out why. When there is a problem,
usually you'll get something like
If that gets you a good response, then you'll need to find out why it wasn't running already. Since the process of finding out is too complicated to put in this tutorial here, I'll invite you to google for keywords in your error message (don't forget that "freebsd" is one of your search terms), ask questions on a forum, or someone you know who runs FreeBSD. In the meantime, you can always login as root and start Postfix manually on those rare occasions when you have to reboot. At this point, your system should know where to hand off any mail
you address for a recipient outside your system. But, be aware there
are other complications possible. For example, if you attempt to send
mail with a "From" address different than the
MAIL RETRIEVER: FETCHMAILI recall reading an article on the Internet where a technician wrote something like this: "Fetchmail has retrieved my mail under the worst circumstances, when nothing else could." Dialup connections can be rather fragile. If anything can get your mail, Fetchmail will do it. You can set up Fetchmail to work automatically, and for the whole system. However, that is more complicated than necessary. Since you as the user control when you are logged in, you might as well control when and how your personal mail is fetched. Rather than change settings for the whole system, you need only create a single file -- another dot file normally hidden from view -- in your home directory. First, a word about protocols. I've never dealt much with a mail system on the Internet that didn't use the standard known as POP3, aside from webmail. With webmail, you read your e-mail by logging on to the provider's machine, and you use their software from your web browser. With POP3, you are pulling that e-mail down to your machine. This allows dialup users to disconnect after you get it and read it later. Create a file named
Next, you need to tell Fetchmail to match your user account name on your personal machine with the user account name you have on the remote mail server. Hopefully, you are not in the habit of using the same or a similar nickname everywhere you go. It's a security risk, though slight. You don't have to be paranoid to realize the value of being hard to find unless you want to be found. Ordinary people like me have been harassed more than once. So you start this next line indented somewhat (about 8 spaces will do) and tell Fetchmail that user so-and-so on the distant machine is the same as you on this machine. It will look like this:
In this case, my example says that I am "joe" on the server where my mail comes in, and "jeh" on my machine at home. This way, Fetchmail will give my login name to the remote machine, and deliver to me on my machine. If your identity is something odd, such as all numerals, then you may need to put double quotation marks around it, so Fetchmail doesn't confuse it with a command. This is a standard practice in Unix software; double quotation marks tells the software: "Pass this exactly as it is." I hope your distant mail server requires a password, too. We discussed in the Install lesson how to devise your passwords, and that they should be different everywhere you have an account. If like me you have lots of accounts at places all over the Internet, there's nothing wrong with keeping a cue-card at hand. You'll have to decide for yourself how to guard that card from prying eyes physically where you keep your computer. For sites where it really doesn't matter, where no significant personal information is kept, I do use the same password for all of them. For e-mail, don't do that. Keeping the same indentation as the identity line, type in the
command
The whole file together might look like this:
If you want to grab mail from more than one source, leave one blank line, then another set of instructions like the first. When you're done, save the file. Then you must protect it by making sure no one else can read it. Fetchmail is a little paranoid on your behalf, so using your Konqueror file browser, right click on the icon for that file, select "Properties" and click the boxes under the "Permissions" tab until it matches only the "User" line with "Read" and "Write". The other two should say "Forbidden". Click "OK". You may need to enable viewing "hidden" files in Konqueror by selecting the "View" menu, then "Show Hidden Files" -- turn it on and off as you see fit. Now whenever you are connected to the Internet, you can go to a
Konsole window and type E-MAIL CLIENT: MUTTIt's quite possible to setup Kmail to do this, or just about any
other GUI mail software you want to use. However, in keeping with our
plan to be ready to run in the CLI, we'll use Mutt. I've already
mentioned that Mutt can be setup with all sorts of nice options. For
example, you can tell Mutt to display everything in colored text. Until
you are ready to read up on all the variations possible, I'll recommend
you copy these lines below into a file named
There are so many other options it is impossible to cover here. I
recommend The
Woodnotes Guide to the Mutt Email Client as a simple place to
start. From that guide, I decided to add these lines to my
You'll need to create your own
You'll also need your own
The first item assumes you have the Lynx web browser installed,
which will be explained in more detail later
( Save these files in your home directory. Also, if you like using Joe
as your standard console editor, you can use it in Mutt by adding this
line to your
Note: this won't apply until you close Konsole and restart it.
Finally, if you have a favorite signature block you want inserted at
the bottom of all your outgoing mail, create a file named
When you are finished with setting options for Mutt, give it a try by sending a test message to yourself as root. Type the command to start Mutt by indicating the "To" address:
Normally you would need the entire email address, but without a
domain following an @ symbol, Mutt assumes it's a user on the local
system. It will ask you to confirm the address by hitting
For dialup users, if you are online at that moment, Postfix should send it right away. If you are not, it will wait. On some systems, as soon as you connect to the Internet, your machine will attempt first thing to send all the mail in the queue. If this doesn't happen, you can go to the command line and type:
which tells Postfix to pass on your out-going mail. Congratulations! You are now ready to use e-mail the way it was meant to be, according to all the best standards. It is virtually impossible for anyone to send you something that will harm your machine, because this combination of software isn't likely to react to viruses, worms, etc. Ed Hurst is Associate Editor of Open for Business. Article Path: Home: Computers and Technology: Linux and BSD on the Desktop: FreeBSD: Desktop FreeBSD Part 4: Internet Mail Setup Re: Desktop FreeBSD Part 4: Internet Mail Setup before putting the line’s it will not stop if you have placed the line sendmail_enable=”NO” into /etc/rc.conf regards, Posted by Sylhouette - May 20, 2007 | 1:34:51 Re: Desktop FreeBSD Part 4: Internet Mail Setup I haven’t installed postfix yet, but I assume that you want to disable sendmail completely, if so you can replace all sendmail options in rc.conf with ‘sendmail_enable=”NONE”’. If you use sysinstall, it suggests this. See also the corresponding rc script. And you can stop sendmail after you have placed the above in rc.conf, try using ‘/etc/rc.d/sendmail onestop’. AFAIK all rc scripts that source ‘/etc/rc.subr’ have this functionality. And why do you use the scripts in ‘/usr/src/etc/rc.d/’? This could lead to unexpected behavior if you upgrade the base system from source. My recommendation is to use the scripts in ‘/etc/rc.d’. regards, Posted by tim - May 31, 2007 | 18:22:28 Re: Desktop FreeBSD Part 4: Internet Mail Setup I think best place to control software installed with ports/packages into /usr/local is ‘/usr/local/etc/rc.d’. ‘/etc/rc.d’ more suits for daemons from base system Posted by Meetrus - Jun 4, 2007 | 8:21:27 Re: Desktop FreeBSD Part 4: Internet Mail Setup Last time I looked sendmail was part of the base system. Posted by FreeDumbo - Oct 11, 2007 | 2:19:22 Re: Desktop FreeBSD Part 4: Internet Mail Setup The good information (and some comments).. Thanks.. Posted by mofff - Feb 6, 2008 | 19:26:19 does anybody know how to change on a freebsd server a interent and email connection only. I seem to have setup a new server 6.2 FBSD and even on vexim i log out people from internet they still can log in a browse. Posted by harald - Feb 10, 2008 | 3:52:23 Re: Desktop FreeBSD Part 4: Internet Mail Setup Nice article. IMHO info about setting up and tuning antispam/antivirus tools should be added with explaining of black and ehite sides of Bayes algorythm filters, black- and greylisting services. Posted by Ford - Mar 13, 2008 | 9:47:50 Please enter your comment entry below. Press 'Preview' to see how it will look. |
UPDATED: BSD on the DesktopBy Ed HurstIn an extensive multi-part report, OFB's Ed Hurst presents how the power of the FreeBSD operating system can be harnessed for the desktop. Using understandable instructions and relevant tips, Ed provides the tools for mere mortals to enjoy BSD's fabled stability. |
![]() |
Write for OFBOpen for Business accepts commentaries and other works on technology, current events, politics, philosophy, business and other relevant matters for publication. Commentaries should be 600-800 words in length, other works vary but should generally be kept to less than 1500 words. If you think you would like to contribute, contact OFB's editor, Timothy R. Butler. |
| Home |
| © 2001-2008 Universal Networks, All Rights Reserved. Some content rights may be held by Universal Networks' providers and used under license. |