Amavisd needs to be running for postfix to use it to scan the mails. For this reason, we need to start amavisd on boot along with our server. Starting amavisd at boot requires a plist to be installed in /Library/launchDaemons/ for launchd to use. There is already a plist for amavisd, but you don’t need to worry about them as they are disabled. We are going to make our own plists instead.

In your favorite text editor create the file org.diymacserver.amavisd.plist which we use to launch amavisd with.

This is what is should look like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>org.diymacserver.amavisd</string>
  <key>OnDemand</key>
  <false/>
  <key>Program</key>
  <string>/usr/local/bin/amavisd</string>
  <key>ProgramArguments</key>
  <array>
    <string>amavisd</string>
    <string>-c</string>
    <string>/etc/amavis/amavisd.conf</string>
    <string>foreground</string>
  </array>
  <key>ServiceIPC</key>
  <false/>
  <key>UserName</key>
  <string>_amavisd</string>
</dict>
</plist>

Once you have it saved, we need to alter the permissions and ownerships on the new file and move it into place. We do that with the following commands :

sudo chown root:wheel org.diymacserver.amavisd.plist
sudo chmod 0644 org.diymacserver.amavisd.plist
sudo mv org.diymacserver.amavisd.plist /Library/LaunchDaemons/

Amavisd has a cleanup process that we also need setup properly now that we are going to be running amavisd all the time. As with amavisd, we are going to make a plist for it. This one will be called org.diymacserver.amavisd_cleanup.plist

It should look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>org.diymacserver.amavisd_cleanup</string>
  <key>Program</key>
  <string>/var/amavis/amavisd_cleanup</string>
  <key>ProgramArguments</key>
  <array>
    <string>amavisd_cleanup</string>
  </array>
  <key>ServiceIPC</key>
  <false/>
  <key>StartInterval</key>
  <integer>600</integer>
  <key>UserName</key>
  <string>_amavisd</string>
</dict>
</plist>

Once this file is saved, just like the other one, we need to change its ownerships and permissions and move it into place.

sudo chown root:wheel org.diymacserver.amavisd_cleanup.plist
sudo chmod 0644 org.diymacserver.amavisd_cleanup.plist
sudo mv org.diymacserver.amavisd_cleanup.plist /Library/LaunchDaemons/

The last thing to do is to create the log file for the amavisd processes. Once created we change the permissions on it and change the ownership to the amavisd user.

We use these commands:

sudo touch /var/log/amavis.log
sudo chmod 644 /var/log/amavis.log
sudo chown amavisd:wheel /var/log/amavis.log

Now that we have all the necessary files in place, there is 1 more thing to do before you start the process. We need to create 1 file or amavisd gets upset. it’s really quick.

sudo touch /var/amavis/local_domains

You can now start the process with the following 2 commands:

sudo launchctl load /Library/LaunchDaemons/org.diymacserver.amavisd_cleanup.plist
sudo launchctl load /Library/LaunchDaemons/org.diymacserver.amavisd.plist

Congratulations, we are almost done. Next we have to tell postfix to use amavisd and clamav.