figured it out. I was missing some entries in my main.cf file:
smtpd_recipient_restrictions = permit_mynetworks, permit_auth_destination, reject
virtual_alias_maps = hash:/etc/postfix/virtual
local_recipient_maps =
making the full main.cf:
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_reject_unlisted_recipient = no
smtpd_recipient_restrictions = permit_mynetworks, permit_auth_destination, reject
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = server1.helpmeco.de
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = helpmeco.de, server1.helpmeco.de, localhost.helpmeco.de, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command =
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
home_mailbox = Maildir/
virtual_alias_maps = hash:/etc/postfix/virtual
local_recipient_maps =
When you say "a PHP script" do you mean a PHP script on a webserver elsewhere, or a PHP script run on the command line locally?
I've done sending the mail to a website elsewhere using exim4 and curl, by creating a custom transport like so:
send_to_site:
driver = pipe
command = /usr/bin/curl https://example.com/mail.php --data-urlencode "mail@-"
user = nobody
group = nogroup
return_path_add
delivery_date_add
envelope_to_add
If you are using Debian's "split configuration" option, you would create a file in /etc/exim4/conf.d/transport/
with this in it. The command
here will pass the entire email (headers and body) to mail.php
in the variable $_REQUEST["mail"]
. You'll need to have your PHP script handle the headers.
To trigger the transport you'll need to have a router
configured that matches whatever email you want to receive and uses the above transport
to send it. With split configuration, routers go in /etc/exim4/conf.d/router/
. For capturing ALL the mail for a specific domain, I haven't tested this but I think this is right:
catchall_mail:
driver = accept
domains = mydomain.com
transport = send_to_site
Debian numbers the files in the router directory to set the order routers are checked in. The first matching router will be used to handle the email. From my configuration here, you'd probably want to number yours around 450 to go after aliases and before the routers that handle local users like hubusers
and procmail
.
After adding these files to the transport and router directories, you will need to run update-exim4.conf
to have Debian create the configuration file exim actually reads.
Best Answer
Checkout the config parameter user_relay to set the catchall user. And to not block non-existing users
local_recipient_maps
must me empty. So in your case: