Thanks to Sahil Tandon and LuKreme for pointing out my mistake on the
debugging tool.  I saw this done in an old archived post, and having
searched for but not found the "what to include in a problem report"
FAQ item, I winged it, incorrectly.  I also forgot to specify the
version of Postfix: 2.6.1 from OpenSuSE 11.2.

So when mail is sent to user+extension, how do I capture the extension?
I solved my problem partially, by cowboy programming.  I never did see
the EXTENSION environment variable being set, but ORIGINAL_RECIPIENT
semi-reliably includes user+extens...@domain, so by parsing that, I was
able to extract the extension and interpret that as the name of the
mailing list.

The only problem is composite lists.  Suppose /etc/aliases says:
    logs: reports, programmers
    programmers: listmonkey+programm...@julia
If someone on Julia sends to logs, the first alias is expanded instantly
and ORIGINAL_RECIPIENT remains as "logs".  The way I dealt with it is
to say
    logs: reports, programm...@sumac
where Sumac is our MX and nobody ever originates messages from there.

In the source code for local(8) it was clear that EXTENSION would have
been set if the message structure had msg_attr.extension, which is set
in deliver_recipient, and clearly the extension is removed from
msg_attr.user at that point (because Julia delivered it to listmonkey,
which is a user, and not listmonkey+testmonkey, which isn't), but I
can't see why it is not available in deliver_command().

If anyone could shed some light on the right way to capture the extension,
I would really appreciate it.  I've appended the output from postconf -n.


James F. Carter          Voice 310 825 2897    FAX 310 206 6673
UCLA-Mathnet;  6115 MSA; 405 Hilgard Ave.; Los Angeles, CA, USA 90095-1555
Email: j...@math.ucla.edu  http://www.math.ucla.edu/~jimc (q.v. for PGP key)

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases, nis:mail.aliases
best_mx_transport = local
biff = no
bounce_queue_lifetime = 150m
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/lib/postfix
debug_peer_level = 2
default_destination_concurrency_limit = 2
disable_dns_lookups = no
html_directory = /usr/share/doc/packages/postfix/html
mail_owner = postfix
mail_spool_directory = /var/mail
mailbox_command = /usr/bin/procmail -Y -t -a "$DOMAIN" -d "$USER"
mailbox_size_limit = 500000000
mailq_path = /usr/bin/mailq
manpage_directory = /usr/share/man
masquerade_domains = $mydomain
masquerade_exceptions = root
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydomain = math.ucla.edu
mynetworks = 128.97.4.0/24, 128.97.19.0/24, 128.97.70.0/24, 128.97.12.0/24 
127.0.0.0/8
newaliases_path = /usr/bin/newaliases
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/packages/postfix/README_FILES
recipient_delimiter = +
relay_clientcerts = hash:/etc/postfix/relay_ccerts
relay_domains = $mynetworks
require_home_directory = no
sample_directory = /usr/share/doc/packages/postfix/samples
sendmail_path = /usr/sbin/sendmail
setgid_group = maildrop
smtp_sasl_auth_enable = no
smtp_tls_CAfile = /etc/ssl/certs/ucla-math.crt
smtp_tls_CApath = /etc/ssl/certs
smtp_tls_cert_file = /etc/ssl/hostcerts/host.crt
smtp_tls_key_file = /etc/ssl/private/host.key
smtp_tls_session_cache_database = btree:/var/lib/postfix/client_scache
smtp_tls_session_cache_timeout = 3600s
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) UCLA-Mathnet
smtpd_client_restrictions = permit_tls_all_clientcerts, 
permit_sasl_authenticated,      permit_mynetworks,      reject
smtpd_enforce_tls = no
smtpd_helo_required = no
smtpd_recipient_restrictions = reject_unknown_sender_domain,    
reject_unknown_recipient_domain,        reject_unlisted_recipient,      
permit_tls_all_clientcerts,     permit_sasl_authenticated,      
permit_mynetworks,      permit_mx_backup,       reject_unauth_destination,      
permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_local_domain = $mydomain
smtpd_sasl_security_options = noplaintext,noanonymous
smtpd_sasl_tls_security_options = noanonymous
smtpd_sender_restrictions = hash:/etc/postfix/access
smtpd_tls_CAfile = /etc/ssl/certs/ucla-math.crt
smtpd_tls_CApath = /etc/ssl/certs
smtpd_tls_ask_ccert = yes
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/ssl/hostcerts/host.crt
smtpd_tls_dh1024_param_file = /etc/postfix/dh_1024.pem
smtpd_tls_dh512_param_file = /etc/postfix/dh_512.pem
smtpd_tls_key_file = /etc/ssl/private/host.key
smtpd_tls_loglevel = 0
smtpd_tls_received_header = yes
smtpd_tls_req_ccert = no
smtpd_tls_session_cache_database = btree:/var/lib/postfix/smtpd_scache
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
soft_bounce = no
strict_rfc821_envelopes = no
tls_random_exchange_name = /var/lib/postfix/prng_exch
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550

Reply via email to