UbuntuHelp:DialupEmailHowto
来自Ubuntu中文
点击翻译: |
English |
请不要直接编辑翻译本页,本页将定期与来源同步。 |
目录
- 1 How To Set Up Email on a Dialup Connection
- 1.1 Contents
- 1.2 0) Before you start -- Information you need
- 1.3 1) Set up modem (ppp and modemlights)
- 1.4 2) Set up incoming mail (fetchmail)
- 1.5 3) Set Up outgoing mail (postfix)
- 1.6 4) Set the system clock when online (ntpdate)
- 1.7 5) Configure Email Client (Evolution)
- 1.8 Finishing touches
- 1.9 Smooth fonts in Warty
- 1.10 Postfix documentation
- 1.11 Comments
How To Set Up Email on a Dialup Connection
This sets up local handling of mail so a dialup user can read and queue mail while on or off line.
This information assumes a standard Ubuntu "warty" setup.
(Here's the scenario -- I set up Ubuntu on a PC for my Mother-in-law, but she has only one phone line and no broadband. I didn't want to have to explain the error messages she would see if she attemtped to read or compose email when the machine is not online. All the "hooks" exist to automatically retrieve and deliver the email over a ppp connection, but they must be set up.)
Contents
- 0) Before you start -- Information you need
- 1) Set up modem (ppp and modemlights)
- 2) Set up incoming mail (fetchmail)
- 3) Set up outgoing mail (postfix)
- 4) Set the system clock when online (ntpdate)
- 5) Configure email client (Evolution)
- Finishing touches
- Smooth fonts in Warty
- Postfix documentation
- Comments
0) Before you start -- Information you need
- The phone number & other modem settings for your Internet Server Provider (ISP)
- Your username and password at your ISP
- Your username and password at your email provider (if different)
- Your email provider's SMTP server name
- Your email provider's POP or IMAP server name
In the examples here, the email provider is fastmail.fm, whose smtp server is smtp.messagingengine.com and whose pop/imap server is mail.messagingengine.com. Fastmail is an actual email ISP whose SMTP and IMAP servers are available to fee-paying subscribers. Please substitute these examples with your own information...
1) Set up modem (ppp and modemlights)
see [DialupModemHowto]
Test to make sure the system seems to connect properly -- open a web page while connected, etc.
2) Set up incoming mail (fetchmail)
Fetchmail is already installed in Warty, but
- some scripts need modification to respect the ppp connection, *and*
- there is no configuration file, so fetchmail will not start.
Modify the script that runs when the modem connects:
# sudo nano /etc/ppp/ip-up.d/fetchmail
Change the *try-restart* command to *start*, so that one line now says:
/etc/init.d/fetchmail start
Also modify the script that runs when the modem disconnects:
# sudo nano /etc/ppp/ip-down.d/fetchmail
Comment out the *exit 0* line in this fetchmail script so it now says:
#exit 0
Create a fetchmail config file. (Pay special attention to the placement of commas, semicolons and colons.)
# sudo nano /etc/fetchmailrc
#!/etc/fetchmailrc # # global options # set logging to syslog set syslog # set to run as daemon with poll interval (seconds) set daemon 240 # poll mail.messagingengine.com: # server options with nodns, with protocol imap, # user options user remote_account_name there, is, local_account_name here, # with stripcr, # with keep, with password my_secret;
Comments regarding the script above:
- Remember to replace *mail.messagingengine.com* with your email server name.
- This script uses *imap* but *pop3* also works with this provider.
- Substitute your email account name (to the left of the @ sign) for *remote_account_name*.
- Substitute your ubuntu login name for *local_account_name*.
- The *stripcr* command is commented out because I don't think I need it.
- To leave the messages on the mail server, uncomment the *with keep* line. (Fetchmail will only retrieve a message once, but with the *keep* command the original will stay on the server after it's retrieved.)
Fetchmail insists on secure permissions for the fetchmail configuration file, so set them securely --
# sudo chmod 0600 /etc/fetchmailrc
3) Set Up outgoing mail (postfix)
The postfix mail server comes installed on Warty, but by default it only delivers system warnings and other messages to the first user on the system. This procedure assumes your ISP requires TLS authentication (which verifies your identity to show you're not a spammer trying to take over their SMTP server).
# sudo dpkg-reconfigure postfix
(Many of the following responses are the system defaults)
- Choose: satellite system
- Mail name: localhost.localdomain
- SMTP Relay host: smtp.messagingengine.com
- Other destinations to accept mail for: localhost.localdomain, localhost
- Force synchronous updates on mail queue: Yes
- Local networks: 127.0.0.0/8
- Use procmail for local delivery: No
- Mailbox size limit: 0
- Local address extension character: +
Edit the postfix config:
# sudo nano /etc/postfix/main.cf
Scroll down to the end of the file and add the following lines:
# lines below added by twt 12/16/2004 # TLS authentication smtp_use_tls = yes smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/smtp_auth smtp_sasl_security_options = noanonymous # Settings for dialup defer_transports = smtp disable_dns_lookups = yes # Address envelopes to avoid bounces masquerade_domains = /etc/mailname
(Lines beginning with "#" are comments.)
Add authentication information to config file (one line only):
# sudo nano /etc/postfix/smtp_auth
mail.messagingengine.com my_email_address:my_secret_password
Put return address host into mailname file
# sudo nano /etc/mailname
fastmail.fm
Change the line to the part of your email address *after* the @ sign.
Now, add the updated info to postfix database & restart postfix. (Run this procedure any time you must make changes to the smtp_auth settings.)
# sudo postmap /etc/postfix/smtp_auth # sudo /etc/init.d/postfix restart
Test your postfix setup from the command line by sending a message to yourself:
# echo "postfix works" | mail somebody_i_know@fastmail.fm
Problems? Look in the outgoing mail queue:
# mailq
(The message should be gone already if you're online.)
If you find a problem, and need to edit the files in /etc/postfix, run the postmap command and restart postfix like described above.
If you see undeliverable junk in the deferred email queue:
# sudo postsuper -d ALL deferred
This command removes the messages from the "deferred" queue so the system won't keep trying to deliver them.
There are many other postfix commands; see the links in the `Postfix Documentation`_ section.
4) Set the system clock when online (ntpdate)
Create a script that calls ntpdate when the modem connects:
# sudo nano /etc/ppp/ip-up.d/2ntpdate
#!/bin/sh # update time when online /etc/init.d/ntpdate restart
Set permissions on the script you just wrote
# sudo chmod 755 /etc/ppp/ip-up.d/2ntpdate
5) Configure Email Client (Evolution)
Launch Evolution and set it to look for mail in all the right places.
Tools -- > Settings...
Click the "Add" button to create a new account
- Receiving Mail: Local Delivery
- Receiving Options: check for new mail every minute or two
- Sending Mail: Server Type: sendmail
Finishing touches
this is a section crying out for more wiki links
Here are some extras to ensure things operate smoothly and easily...
- Make sure the machine starts and stops without strangeness (it should power down properly, for example).
- Set GDM to log in automatically if desired
- Adjust Gnome screen resolution, colors and font sizes for user's eyes as necessary
- Make fonts smooth using Smooth fonts in Warty
- Make GRUB menu usable for another OS if desired
Smooth fonts in Warty
Create the ./fonts.conf file in the home directory to make the fonts look smooth on the screen. If you already have this file, add the parts from <match target="font"> to </match>.
nano ~/.fonts.conf
<?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <match target="font"> <edit name="autohint" mode="assign"> <bool>true</bool> </edit> </match> </fontconfig>
Postfix documentation
There's lots of information for using postfix on a dialup connection at Red Hat, though it turns out the Postfix site has lots of information, too. The Debian default package settings are configured a bit differently from Red Hat's, making their advice potentially confusing.
Here are links to the documentation I have found most helpful:
- Postfix @ michael-prokop.at Set up postfix using TLS on a Debian box
- Postfix Standard Configuration
- Postfix FAQ
- (See the sections Running Postfix on a Dialup machine and Root's mail is delivered to nobody)
- Red Hat Postfix FAQ (see section 3.14 How can I use Postfix from my dial-up machine at home?)
- Red Hat Postfix HOWTO (See Section 9 [http://www.redhat.com/support/resources/howto/RH-postfix-HOWTO/c241.html Beyond Default)
Comments
From TommyTrussell Wed Dec 15 16:58:11 +0000 2004 From: Tommy Trussell Date: Wed, 15 Dec 2004 16:58:11 +0000 Subject: Entire original /etc/postfix/main.cf Message-ID: <20041215165811+0000@https://www.ubuntulinux.org>
This is the entire /etc/postfix/main.cf file after editing it as described in the original instructions (from November 30, 2004). There is a problem here -- it works on an Ethernet LAN but on dialup, the mail does not make it out of the queue -- the queue status says there's "no route to host."
# See /usr/share/postfix/main.cf.dist for a commented, more complete version # For better performance, chattr -S -R /var/spool/postfix, and use a # journaled filesystem to achieve the same results as chattr +S gives. smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) biff = no # appending .domain is the MUA's job. append_dot_mydomain = no # Uncomment the next line to generate "delayed mail" warnings #delay_warning_time = 4h # Uncomment the next line to use procmail for delivery #mailbox_command = procmail -a "$EXTENSION" myhostname = localhost.localdomain alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = localhost.localdomain, localhost relayhost = mail.messagingengine.com smtp_use_tls = yes smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/smtp_auth smtp_sasl_security_options = noanonymous mynetworks = 127.0.0.0/8 mailbox_command = mailbox_size_limit = 0 recipient_delimiter = +
update 12/16/2004
This is the entire /etc/postfix/main.cf file with the 12/16/2004 updates (correct problems)
# See /usr/share/postfix/main.cf.dist for a commented, more complete version # For better performance, chattr -S -R /var/spool/postfix, and use a # journaled filesystem to achieve the same results as chattr +S gives. smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) biff = no # appending .domain is the MUA's job. append_dot_mydomain = no # Uncomment the next line to generate "delayed mail" warnings #delay_warning_time = 4h # Uncomment the next line to use procmail for delivery #mailbox_command = procmail -a "$EXTENSION" myhostname = localhost.localdomain alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = localhost.localdomain, localhost relayhost = mail.messagingengine.com mynetworks = 127.0.0.0/8 mailbox_command = mailbox_size_limit = 0 recipient_delimiter = + # lines below added by twt 12/16/2004 # TLS authentication smtp_use_tls = yes smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/smtp_auth smtp_sasl_security_options = noanonymous # Settings for dialup defer_transports = smtp disable_dns_lookups = yes # Address envelopes to avoid bounces masquerade_domains = /etc/mailname
From TommyTrussell Mon Dec 20 18:22:12 +0000 2004 From: Tommy Trussell Date: Mon, 20 Dec 2004 18:22:12 +0000 Subject: Update 12/20/04 Message-ID: <20041220182212+0000@https://www.ubuntulinux.org>
I never could get this configuration to work reliably. I finally got postfix going (with completely revised settings) but now fetchmail complains it can't find the mail server's canonical name. Fetchmail starts working if you tinker with its settings after startup, but that's not good.