set_credentials.sh [plain text]
#!/bin/sh
/usr/sbin/postconf -e imap_submit_cred_file=/Library/Server/Mail/Config/postfix/submit.cred
if [ ! -e /Library/Server/Mail/Config/postfix/submit.cred ] ; then
hostname=`/usr/sbin/postconf -c /Library/Server/Mail/Config/postfix -h myhostname`
if [ ! "$hostname" ] ; then
hostname=`hostname`
fi
if [ -s /Library/Server/Mail/Config/dovecot/submit.passdb ] ; then
pw=`grep "^submit:" /private/etc/dovecot/submit.passdb | sed -e 's,.*},,' -e 's,:.*,,'`
elif [ -s /private/etc/dovecot/submit.passdb ] ; then
pw=`grep "^submit:" /Library/Server/Mail/Config/dovecot/submit.passdb | sed -e 's,.*},,' -e 's,:.*,,'`
fi
if [ ! "$pw" ] ; then
pw=`dd if=/dev/urandom bs=256 count=1 2>&1 | env LANG=C tr -dc a-zA-Z0-9 2>&1 | cut -b 1-22 2>&1`
fi
if [ "$pw" -a "$hostname" ]; then
echo "submitcred version 1" > /Library/Server/Mail/Config/postfix/submit.cred
echo "$hostname|submit|$pw" >> /Library/Server/Mail/Config/postfix/submit.cred
fi
chmod 600 /Library/Server/Mail/Config/postfix/submit.cred
fi