Dec 072009

I don’t know what is the right subject for this topic, the idea is, i just want my outgoing smtp for sending email only, authenticated user not supposed send(or accidentally) to his/her smtp authentication account.which are in my configuration stored in virtual mailbox maps table. In normal case can delivering email to maildir.

I’m using postfixadmin to generate username/password, saslauthd with pam_mysql for querying username/password to mysql virtual mailbox table.Everything is okay with authentication things, except i don’t want username receiving email

In postfix access 5 manual there is actions called DISCARD

       DISCARD optional text...
              Claim successful delivery and silently discard  the
              message.   Log the optional text if specified, oth-
              erwise log a generic message.

              Note: this action currently affects all  recipients
              of  the  message.   To  discard  only one recipient
              without discarding  the  entire  message,  use  the
              transport(5) table to direct mail to the discard(8)

              This feature is available in Postfix 2.0 and later.

Here’s how i do it:

Create mysql lookup tables

user = postfix
password = password
hosts = localhost
dbname = postfixdb
query = SELECT 'DISCARD [Sent only user!]' FROM mailbox WHERE username='%s' AND active = 1

Notice on query statement “query = SELECT ‘DISCARD [Sent only user!]’ FROM mailbox WHERE username=’%s’ AND active = 1”

The query will always returning ‘DISCARD [Sent only user!]’ if ‘%s’ match username in virtual mailbox tables

Now put lookup query to submission resctriction

submission inet n       -       n       -       -       smtpd
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_recipient_restrictions=check_recipient_access,mysql:/etc/postfix/,permit_mynetworks,permit_sasl_authenticated,reject

Logs shows:

Dec  7 11:44:32 smtp postfix/smtpd[29040]: NOQUEUE: discard: RCPT from[] <>: Recipient address [Sent only user!]; from=<> to=<> proto=ESMTP helo=<[]> 
Dec  7 11:44:32 smtp postfix/smtpd[29040]: E9CE5208A1:[], sasl_method=PLAIN,

Maybe there’s easy/better solutions that i don’t know yet, but it work as i expected for now.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>