Here’s a quick and dirty diff to get sSMTP to build and install properly under MacOS X without it doing stupid things.
What is sSMTP? It’s a secure, effective and simple way of getting mail off a system to your mail hub. It contains no suid-binaries or other dangerous things – no mail spool to poke around in, and no daemons running in the background. Mail is simply forwarded to the configured mailhost. No worries about maintaining sendmail, or the security issues of sendmail itself! I like the idea of easy configuration with minimal security implications. Were I needing a bit more than a simple ‘forward mail’ function, I’d probably setup postfix again, but as Thoreau said, “Simplify, Simplify.”
The default configuration attempts to replace sendmail entirely with the ‘install-sendmail’ directive. This isn’t only wrong practice, but more than likely, it’ll screw things up.
My patch will allow you to replace sendmail and use SSMTP, but backs up sendmail to sendmail.OLD so when you install a system patch, you can just revert to sendmail, then manually replace the sendmail binary with SSMTP, should you choose. Read the README and INSTALL. Few of you probably want, and even fewer probably need this. This package, 2.60.3, was still set as 2.60.1 in the source. I bumped it, since I’m anal. This patch somewhat fixes the configuration script – it’s a bit funky in what it assumes, and I figure ‘you’ll only install once, anyhow’. Note that I haven’t fixed this to include functions to make ’—enable-logging’ for excessive logging work. I don’t need it, and it’s pretty easy to trace sSMTP. ;)
Note that to get everything in an OSX-friendly manner, I configured as:
./configure—prefix=/usrThen I exected a ‘make install-sendmail’, following with editing my configuration files in /usr/etc/ssmtp/ssmtp.conf. You’ll most likely want to set root=YOURUSERNAME and mailhub=some.other.mail.host.org. If you don’t want sSMTP to rewrite everything, and to use whatever your mailer sets the ‘From’ line as, ensure to append ‘FromLineOverride=YES’ to this file!
As it’s not a daemon, there’s nothing to startup – you can test that it’s working with
%mailYou’ll watch as ssmtp starts spewing out garbage like:
[<That means it’s working!
Now, for the patch:
diff -u -r -N ssmtp-2.60/Makefile.in ssmtp-2.60.OSX/Makefile.in—- ssmtp-2.60/Makefile.in2002-09-27 05:32:53.000000000 -0700 +++ ssmtp-2.60.OSX/Makefile.in2003-05-21 19:38:46.000000000 -0700@ -56,11 +56,11
@
.PHONY: install-sendmail
install-sendmail: install
-$(RM) $(bindir)/sendmail
-$(LN_S) ssmtp $(bindir)/sendmail
+-mv -f $(bindir)/sendmail $(bindir)/sendmail.OLD
+$(LN_S) $(bindir)/ssmtp $(bindir)/sendmail
$(INSTALL) -d -m 755 $(libexecdir)
$(RM) $(libexecdir)/sendmail
-$(LN_S) sendmail /lib/sendmail
+$(LN_S) sendmail $(prefix)/lib/sendmail
$(RM) $(mandir)/sendmail.8
$(LN_S) ssmtp.8 $(mandir)/sendmail.8
diff -u -r -N ssmtp-2.60/generate_config ssmtp-2.60.OSX/generate_config—- ssmtp-2.60/generate_config2002-09-27 04:00:01.000000000 -0700
+++ ssmtp-2.60.OSX/generate_config2003-05-21 19:06:00.000000000 -0700
@ -1,4 +1,4
@
-#!/bin/sh -e
+#!/bin/sh
@ -7,7 +7,7
@
syshostname=`hostname—fqdn`
if test -f /etc/mailname
then
-:
+/bin/true
else
echo “Please enter the mail name of your system.”
echo “This is the hostname portion of the address to be shown”
@ -22,13 +22,11
@
then
mailname=$syshostname
fi
-else
-mailname=”`head -1 /etc/mailname`”
fi
echo -n “Please enter the SMTP port number [25]: ”
read smtpport
-if test -z ”$smtpport”
+if [ -z ”$smtpport” ];
then
mailhub=$mailhub
else
diff -u -r -N ssmtp-2.60/ssmtp.c ssmtp-2.60.OSX/ssmtp.c—- ssmtp-2.60/ssmtp.c2002-12-08 09:26:20.000000000 -0800
+++ ssmtp-2.60.OSX/ssmtp.c2003-05-21 19:00:08.000000000 -0700
@ -14,6 +14,7
@
*/
-#define VERSION “2.60.1”
+#define VERSION “2.60.3”
+#include
That’s all there is to it! You can find the “current” release of sSMTP at various places, but I patched against the one I found at ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/ssmtp_2.60.3.tar.gz.
[Update: This assumes that you are not using my mailwrapper configuration – if you install this way, install mailwrapper AFTER sSMTP, it’s smart enough to test if sendmail is a symlink – note you’ll still have to modify /etc/mail/mailer.conf for sSMTP use.]