个人工具

“UbuntuHelp:DialupEmailHowto”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(新页面: {{From|https://help.ubuntu.com/community/DialupEmailHowto}} {{Languages|UbuntuHelp:DialupEmailHowto}} == How To Set Up Email on a Dialup Connection == This sets up local handling of mai...)
 
 
(未显示同一用户的7个中间版本)
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/DialupEmailHowto}}
 
{{From|https://help.ubuntu.com/community/DialupEmailHowto}}
 
{{Languages|UbuntuHelp:DialupEmailHowto}}
 
{{Languages|UbuntuHelp:DialupEmailHowto}}
 
+
<<Include(Tag/Unsupported)>>
 
== How To Set Up Email on a Dialup Connection ==
 
== 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 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.
 
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.)
 
(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 ===
 
=== Contents ===
 
 
* 0) Before you start -- Information you need
 
* 0) Before you start -- Information you need
 
* 1) Set up modem (ppp and modemlights)
 
* 1) Set up modem (ppp and modemlights)
第18行: 第13行:
 
* 4) Set the system clock when online (ntpdate)
 
* 4) Set the system clock when online (ntpdate)
 
* 5) Configure email client (Evolution)
 
* 5) Configure email client (Evolution)
 
 
* Finishing touches
 
* Finishing touches
 
* Smooth fonts in Warty
 
* Smooth fonts in Warty
 
* Postfix documentation
 
* Postfix documentation
 
* Comments
 
* Comments
 
 
=== 0) Before you start -- Information you need ===
 
=== 0) Before you start -- Information you need ===
 
 
* The phone number & other modem settings for your Internet Server Provider (ISP)  
 
* 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 ISP
第31行: 第23行:
 
* Your email provider's SMTP server name
 
* Your email provider's SMTP server name
 
* Your email provider's POP or IMAP 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...
 
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) ===
 
=== 1) Set up modem (ppp and modemlights) ===
 
 
see [DialupModemHowto]
 
see [DialupModemHowto]
 
 
Test to make sure the system seems to connect properly -- open a web page while connected, etc.
 
Test to make sure the system seems to connect properly -- open a web page while connected, etc.
 
 
=== 2) Set up incoming mail (fetchmail) ===
 
=== 2) Set up incoming mail (fetchmail) ===
 
 
Fetchmail is already installed in Warty, but
 
Fetchmail is already installed in Warty, but
 
 
* some scripts need modification to respect the ppp connection, *and*
 
* some scripts need modification to respect the ppp connection, *and*
 
* there is no configuration file, so fetchmail will not start.
 
* there is no configuration file, so fetchmail will not start.
 
+
Modify the script that runs when the modem connects which is located at /etc/ppp/ip-up.d/fetchmail
Modify the script that runs when the modem connects:
+
Change the '''try-restart''' command to '''start''', so that one line now says:
 
+
 
<pre><nowiki>
 
<pre><nowiki>
# sudo nano /etc/ppp/ip-up.d/fetchmail
+
    /etc/init.d/fetchmail start
 
</nowiki></pre>
 
</nowiki></pre>
 
+
Also modify the script that runs when the modem disconnects which is located at /etc/ppp/ip-down.d/fetchmail
Change the *try-restart* command to *start*, so that one line now says:
+
Comment out the '''exit 0''' line in this fetchmail script so it now says:
 
+
 
<pre><nowiki>
 
<pre><nowiki>
/etc/init.d/fetchmail start
+
    #exit 0
 
</nowiki></pre>
 
</nowiki></pre>
 
+
Create a fetchmail config file in /etc/fetchmailrc . (Pay special attention to the placement of commas, semicolons and colons)
Also modify the script that runs when the modem disconnects:
+
 
+
 
<pre><nowiki>
 
<pre><nowiki>
# sudo nano /etc/ppp/ip-down.d/fetchmail
+
    #!/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;
 
</nowiki></pre>
 
</nowiki></pre>
 
Comment out the *exit 0* line in this fetchmail script so it now says:
 
 
<pre><nowiki>
 
#exit 0
 
</nowiki></pre>
 
 
Create a fetchmail config file. (Pay special attention to the placement of commas, semicolons and colons.)
 
 
<pre><nowiki>
 
# sudo nano /etc/fetchmailrc
 
</nowiki></pre>
 
 
<pre><nowiki>
 
#!/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;
 
</nowiki></pre>
 
 
 
Comments regarding the script above:
 
Comments regarding the script above:
 
 
* Remember to replace *mail.messagingengine.com* with your email server name.
 
* Remember to replace *mail.messagingengine.com* with your email server name.
 
* This script uses *imap* but *pop3* also works with this provider.
 
* This script uses *imap* but *pop3* also works with this provider.
第105行: 第68行:
 
* The *stripcr* command is commented out because I don't think I need it.  
 
* 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.)
 
* 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 --
 
Fetchmail insists on secure permissions for the fetchmail configuration file, so set them securely --
 
 
<pre><nowiki>
 
<pre><nowiki>
# sudo chmod 0600 /etc/fetchmailrc
+
    # sudo chmod 0600 /etc/fetchmailrc
 
</nowiki></pre>
 
</nowiki></pre>
 
 
=== 3) Set Up outgoing mail (postfix) ===
 
=== 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).
 
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).
 
 
<pre><nowiki>
 
<pre><nowiki>
# sudo dpkg-reconfigure postfix
+
    # sudo dpkg-reconfigure postfix
 
</nowiki></pre>
 
</nowiki></pre>
 
 
(Many of the following responses are the system defaults)
 
(Many of the following responses are the system defaults)
 
* Choose: satellite system  
 
* Choose: satellite system  
第130行: 第87行:
 
* Mailbox size limit: 0
 
* Mailbox size limit: 0
 
* Local address extension character: +
 
* Local address extension character: +
 
+
Edit the postfix config which is located at /etc/postfix/main.cf
Edit the postfix config:
+
Scroll down to the end of the file and add the following lines:
 
+
 
<pre><nowiki>
 
<pre><nowiki>
# sudo nano /etc/postfix/main.cf
+
    # lines below added by >you< on >date<
</nowiki></pre>
+
    # See http://www.michael-prokop.at/postfix/
  
Scroll down to the end of the file and add the following lines:
+
    #Most ISPs block port 25 these days; most ISPs offer port 587 as an alternate.  (Some support ports other than the MSP port, such as 26, 2525, etc.)
 +
    # Also, the square brackets are supposed to be there-do NOT leave them out.
 +
    relayhost = [mail.messagingengine.com]:587
  
<pre><nowiki>
+
    # TLS authentication
# lines below added by twt 12/16/2004
+
    smtp_use_tls = yes
 +
    smtp_sasl_auth_enable = yes
 +
    smtp_sasl_password_maps = hash:/etc/postfix/smtp_auth
 +
    smtp_sasl_security_options = noanonymous
  
# TLS authentication
+
    # Settings for dialup
smtp_use_tls = yes
+
    defer_transports = smtp
smtp_sasl_auth_enable = yes
+
    disable_dns_lookups = yes
smtp_sasl_password_maps = hash:/etc/postfix/smtp_auth
+
smtp_sasl_security_options = noanonymous
+
  
# Settings for dialup
+
    # Address envelopes to avoid bounces
defer_transports = smtp
+
    masquerade_domains = /etc/mailname
disable_dns_lookups = yes
+
 
+
# Address envelopes to avoid bounces
+
masquerade_domains = /etc/mailname
+
 
</nowiki></pre>
 
</nowiki></pre>
 
 
(Lines beginning with "#" are comments.)  
 
(Lines beginning with "#" are comments.)  
 
+
Add authentication information to config file located here /etc/postfix/smtp_auth
Add authentication information to config file (one line only):
+
(one line only)
 
+
 
<pre><nowiki>
 
<pre><nowiki>
# sudo nano /etc/postfix/smtp_auth
+
    mail.messagingengine.com my_email_address:my_secret_password
 
</nowiki></pre>
 
</nowiki></pre>
 
+
Put return address host into mailname file located at /etc/mailname
 
<pre><nowiki>
 
<pre><nowiki>
mail.messagingengine.com my_email_address:my_secret_password
+
    fastmail.fm
 
</nowiki></pre>
 
</nowiki></pre>
 
Put return address host into mailname file
 
 
<pre><nowiki>
 
# sudo nano /etc/mailname
 
</nowiki></pre>
 
 
<pre><nowiki>
 
fastmail.fm
 
</nowiki></pre>
 
 
 
Change the line to the part of your email address *after* the @ sign.
 
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; it converts the contents of /etc/postfix/smtp_auth into /etc/postfix/smtp_auth.db, a format postfix expects.)
Now, add the updated info to postfix database & restart postfix. (Run this procedure any time you must make changes to the smtp_auth settings.)
+
 
+
 
<pre><nowiki>
 
<pre><nowiki>
# sudo postmap /etc/postfix/smtp_auth
+
    # sudo postmap /etc/postfix/smtp_auth
# sudo /etc/init.d/postfix restart
+
    # sudo /etc/init.d/postfix restart
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Test your postfix setup from the command line by sending a message to yourself:
 
Test your postfix setup from the command line by sending a message to yourself:
 
 
<pre><nowiki>
 
<pre><nowiki>
# echo "postfix works" | mail somebody_i_know@fastmail.fm
+
    # echo "postfix works" | mail somebody_i_know@fastmail.fm
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Problems? Look in the outgoing mail queue:
 
Problems? Look in the outgoing mail queue:
 
 
<pre><nowiki>
 
<pre><nowiki>
# mailq
+
    # mailq
 
</nowiki></pre>
 
</nowiki></pre>
 
 
(The message should be gone already if you're online.)  
 
(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 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:
 
If you see undeliverable junk in the deferred email queue:
 
 
<pre><nowiki>
 
<pre><nowiki>
# sudo postsuper -d ALL deferred
+
    # sudo postsuper -d ALL deferred
 
</nowiki></pre>
 
</nowiki></pre>
 
 
This command removes the messages from the "deferred" queue so the system won't keep trying to deliver them.
 
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.
 
There are many other postfix commands; see the links in the `Postfix Documentation`_ section.
 
 
=== 4) Set the system clock when online (ntpdate) ===
 
=== 4) Set the system clock when online (ntpdate) ===
 
 
Create a script that calls ntpdate when the modem connects:
 
Create a script that calls ntpdate when the modem connects:
 
 
<pre><nowiki>
 
<pre><nowiki>
# sudo nano /etc/ppp/ip-up.d/2ntpdate
+
    # sudo nano /etc/ppp/ip-up.d/2ntpdate
 
</nowiki></pre>
 
</nowiki></pre>
 
 
<pre><nowiki>
 
<pre><nowiki>
#!/bin/sh
+
    #!/bin/sh
# update time when online
+
    # update time when online
/etc/init.d/ntpdate restart
+
    /etc/init.d/ntpdate restart
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Set permissions on the script you just wrote
 
Set permissions on the script you just wrote
 
 
<pre><nowiki>
 
<pre><nowiki>
# sudo chmod 755 /etc/ppp/ip-up.d/2ntpdate
+
    # sudo chmod 755 /etc/ppp/ip-up.d/2ntpdate
 
</nowiki></pre>
 
</nowiki></pre>
 
 
=== 5) Configure Email Client (Evolution) ===
 
=== 5) Configure Email Client (Evolution) ===
 
 
Launch Evolution and set it to look for mail in all the right places.
 
Launch Evolution and set it to look for mail in all the right places.
 
 
Tools -- > Settings...
 
Tools -- > Settings...
 
 
Click the "Add" button to create a new account
 
Click the "Add" button to create a new account
 
 
* Receiving Mail: Local Delivery
 
* Receiving Mail: Local Delivery
 
* Receiving Options: check for new mail every minute or two
 
* Receiving Options: check for new mail every minute or two
 
* Sending Mail: Server Type: sendmail
 
* Sending Mail: Server Type: sendmail
 
 
=== Finishing touches ===
 
=== Finishing touches ===
 
<pre><nowiki>
 
this is a section crying out for more wiki links
 
</nowiki></pre>
 
 
 
Here are some extras to ensure things operate smoothly and easily...
 
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).
 
* Make sure the machine starts and stops without strangeness (it should power down properly, for example).
 
* Set GDM to log in automatically if desired  
 
* Set GDM to log in automatically if desired  
第258行: 第170行:
 
* Make fonts smooth using Smooth fonts in Warty
 
* Make fonts smooth using Smooth fonts in Warty
 
* Make GRUB menu usable for another OS if desired
 
* Make GRUB menu usable for another OS if desired
 
 
=== Smooth fonts in Warty ===
 
=== 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>.
 
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>.
 
 
<pre><nowiki>
 
<pre><nowiki>
nano ~/.fonts.conf
+
    nano ~/.fonts.conf
 
</nowiki></pre>
 
</nowiki></pre>
 
 
<pre><nowiki>
 
<pre><nowiki>
<?xml version="1.0"?>
+
    <?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
+
    <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
+
    <fontconfig>
<match target="font">
+
      <match target="font">
<edit name="autohint" mode="assign">
+
        <edit name="autohint" mode="assign">
<bool>true</bool>
+
          <bool>true</bool>
</edit>
+
        </edit>
</match>
+
      </match>
</fontconfig>
+
    </fontconfig>
 
</nowiki></pre>
 
</nowiki></pre>
 
 
=== Postfix documentation ===
 
=== 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.  
 
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:
 
Here are links to the documentation I have found most helpful:
 
 
* Postfix @ michael-prokop.at [http://www.michael-prokop.at/postfix/ Set up postfix using TLS on a Debian box]
 
* Postfix @ michael-prokop.at [http://www.michael-prokop.at/postfix/ Set up postfix using TLS on a Debian box]
 
* [http://www.postfix.org/STANDARD_CONFIGURATION_README.html Postfix Standard Configuration]
 
* [http://www.postfix.org/STANDARD_CONFIGURATION_README.html Postfix Standard Configuration]
 
* [http://www.postfix.org/faq.html Postfix FAQ]
 
* [http://www.postfix.org/faq.html Postfix FAQ]
** (See the sections [http://www.postfix.org/faq.html#dialup Running Postfix on a Dialup machine] and [http://www.postfix.org/faq.html#root Root's mail is delivered to nobody])
+
* (See the sections [http://www.postfix.org/faq.html#dialup Running Postfix on a Dialup machine] and [http://www.postfix.org/faq.html#root Root's mail is delivered to nobody])
 
* [http://www.redhat.com/support/resources/faqs/RH-postfix-FAQ/book1.html Red Hat Postfix FAQ] (see section 3.14 [http://www.redhat.com/support/resources/faqs/RH-postfix-FAQ/x112.html How can I use Postfix from my dial-up machine at home?])
 
* [http://www.redhat.com/support/resources/faqs/RH-postfix-FAQ/book1.html Red Hat Postfix FAQ] (see section 3.14 [http://www.redhat.com/support/resources/faqs/RH-postfix-FAQ/x112.html How can I use Postfix from my dial-up machine at home?])
 
* [http://www.redhat.com/support/resources/howto/RH-postfix-HOWTO/book1.html Red Hat Postfix HOWTO (See Section 9 [http://www.redhat.com/support/resources/howto/RH-postfix-HOWTO/c241.html Beyond Default])
 
* [http://www.redhat.com/support/resources/howto/RH-postfix-HOWTO/book1.html Red Hat Postfix HOWTO (See Section 9 [http://www.redhat.com/support/resources/howto/RH-postfix-HOWTO/c241.html Beyond Default])
 
 
=== Comments ===
 
=== Comments ===
 
+
[[UbuntuHelp:TommyTrussell|TommyTrussell]] commented on Wed Dec 15 16:58:11 +0000 2004
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
 
Subject: Entire original /etc/postfix/main.cf
 
Message-ID: <20041215165811+0000@https://www.ubuntulinux.org>
 
Message-ID: <20041215165811+0000@https://www.ubuntulinux.org>
 
+
that he would post his entire /etc/postfix/main.cf file after editing it as described in the original instructions (from November 30, 2004).  
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."
+
What is now below is an edited version of his second version; the edit should work/resolve the issue he had, and serve as a better example. (See the wiki history if you're interested in the previous versions.)
 
+
Revised 12/16/2004 by [[UbuntuHelp:TommyTrussell|TommyTrussell]] and Aug 2007 by MrElvey
 
<pre><nowiki>
 
<pre><nowiki>
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
+
    # 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
  
# 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.
+
    # See http://www.michael-prokop.at/postfix/
append_dot_mydomain = no
+
  
# Uncomment the next line to generate "delayed mail" warnings
+
    #Most ISPs block port 25 these days; most ISPs offer port 587 as an alternate.  (Some support ports other than the MSP port, such as 26, 2525, etc.)
#delay_warning_time = 4h
+
    # Also, the square brackets are supposed to be there-do NOT leave them out.
 +
    relayhost = [mail.messagingengine.com]:587
 +
   
 +
    mynetworks = 127.0.0.0/8
 +
    mailbox_command =
 +
    mailbox_size_limit = 0
 +
    recipient_delimiter = +
  
# Uncomment the next line to use procmail for delivery
+
    # lines below added by twt 12/16/2004
#mailbox_command = procmail -a "$EXTENSION"
+
  
myhostname = localhost.localdomain
+
    # TLS authentication
alias_maps = hash:/etc/aliases
+
    smtp_use_tls = yes
alias_database = hash:/etc/aliases
+
    smtp_sasl_auth_enable = yes
myorigin = /etc/mailname
+
    smtp_sasl_password_maps = hash:/etc/postfix/smtp_auth
mydestination = localhost.localdomain, localhost
+
    smtp_sasl_security_options = noanonymous
relayhost = mail.messagingengine.com
+
  
smtp_use_tls = yes
+
    # Settings for dialup
smtp_sasl_auth_enable = yes
+
    defer_transports = smtp
smtp_sasl_password_maps = hash:/etc/postfix/smtp_auth
+
    disable_dns_lookups = yes
smtp_sasl_security_options = noanonymous
+
  
mynetworks = 127.0.0.0/8
+
    # Address envelopes to avoid bounces
mailbox_command =
+
    masquerade_domains = /etc/mailname
mailbox_size_limit = 0
+
recipient_delimiter = +
+
 
</nowiki></pre>
 
</nowiki></pre>
 
+
From [[UbuntuHelp:TommyTrussell|TommyTrussell]] never could get this configuration to work reliably... but with the square brackets now above; perhaps he would...
==== update 12/16/2004 ====
+
Take care to not copy/paste the spaces in front of each line, as those seem to mean to Postfix "merge this with the previous line" (just like in good ole RFC822, imagine that). Other than that, the Postfix part works nicely even for me on Gutsy. Thanks!  -- Era
 
+
----
This is the entire /etc/postfix/main.cf file with the 12/16/2004 updates (correct problems)
+
[[category:CategoryEmail]]
 
+
<pre><nowiki>
+
# 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
+
</nowiki></pre>
+
 
+
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.
+
 
+
[[category:CategoryDocumentation]] [[category:CategoryCleanup]]
+
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2008年10月19日 (日) 14:48的最新版本

<<Include(Tag/Unsupported)>>

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 which is located at /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 which is located at /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 in /etc/fetchmailrc . (Pay special attention to the placement of commas, semicolons and colons)

     #!/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 which is located at /etc/postfix/main.cf Scroll down to the end of the file and add the following lines:

     # lines below added by >you< on >date<
     # See http://www.michael-prokop.at/postfix/

     #Most ISPs block port 25 these days; most ISPs offer port 587 as an alternate.  (Some support ports other than the MSP port, such as 26, 2525, etc.)
     # Also, the square brackets are supposed to be there-do NOT leave them out.
     relayhost = [mail.messagingengine.com]:587

     # 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 located here /etc/postfix/smtp_auth (one line only)

     mail.messagingengine.com my_email_address:my_secret_password

Put return address host into mailname file located at /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; it converts the contents of /etc/postfix/smtp_auth into /etc/postfix/smtp_auth.db, a format postfix expects.)

     # 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

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:

Comments

TommyTrussell commented on Wed Dec 15 16:58:11 +0000 2004 Subject: Entire original /etc/postfix/main.cf Message-ID: <20041215165811+0000@https://www.ubuntulinux.org> that he would post his entire /etc/postfix/main.cf file after editing it as described in the original instructions (from November 30, 2004). What is now below is an edited version of his second version; the edit should work/resolve the issue he had, and serve as a better example. (See the wiki history if you're interested in the previous versions.) Revised 12/16/2004 by TommyTrussell and Aug 2007 by MrElvey

     # 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



     # See http://www.michael-prokop.at/postfix/

     #Most ISPs block port 25 these days; most ISPs offer port 587 as an alternate.  (Some support ports other than the MSP port, such as 26, 2525, etc.)
     # Also, the square brackets are supposed to be there-do NOT leave them out.
     relayhost = [mail.messagingengine.com]:587
     
     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 never could get this configuration to work reliably... but with the square brackets now above; perhaps he would... Take care to not copy/paste the spaces in front of each line, as those seem to mean to Postfix "merge this with the previous line" (just like in good ole RFC822, imagine that). Other than that, the Postfix part works nicely even for me on Gutsy. Thanks! -- Era