1 (edited by wdbacker 2011-12-08 20:04:01)

Topic: Create blackhole mail address (e.g. noreply@example.com)

If one needs a mail address from which you will only send mail out, but don't wish to receive mail (e.g. you send a newsletter with noreply@example.com as sender address), you can do this rather easily:

- edit the /etc/postfix/aliases file and add there as bottom line:

devnull: /dev/null

- rebuild the aliases.db file with the command:

newaliases

- edit the /etc/postfix/virtual file and add as bottom line (replace the example.com domain with your main virtual domain):

blackhole@example.com devnull

- rebuild virtual.db file with the command:

postmap /etc/postfix/virtual

Now create a mail user or alias that is forwarded to blackhole@example.com ... that's all!

2

Re: Create blackhole mail address (e.g. noreply@example.com)

Thanks for sharing this useful tip. smile

3 (edited by mark.tamis 2014-01-04 06:02:56)

Re: Create blackhole mail address (e.g. noreply@example.com)

I am using the following approach:

- create a mail user called do-not-reply@domain.tld
- create the file /etc/postfix/ldap/transport_maps_discard.cf

server_host     = 127.0.0.1
server_port     = 389
version         = 3
bind            = yes
start_tls       = no
bind_dn         = cn=vmail,dc=domain,dc=tld
bind_pw         = YourPassword
search_base     = ou=Users,domainName=%d,o=domains,dc=domain,dc=tld
scope           = one
query_filter    = (&(objectClass=mailUser)(|(mail=do-not-reply@%d)(&(enabledService=shadowaddress)(shadowAddress=do-not-reply@%d)))(accountStatus=active)(enabledService=mail)(enabledService=deliver))
result_attribute= uid
result_filter   = discard:[NOT SENT: %s]
debuglevel      = 0

in /etc/postfix/main.cf

transport_maps = proxy:ldap:/etc/postfix/ldap/transport_maps_user.cf, proxy:ldap:/etc/postfix/ldap/transport_maps_domain.cf, proxy:ldap:/etc/postfix/ldap/transport_maps_discard.cf

and reload postfix

you should see a mail.log message as follows when someone tries to send a message

Jan  3 19:04:18 rbx1 postfix/discard[31565]: 2591840DBA: to=<do-not-reply@dc=domain,dc=tld>, relay=none, delay=0.02, delays=0.01/0.01/0/0, dsn=2.0.0, status=sent ([NOT SENT: do-not-reply])

the way it is set up, a special email account called do-not-reply should be created for each of your domains (you can change this address fairly simply to whatever you want)

If you prefer to set up a mail alias rather than a mail user, change the following lines in transport_maps_discard.cf:

search_base     = o=domains,dc=domain,dc=tld
scope           = sub
query_filter    = (&(|(mail=do-not-reply%d)(shadowAddress=do-not-reply%d))(accountStatus=active)(enabledService=mail)(enabledService=deliver)(|(objectClass=mailAlias)(&(objectClass=mailUser)(enabledService=forward))))

4

Re: Create blackhole mail address (e.g. noreply@example.com)

This has been working fine for me, except when sending from a system user to an address on the same server. I must have something askew in the query, as when internal log messages (root@mailserver.domain.tld) are sent to any address of my domain (postmaster@domain.tld, user@domain.tld), the filter kicks in and discards these. But no issue when communicating with the outside world. Any ideas, anyone?

5

Re: Create blackhole mail address (e.g. noreply@example.com)

wdbacker wrote:

If one needs a mail address from which you will only send mail out, but don't wish to receive mail (e.g. you send a newsletter with noreply@example.com as sender address), you can do this rather easily:

- edit the /etc/postfix/aliases file and add there as bottom line:

devnull: /dev/null

- rebuild the aliases.db file with the command:

newaliases

- edit the /etc/postfix/virtual file and add as bottom line (replace the example.com domain with your main virtual domain):

blackhole@example.com devnull

- rebuild virtual.db file with the command:

postmap /etc/postfix/virtual

Now create a mail user or alias that is forwarded to blackhole@example.com ... that's all!

Following those instructions postfix logs:
Jul  6 08:54:29 m0 postfix/smtpd[5187]: AEBAA16064A: client=localhost[127.0.0.1]
Jul  6 08:54:29 m0 postfix/cleanup[5176]: AEBAA16064A: message-id=<e08daaa6bbbe53952d76d555fb1635c2@hidden>
Jul  6 08:54:29 m0 postfix/qmgr[4999]: AEBAA16064A: from=<hidden>, size=5257, nrcpt=1 (queue active)
Jul  6 08:54:29 m0 amavis[22378]: (22378-17) Passed CLEAN {RelayedOutbound}, MYNETS/MYUSERS LOCAL [127.0.0.1]:35698 [127.0.0.1] <hidden> -> <blackhole@example.com>, Message-ID: <e08daaa6bbbe53952d76d555fb1635c2@hidden>, mail_id: FjGKLrHZcKNl, Hits: -8.451, size: 4824, queued_as: AEBAA16064A, 356 ms
Jul  6 08:54:29 m0 postfix/smtp[5178]: 48EAE16006C: to=<blackhole@example.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=0.46, delays=0.06/0.03/0/0.36, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as AEBAA16064A)
Jul  6 08:54:29 m0 postfix/pipe[5188]: AEBAA16064A: to=<blackhole@example.com>, relay=dovecot, delay=0.06, delays=0.01/0.01/0/0.04, dsn=5.1.1, status=bounced (user unknown)
Jul  6 08:54:29 m0 postfix/bounce[5190]: AEBAA16064A: sender non-delivery notification: BB9C916064D

This is a sample attempt to reply to the no-reply@domain.com which is an alias to blackhole@example.com which leads to devnull (/dev/null).  As you can see, postfix relays the mail through dovecot, a bounced mail is generated and returned to the user who attempts to reply to the no-reply (blackhole) address. Can this be avoided, and how?