Help Setting up smtp authentication in postfix

Good Day,

I am a linux noobie and is having trouble te get smtp authentication working with postfix.

I have tried a ton of guides but every single one of them is different from my default config.

I'm not sure if I should go with dovecot or Cyrus SASL.

All the mail server needs to do is to receive the email from the client and then send it on to the recipient's mailbox.

All clients use the same username and password, port 25 no encryption.

If anyone can give me some tips or a link that explain where and how to set up the username and password.

Thank you in advance.

The documentation is a good place to start. Probably the simplest way to authenticate your mail user is to create an actual system user and have Dovecot/Cyrus authenticate against the /etc/passwd file.

The specifics of what you will have to do depend a lot on the default config that ships with your distro.

1 Like

Thanks,

I will give it a try.

This is the guide I used to set up my mail server. It might be a little more than what you want to do but it might be worth a look anyway.

http://flurdy.com/docs/postfix/

Thank you,

One more question,

Where do I specify the username and password for the authentication?

Do I need to create the database and the tables manually or should postfix-sql create them automaticly?

Dec 17 12:33:55 cwnmail2 postfix/smtpd[4493]: sql plugin trying to open db 'maildb' on host '127.0.0.1'
Dec 17 12:33:55 cwnmail2 postfix/smtpd[4493]: sql plugin could not connect to host 127.0.0.1
Dec 17 12:33:55 cwnmail2 postfix/smtpd[4493]: sql plugin couldn't connect to any host
Dec 17 12:33:55 cwnmail2 postfix/smtpd[4493]: sql plugin Parse the username admin

Yeah you'll need to set up the database and then add the users to that database.

Ok Thank you Sir,

Will give that a try.

Ok,

I have managed to set up the mysql db and the tables.

Also I have managed to completely mess up postfix to the point outlook gives me a unknown error when testing the connection.

I have asked the previous guy who configured the server a few years back how the authentication is done and he did it by creating a admin user with password admin on ubuntu and gave the user some permission to authenticate with postfix.

That was more than 3 years ago.

The mailserver is for a ISP and only does SMTP.

There must only be one username and password for all clients, admin:admin

Port 25 no encryption.

Can anyone help with authenticating using a system user and password?

All I can find, is authentication with dovecot/cyrus or MySql.

All I need is a quick and dirty authentication method for smtp

I Just want to add something,

Im looking for something like carnogaunt suggested, but the problem is I am still very new to Linux.

The only way I manage to get something done in the command line is by following a guide on the net.

Usually the guide assumes that you are already clued up with linux.

I am a network admin for a wireless ISP, so finding time to learn is a bit tough.

Well, I can show you my config. It's pretty quick and pretty dirty. The high-level overview is that clients will connect to Postfix and offer credentials, Postfix will pass the credentials to Dovecot over a socket, and Dovecot will confirm the validity of the credentials using PAM.

This is what I've appended to /etc/postfix/main.cf:

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject
smtpd_tls_cert_file = /etc/pki/tls/certs/mx.*****.combined.crt
smtpd_tls_key_file = /etc/pki/tls/private/mx.*****.key
smtpd_tls_security_level = may
smtpd_tls_auth_only = yes
smtpd_tls_session_cache_database = btree:/var/lib/postfix/smtpd_scache
smtpd_tls_note_starttls_offer = yes

I suppose you could ignore the TLS options if you really don't need encryption.

And these are my non-default options in Dovecot:

$ doveconf -n
# 2.2.10: /etc/dovecot/dovecot.conf
# OS: Linux 3.10.0-327.3.1.el7.x86_64 x86_64 CentOS Linux release 7.2.1511 (Core)
auth_mechanisms = plain login
mail_location = maildir:~/Maildir
mbox_write_locks = fcntl
namespace inbox {
  inbox = yes
  location =
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Sent {
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  mailbox Trash {
    special_use = \Trash
  }
  prefix =
}
passdb {
  driver = pam
}
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0666
    user = postfix
  }
}
ssl = required
ssl_cert = </etc/pki/tls/certs/mail.*****.combined.crt
ssl_key = </etc/pki/tls/private/mail.*****.key
ssl_protocols = !SSLv2 !SSLv3
userdb {
  driver = passwd
}

The Dovecot options are spread throughout several different files, which are parsed in order of file name. From the modified date of the files, I see that I changed 10-auth.conf, 10-mail.conf, 10-master.conf, and 10-ssl.conf. It probably would have been better for maintainability to put these options in a new file like 11-custom.conf. Again, you can probably just ignore the SSL options if you really don't need encryption.

Then you will do something like the following to add the user:

# useradd admin
# passwd admin
# # and it may also be wise to disable shell login for this user
# usermod -s /sbin/nologin admin

Note that with this config your mail user does need a home directory to store received mail.

I can give additional information or clarification if need be.

Thanks for the info.

For some reason when I enable this line

smtpd_sasl_type = dovecot

Outlook just comes with the error, Unable to connect, connection interrupted.

Any Ideas?

Do you get that error when you try to send mail, or when you just try to open your mailbox?

Try enabling auth_debug in Dovecot and show us a log.