Опубликован: 06.08.2012 | Доступ: свободный | Студентов: 1189 / 25 | Оценка: 5.00 / 5.00 | Длительность: 53:41:00
Лекция 27:

Electronic mail: servers

< Лекция 26 || Лекция 27: 12345 || Лекция 28 >

Downloading mail from your ISP

As we discussed before, the Internet wasn' t designed for dialup use. Most protocols assume that systems are up a large proportion of the time: down time indicates some kind of failure. This can cause problems delivering mail if you are not permanently connected to the Internet.

If you have an MX record that points to another system that is permanently connected, this doesn't seem to be a problem: the mail will be sent to that system instead. When you connect, the mail can be sent to you.

How does the mail system know when you connect? Normally it doesn't. That's the first problem. Most systems set up their MTA to try to deliver mail every 30 to 120 minutes. If you are connected that long, the chances are good that the mail will be delivered automatically, but you don't know when.

One possibility here is to tell the remote MTA when you're connected. You can do this with the SMTP ETRN command. Telnet to thesmtp port on the system where the mail is queued:

$ telnet mail.example.net smtp
Trying 139.130.237.17...
Connected to mail.example.net.
Escape character is '"]'.
220 freebie.example.org ESMTP Sendmail 8.8.7/8.8.7 ready at Mon, 5 May 1997
12:55:10 +0930 (CST)

etrn freebie.example.org
250 Queuing for node freebie.example.org started
quit
221 mail.example.net closing connection
Connection closed by foreign host.

The mail starts coming after the message Queuing for node freebie.example.org started. Depending on how much mail it is, it might take a while, but you don't need to wait for it.

Another alternative is the Post Office Protocol, or POP. POP was designed originally for Microsoft-style computers that can't run daemons, so they have to explicitly request the other end to download the data. POP is an Internet service, so you need the cooperation of the other system to run it. We'll look at POP in the next section.

POP: the Post Office Protocol

The Post Office Protocol is a means for transferring already-delivered mail to another site. It consists of two parts, the client and the server. A number of both clients and servers are available. In this discussion, we'll look at the server popper and the client fetchmail, both of which are in the Ports Collection.

popper: the server

Install popper from the Ports Collection in the usual manner:

# cd /usr/ports/mail/popper
# make install

popper is designed to be started only via inetd. To enable it, edit /etc/inetd.conf. By default, it contains the following line:

#pop3 stream tcp nowait root /usr/local/libexec/popper popper

This line is commented out with the # character. Remove that character to enable the service. Then cause inetd to re-read its configuration file:

# killall -1 inetd send a SIGHUP

To test the server, telnet to the pop3 port. You can't do much like this, but at least you can confirm that the server is answering:

$ telnet localhost pop3
Trying : :1…
telnet: connect to address : :1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '"]'.
+OK QPOP (version 2.53) at freebie.example.com starting. <11755.1028797120@freebie.
example.com>
quit
+OK Pop server at freebie.example.com signing off.
Connection closed by foreign host.

fetchmail: the client

Install fetchmail from the Ports Collection. To run it, just specify the name of the server from which you want to load the mail.

$ fetchmail hub
querying hub
Enter mailserver password: doesn’t echo
QPOP (version 2.3) at hub.freebsd.org starting. <27540.876902406@hub.freebsd.org>
5 messages in folder, 4 new messages.
reading message 1...
flushing message 2
reading message 2....
flushing message 3
reading message 3...
flushing message 4
reading message 4...
flushing message 5
reading message 5....

fetchmail and popper are relatively simple to use if you have to, but they add another level of complexity to the mail system, and they require additional work in a system that is designed to be automatic. In addition, fetchmail is not a speed demon: if you have a lot of mail to transfer, be prepared to wait much longer than an SMTP MTA would take.

Mailing lists: majordomo

majordomo is a mail list manager. If you run mailing lists, you probably want to use majordomo: it saves you manually modifying the mailing lists. As usual, you can find majordomo in the Ports Collection, in the directory /usr/ports/mail/majordomo. When installing, you'll notice a message:

To finish the installation, ’su’ to root and type:
           make install-wrapper
If not installing the wrapper, type
           cd /usr/local/majordomo; ./wrapper config-test
(no ’su’ necessary) to verify the installation.
./install.sh -o root -g 54 -m 4755 wrapper /usr/local/majordomo/wrapper

With the exception of the last line, this comes from the original majordomo installation procedure. The last line is the port performing the make install-wrapper for you. You don't need to do anything else, and you can ignore the messages.

After installation, you still need to perform some configuration:

  • Customize /usr/local/majordomo/majordomo.cf. This should be easy enough to read, and you may not need to change anything. Once you have it up and running, you might like to consider changing the default_subscribe_policy.
  • Define your lists in /usr/local/majordomo/aliases.majordomo. This file contains a single list, test -l, which you should remove once you have things up and running.
  • Ensure that there is a mail user majordomo-owner on the system. The best way to handle this is to add an entry in /etc/mail/aliases (see page 496):
    majordomo-owner: root
    

    Since root should be an alias for your mail ID, this will mean that you get the mail for

    majordomo-owner as well. Don't run postmap or newaliases yet.

  • Add /usr/local/majordomo/aliases.majordomo to the list Postfix aliases. We looked at this point above; you need at least the bold text part of the following line in /usr/local/etc/postfix/main.cf:
    alias_maps=hash:/etc/mail/aliases,hash:/usr/local/majordomo/aliases.majordomo
    
  • Run postmap.
  • Restart Postfix:
    # postfix reload
    
  • This isn't absolutely necessary, but it will take Postfix a few minutes to notice otherwise.

That's all you need to do. You don't need to start any processes to run majordomo: it gets started automatically when a mail message is received.

< Лекция 26 || Лекция 27: 12345 || Лекция 28 >