Sendmail

From pressy's brainbackup
Jump to: navigation, search

Sendmail

How to send mail with mailx.

Modify /etc/mail/submit.cf so that mail is sent via your smtp host. The easiest way to modify /etc/mail/submit.cf is to change /usr/lib/mail/cf/submit.mc.

# cd /usr/lib/mail/cf/
# vi submit.mc

Add to that the following directives

define(`SMART_HOST', `your.smtp.server.')dnl
define(`MAIL_HUB',`your.smtp.server.')dnl
define(`LOCAL_RELAY',`your.smtp.server')dnl

prior to the line that says:

FEATURE(`msp',`[127.0.0.1]')dnl

then

# make submit.cf
# cp submit.cf /etc/mail/

You should now be able to send mail without sendmail running.

# /etc/init.d/sendmail stop

AUTO

#
# Script to set mailer
#
cd /etc/mail/cf/cf
# Copy example sendmail.mc to hostname.mc
cp sendmail.mc `hostname`.mc
# Enter correct FALLBACK_SMARTHOST
nawk '{gsub(/mailhost\$\?m\.\$m\$\./, "mail.pressy.at"); print $0}' `hostname`.mc > `hostname`_tmp.mc
mv `hostname`_tmp.mc `hostname`.mc
# Compile new sendmail.cf
make `hostname`.cf > /dev/null 2>&1
if [ $? -ne 0 ]; then
   echo "Compilation of sendmail was not successful"
   echo "Now I will edit the file sendmail.cf directly"
   cp /etc/mail/sendmail.cf /etc/mail/sendmail.cf_ori
   cp /etc/mail/submit.cf /etc/mail/submit.cf_ori
   sed 's/^O FallbackSmartHost=.*/O FallbackSmartHost=mail\.pressy\.at/g' /etc/mail/sendmail.cf_ori > /etc/mail/sendmail.cf
   sed 's/.*O FallbackSmartHost=.*/O FallbackSmartHost=mail\.pressy\.at/g' /etc/mail/submit.cf_ori > /etc/mail/submit.cf
else
   echo "Compilation of sendmail was successful"
   cp /etc/mail/sendmail.cf /etc/mail/sendmail.cf_ori
   cp `hostname`.cf /etc/mail/sendmail.cf
fi
# Restart sendmail
svcadm restart -s svc:/network/smtp:sendmail
# Send test mail
echo "Test-Normal Mail: Configuration is ready." | mailx -s "TESTMAIL from `hostname`" me@pressy.at