sawyl: (Default)
[personal profile] sawyl
Ever wanted to get postfix authentication working under NetBSD? Well, it's not actually all that difficult. Here's a quick guide to doing it from scratch:

1. Install pkgsrc
Download the tarball from the NetBSD web site. Bootstrap the installation as follows:

cd /usr/pkgsrc/bootstrap; ./bootstrap
cd /etc
ln -s ../usr/pkg/etc/mk.conf .

2. Set Postfix Options
Edit /etc/mk.conf to add the option "PKG_OPTIONS.postfix+=sasl"

3. Build and Install Postfix
Build and install the package in the normal way:

cd /usr/pkgsrc/mail/postfix
make install

4. Build and Install cy2-plain
Build and install the auth package in the usual way (you might need other packages if you want to use something other than plaintext authentication):

cd /usr/pkgsrc/security/cy2-plain
make install

5. Setup the Configuration Files
Set up the postfix configuration files by doing the following:

cd /etc/postfix
mv main.cf main.orig
mv master.cf master.orig
ln -s ../../usr/pkg/etc/postfix/main.cf .
ln -s ../../usr/pkg/etc/postfix/master.cf .

6. Edit main.cf
Change the main.cf configuration file. It should contain something like the following (where "mail.isp" is the name of your ISP's SMTP relay host):

# Directory settings
command_directory = /usr/pkg/sbin
config_directory = /usr/pkg/etc/postfix
daemon_directory = /usr/pkg/libexec/postfix
queue_directory = /var/spool/postfix
sample_directory = /usr/pkg/share/examples/postfix
newaliases_path = /usr/pkg/bin/newaliases
sendmail_path = /usr/pkg/sbin/sendmail
mailq_path = /usr/pkg/bin/mailq

# User settings
mail_owner = postfix
setgid_group = maildrop

# Local settings
myorigin = $myhostname
mydestination = $myhostname localhost localhost.$mydomain
mynetwork_style = host
relay_domains =
relayhost = [mail.isp]
notify_classes = resource, software

# SASL settings
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/usr/pkg/etc/postfix/sasl_passwd
smtp_sasl_security_options =

7. Setup the SASL Password File
Create the password file as follows:

touch /usr/pkg/etc/postfix/sasl_passwd
chmod 0600 /usr/pkg/etc/postfix/sasl_passwd

Then add the lines:

[mail.isp] username:password

Replacing "[mail.isp]" with the name of your SMTP relay host. Create the password hash with:

postmap hash:/usr/pkg/etc/postfix/sasl_passwd

8. Configure the Startup Scripts
Add the following to /etc/rc.conf.d/postfix:

required_files='/usr/pkg/etc/postfix/main.cf'
start_cmd='/usr/pkg/sbin/postfix start'
stop_cmd='/usr/pkg/sbin/postfix stop'
reload_cmd='/usr/pkg/sbin/postfix reload'

9. Start Postfix
Start the daemons by hand:

/usr/pkg/sbin/postfix start

10. Test the Configuration
Try sending a message to a user on the local machine. If this works, try sending a message a remote user. Examine the mail log and confirm that the relayhost has accepted the message — the smtp server should report something like "status=sent (250 OK id=XXX)" if the message has been accepted.

Profile

sawyl: (Default)
sawyl

August 2018

S M T W T F S
   123 4
5 6 7 8910 11
12131415161718
192021222324 25
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 5th, 2026 02:21 am
Powered by Dreamwidth Studios