Configuring Sun Solaris outgoing mail

 


     

  1. Gather the following information
    1. Your email address, i.e., foo@foo.com
    2. Your ISP's domain, i.e., foo.com
    3. The name of your ISP's outgoing mail host, i.e., mail.foo.com

     

  2. Check that sendmail can identify your host
  3. Run the following script to verify the FQDN is set correctly:

    /usr/lib/mail/sh/check-hostname
    If an error message returns, make recommended corrections, which generally include putting the FQDN in /etc/inet/hosts. If you don't own a domain name, invent one.
    IP_address          hostname FQDN loghost
    

     

  4. Make a copy of /etc/mail/subsidiary.cf
  5. # cd /etc/mail
    # cp subsidiary.cf sendmail.cf.yourisp

     

  6. Edit /etc/mail/sendmail.cf.yourisp
  7. Look near the start of the file for the section headed:

    ##################
    # local info #
    ##################

    A few lines after this heading are the lines:

    # "Smart" relay host (may be null)
    DSmailhost.$m

    Change the second of these lines so that it reads "DS" followed immediately by the name of your ISP's smart mail host. There mustn't be any spaces on this line. For example, if the name of the smart host is mail.foo.com, this line should read:

    DSmail.foo.com

    If your system does not have access to DNS, tell sendmail not to try and do DNS lookups for outgoing email. Look for the section in the file headed:

    ###############
    # Options #
    ###############

    and, within the Options section, the lines which read:

    # name resolver options
    #O ResolverOptions=+AAONLY

    Immediately after this point, insert the lines:

    # Don't use DNS
    O ResolverOptions=-DNSRCH

     

  8. Test the edits to the sendmail rewriting rules
  9. To test rewriting rules:

    # /usr/lib/sendmail -C/etc/mail/sendmail.cf.yourisp -bt

    If sendmail reports errors such as "invalid rewrite line", your edits to the sendmail configuration file are incorrect. If all is well, sendmail will respond with some text and a ">" prompt, expecting you to type a rule number followed by a space and an address. For example:

    # /usr/lib/sendmail -C/etc/mail/sendmail.cf.yourisp -bt

    ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
    Enter <ruleset> <address>
    > 11 clyde
    rewrite: ruleset 11 input: clyde
    rewrite: ruleset 11 returns: clyde @ yourisp . com
    > 11 clyde.barrow@localhost
    rewrite: ruleset 11 input: clyde @ localhost
    rewrite: ruleset 11 returns: clyde @ yourisp . com
    > 11 bonnie@gateway
    rewrite: ruleset 11 input: bonnie @ gateway
    rewrite: ruleset 11 returns: bonnie @ yourisp . com
    > 31 joe
    rewrite: ruleset 31 input: joe
    rewrite: ruleset 31 returns: joe @ yourisp . com
    > 31 sally@localhost
    rewrite: ruleset 31 input: sally @ localhost
    rewrite: ruleset 31 returns: sally @ yourisp . com
    > 31 sally@gateway
    rewrite: ruleset 31 input: sally @ gateway
    rewrite: ruleset 31 returns: sally @ yourisp . com
    > #

    To exit sendmail execute <CONTROL>-<D>

     

  10. Test the changes to the sendmail delivery rules
  11. Run sendmail again in rule testing mode to check that it correctly identifies the delivery agent:

    # /usr/lib/sendmail -C/etc/mail/sendmail.cf.yourisp -bt

    Use the "/parse" command on different types of email address to check which mailer will be invoked by sendmail for each type of address. For example:

    > /parse bonnie
    > /parse bonnie@local_machine_on_your_network
    > /parse bonnie.parker@foo.com

    For the last example, the output should contain:

    mailer relay, host mail.foo.com, user bonnie.parker@foo.com

    This indicates that mail to non-local addresses will be delivered using the "relay" mailer which will send the mail to mail.foo.com, the ISP's mail host.

     

  12. Edit /etc/init.d/sendmail
  13. This file starts sendmail at boot time. Edit the file to replace:

    /usr/lib/sendmail -bd -q15m &

    in the "start" section with the line:

    /usr/lib/sendmail -bd -X /var/log/mail.log -oL9 &

    The option "-bd" starts sendmail as a daemon, listening for SMTP connections on port 25. The option "-q15m" in the default file causes sendmail to process its queue of outgoing mail every 15 minutes and this isn't appropriate when the system spends most of its time off-line. The remaining options are optional but are worth using until you're sure that sendmail is working properly. "-X /var/log/mail.log" logs all mail transactions to the specified file; and "-oL9" sets the logging level to the specified value.

     

  14. Activate the new sendmail.cf
  15. Providing the tests in the preceding step were successful, activate the new sendmail configuration file by copying it and restarting sendmail:

    # cp /etc/mail/sendmail.cf.yourisp /etc/mail/sendmail.cf"
    # /etc/init.d/sendmail stop
    # /etc/init.d/sendmail start

     

  16. Test mail delivery
  17. To send a mail message to clyde from the command line:

    # mail clyde
    From: root
    To: clyde

    This is a test mail message
    .

    Note the blank line after the headers and the full stop at the start of the final line which terminates the message.

    Check that the mail queue is empty:

    # mailq
    Mail queue is empty

    Now switch user to clyde and check that the mail message has been delivered:

    # su - clyde
    Sun Microsystems Inc. SunOS 5.8 Beta_Refresh February 2000
    You have mail.
    $ mail
    From root Sat Jan 8 21:52:42 2000
    Date: Sat, 8 Jan 2000 21:52:42 GMT
    From: John Mann
    Message-Id: <200001082152.VAA00847@sunbeam.foo.com>
    To: clyde
    Content-Length: 29

    This is a test mail message

    ? d
    $ exit
    #

    Now send a mail message to an address outside your system. For example:

    # mail bonnie.parker@foo.com
    From: clyde.barrow@foo.com
    To: bonnie.parker@foo.com

    This is a test mail message
    .

    and make sure that it's been queued by sendmail for later delivery:

        # mailq
                    Mail Queue (1 request)
        --Q-ID-- --Size-- -----Q-Time----- ------------Sender/Recipient------------
        RAA01206       29 Sun Jan  9 17:48 root
                                           bonnie.parker@foo.com
    

     

  18. To monitor the actions of sendmail:
  19. # tail -f /var/log/mail.log

 


Configuration Files

/etc/mail/sendmail.cf Main configuration file
/etc/mail/main.cf Used on systems which act as mailhosts. Provides all the sendmail rules needed to route mail on to the Internet.
/etc/mail/subsidiary.cf Used on systems which only route mail directly to hosts on the same domain and which send outbound mail to a designated smart host which relays the mail to its destination.


 

Home