Sendmail OSX part 2

get sendmail to work with AppleMailServer

get sendmail to work with AppleMailServer




h2. get sendmail to work with AppleMailServer

Option 1 : get sendmail to work with AppleMailServer

OSX Server only. Not the recommended option.

Because we no longer run AppleMailServer at any of our customers’ sites I cannot guarantee success with this method under 10.1.5. It definitely worked with 10.1.4 though.

What we are trying to do here is get sendmail to pass any local messages to the AppleMailServer for local delivery. These messages are forwarded via SMTP on port 627. It is important if you use this approach that port 627 is blocked at your firewall to prevent others exploiting holes (such as the open relay bug) in AppleMailServer.

Create /etc/mail/mailertable. This file tells sendmail to deliver certain domains to a special mailer called "ams".

localhost ams:localhost
domain.com.au ams:localhost

Create /usr/share/sendmail/conf/mailer/AppleMailServer.m4. Here we define the mailer called "ams". This is the part that took me the longest to get right. I am by no means a sendmail expert, so please let me know if you have improvements to be made here. Make sure you don’t get too many line breaks in there, or just download it.


#########################################
  1. AppleMailServer specification ### #########################################

    ifdef(`_ARG_’,`define(`AMS_PORT’,ARG)’)dnl
    ifdef(`AMS_PORT’,,`define(`AMS_PORT’,627)’)dnl

    VERSIONID
    Mams, P=[IPC], F=SMTP_MAILER_FLAGS">CONCAT, S=11/31, R=ifdef(`_ALL_MASQUERADE_’, `21/31’, `21’), E=\r\n,
    L=2040,_OPTINS(`RELAY_MAILER_CHARSET’, `C=’, `,’)T=DNS/RFC822/SMTP, A=IPC $h AMS_PORT


OK. Now we can create the configuration file and we are all done. Be careful here with line breaks. Each line begins with a command like "define" or "feature", even though your browser may have wrapped text differently.

Create /etc/mail/sendmail.mc


###
	
  1. This basic sendmail.mc file provides basic sendmail service
  2. which is still a vast improvement over the built-in Apple
  3. Mail Server.
#
  1. After any change made here, execute this:
  2. cd /usr/share/sendmail/conf/m4
  3. m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf ###

    include(`/usr/share/sendmail/conf/m4/cf.m4’)

    VERSIONID
    OSTYPE
    DOMAIN
    define(`PROCMAIL_MAILER_PATH’,`/usr/bin/procmail’)
    define(`confTRY_NULL_MX_LIST’,true)
    define(`_USE_ETC_MAIL_’,true)
    define(`confSMTP_LOGIN_MSG’,”$j ; $b”)
    define(`confMAX_DAEMON_CHILDREN’,15)
    define(`confPRIVACY_FLAGS’,``noexpn,authwarnings,novrfy,goaway’‘)

    FEATURE
    FEATURE
    define(`confCW_FILE’, `-o /etc/mail/local-host-names’)

    1. deliver all messages through AppleMailServer relay
      FEATURE

    FEATURE
    FEATURE

    FEATURE

    FEATURE
    FEATURE

    1. relay addresses without a domain (eg. admin) to AppleMailServer
      define(`LOCAL_RELAY’, `ams:localhost’)
    2. relay addresses with a domain (eg. admin@domain.com.au) to AppleMailServer

    define(`MAIL_HUB’, `ams:localhost’)

    MAILER
    MAILER
    MAILER

Now go into the Server Admin tool, select "configure mail server…" and select "sendmail" in the popup next to SMTP. Save the preferences. This will write some configuration into the sendmail.cf file, which doesn’t seem to work. Later on we rebuild that file anyway, so don’t worry about it.

Now move on to the “final step”:node/131.