Replacing the default FreeBSD system mailer Sendmail with Postfix using SMTP AUTH, acting as mail client
# pkg install postfix-sasl
1
Would you like to activate Postfix in /etc/mail/mailer.conf [n]? y2
# service sendmail stop
# sysrc postfix_enable="YES"
# sysrc sendmail_enable="NONE"
# echo '# Disable sendmail(8) specific tasks\
daily_clean_hoststat_enable="NO"\
daily_status_mail_rejects_enable="NO"\
daily_status_include_submit_mailq="NO"\
daily_submit_queuerun="NO"\
#' >> /etc/periodic.conf
1: To use SASL authentication Postfix needs be built with Cyrus SASL support.
2: If you skipped this step and Postfix is not already activated in /etc/mail/mailer.conf :
# mv /etc/mail/mailer.conf /etc/mail/mailer.conf.old
# install -m 0644 /usr/local/share/postfix/mailer.conf.postfix /etc/mail/mailer.conf
Make sure Postfix built with SASL:
# postconf -A
cyrus
Create $config_directory/sasl_passwd
:
[smtp.example.com]:submission username:password
# postmap sasl_passwd
Add to main.cf
:
# SASL authentication in the Postfix SMTP client
smtp_sasl_auth_enable = yes
relayhost = [smtp.example.com]:submission
smtp_sasl_password_maps = hash:$config_directory/sasl_passwd
# service postfix start
To enable opportunistic TLS add to main.cf
:
smtp_tls_security_level = may
> telnet localhost 25
...
mail from: <[email protected]>
250 2.1.0 Ok
rcpt to: <[email protected]>
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
To: <[email protected]>
From: <[email protected]>
Subject: Test
Message-Id: <local-part@domain>
Content-Type: text/plain; charset=utf-8
Test
.
250 2.0.0 Ok: queued as 0EA2B53155
<...another mail transaction...>
quit