[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: exim headaches



Ok, here's what I did (don't worry, it's not as bad as it probably
looks :-).

First, create the file /etc/email.map, which will specify the email
mapping for outgoing messages.  Each line should be of the format
"local_user: Justin Kase <jkase@myisp.net>".  Mine looks like:

     root:   Greg Norris <haphazard@socket.net>
     adric:  Greg Norris <haphazard@socket.net>

Second, create a minimal exim configfile and save it as
/etc/exim-external.conf.  I just copied my original file (created by
eximconfig) and stripped out the unnecessary bits.  To save you some
time, I've attached my version... you should only need to change the
mailserver (currently "mail.socket.net") and the host/domainname in the
rewriting rules at the end (last 15 lines or so).

Third, in your existing /etc/exim.conf file add (or modify) the
following in the TRANSPORTS CONFIGURATION section:

     # Transport to send SMTP using port 26
     internal_smtp:
       driver = smtp
       service = 26

Fourth, in your existing /etc/exim.conf file add (or modify) the
following in the ROUTERS CONFIGURATION section (according to the exim
FAQ, this should be the only router):

     # Router to send everything from the internal_smtp transport
     pass_remotes:
       driver = domainlist
       transport = internal_smtp
       route_list = * localhost byname
       self = send

The two steps above cause non-local email to be forwarded to port 26,
which is where the secondary copy of exim will reside.

Fifth, you probably want to comment out the rewriting rules in your
existing /etc/exim.conf file.

Sixth, create the directory /var/spool/exim-external, with the same
ownership and permissions as /var/spool/exim.

Seventh, add the following entry to the end of /etc/services:

     smtp-local      26/tcp          mail-local

Eighth, add the following entry to /etc/inetd.conf (I've broken it for
readability, but it should all be on a single line):

     smtp-local      stream  tcp     nowait  mail \
        /usr/sbin/exim exim -C /etc/exim-external.conf -bs -oX 26

This causes the secondary copy of exim to be invoked whenever there's
a connection to port 26.

Nineth, add the following to /etc/cron.d/exim (again, broken for
readability):

     08,38 *     * * *     mail   \
        if [ -x /usr/sbin/exim -a -f /etc/exim-external.conf ]; then \
        /usr/sbin/exim -C /etc/exim-external.conf -q >/dev/null 2>&1; fi

If you connect to the net by modem (I'm using DSL), you may want to add
that to etc/ppp/ip-up.d/exim instead.  This ensures that outgoing email
will eventually get delivered, in case your ISP's mailserver is
inaccessible during the original attempt.

Tenth, test your rewriting rules by running:

     exim -brw user@somewhere
     exim -C /etc/exim-external.conf -brw user@somewhere

Tweak the rules until you're happy with the results.

Finally, run "killall -HUP inetd" to force inetd to reread it's
configfile.  At this point, you should be set.

Good luck!
# This is the main exim configuration file.
# It was originally generated by `eximconfig', part of the exim package
# distributed with Debian, but it may edited by the mail system administrator.
# This file originally generated by eximconfig at Sun Nov  1 13:03:03 CST 1998
# See exim info section for details of the things that can be configured here.

# Please see the manual for a complete list
# of all the runtime configuration options that can be included in a
# configuration file.

# This file is divided into several parts, all but the last of which are
# terminated by a line containing the word "end". The parts must appear
# in the correct order, and all must be present (even if some of them are
# in fact empty). Blank lines, and lines starting with # are ignored.

######################################################################
#                    MAIN CONFIGURATION SETTINGS                     #
######################################################################

local_domains =
local_interfaces = 127.0.0.1
host_accept_relay = 127.0.0.1 : ! *
host_reject = ! localhost : *
spool_directory = /var/spool/exim-external

# No local deliveries will ever be run under the uids of these users (a colon-
# separated list). An attempt to do so gets changed so that it runs under the
# uid of "nobody" instead. This is a paranoic safety catch. Note the default
# setting means you cannot deliver mail addressed to root as if it were a
# normal user. This isn't usually a problem, as most sites have an alias for
# root that redirects such mail to a human administrator.

never_users = root

# If this option is set, then any process that is running as one of the
# listed users may pass a message to Exim and specify the sender's
# address using the "-f" command line option, without Exim's adding a
# "Sender" header.

trusted_users = mail

# If this option is true, the SMTP command VRFY is supported on incoming
# SMTP connections; otherwise it is not.

smtp_verify = false

# Some operating systems use the "gecos" field in the system password file
# to hold other information in addition to users' real names. Exim looks up
# this field when it is creating "sender" and "from" headers. If these options
# are set, exim uses "gecos_pattern" to parse the gecos field, and then
# expands "gecos_name" as the user's name. $1 etc refer to sub-fields matched
# by the pattern.

gecos_pattern = ^([^,:]*)
gecos_name = $1

# This string defines the contents of the \`Received' message header that
# is added to each message, except for the timestamp, which is automatically
# added on at the end, preceded by a semicolon. The string is expanded each
# time it is used.

received_header_text = "Received: \
          ${if def:sender_fullhost {from ${sender_fullhost} \
          ${if def:sender_ident {(${sender_ident})}}\n\t}\
          {${if def:sender_ident {from ${sender_ident} }}}}\
          by ${primary_hostname} \
          ${if def:received_protocol {with ${received_protocol}}} \
          (Exim ${version_number} #${compile_number} (Debian))\n\t\
          id ${message_id}"

# misc. options
queue_list_requires_admin = false
smtp_accept_queue_per_connection = 0

end


######################################################################
#                      TRANSPORTS CONFIGURATION                      #
######################################################################
#                       ORDER DOES NOT MATTER                        #
#     Only one appropriate transport is called for each delivery.    #
######################################################################

remote_smtp:
  driver = smtp

end


######################################################################
#                      DIRECTORS CONFIGURATION                       #
#             Specifies how local addresses are handled              #
######################################################################
#                          ORDER DOES MATTER                         #
#   A local address is passed to each in turn until it is accepted.  #
######################################################################

end


######################################################################
#                      ROUTERS CONFIGURATION                         #
#            Specifies how remote addresses are handled              #
######################################################################
#                          ORDER DOES MATTER                         #
#  A remote address is passed to each in turn until it is accepted.  #
######################################################################

# Remote addresses are those with a domain that does not match any item
# in the "local_domains" setting above.

# Send all mail to a smarthost

smarthost:
  driver = domainlist
  transport = remote_smtp
  route_list = "* mail.socket.net bydns_a"

end


######################################################################
#                      RETRY CONFIGURATION                           #
######################################################################

# This single retry rule applies to all domains and all errors. It specifies
# retries every 15 minutes for 2 hours, then increasing retry intervals,
# starting at 2 hours and increasing each time by a factor of 1.5, up to 16
# hours, then retries every 8 hours until 4 days have passed since the first
# failed delivery.

# Domain               Error       Retries
# ------               -----       -------

*                      *           F,2h,15m; G,16h,2h,1.5; F,4d,8h

end


######################################################################
#                      REWRITE CONFIGURATION                         #
######################################################################


# This is an example of a useful rewriting rule---it looks up the real
# address of all local users in a file

# *@socket.net    ${lookup{$1}lsearch{/etc/email.map}\
#						{$value}fail} bcfrF

*@snoozer.net		${lookup{$1}lsearch{/etc/email.map}\
					{$value}fail} frFs
*@*.snoozer.net		${lookup{$1}lsearch{/etc/email.map}\
					{$value}fail} frFs
*@glitch		${lookup{$1}lsearch{/etc/email.map}\
					{$value}fail} frFs
*@localhost		${lookup{$1}lsearch{/etc/email.map}\
					{$value}fail} frFs

# End of Exim configuration file

Attachment: pgpnb5EdFFcFb.pgp
Description: PGP signature


Reply to: