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?