I'm trying to set my company server up to be able to receive emails to a certain account on a subdomain of our main domain i.e.: [email protected]
Those incoming mailers should trigger a php script that will handle some content processing.
I'm running Ubuntu Server 20.0.4, Postfix is installed, Dovecot is installed, I also tried using courier so that's there too, but I couldn't get that going
I've gotten this far:
- I created a linux user and configured postfix to use local accounts as valid mailboxes
- I configured postfix to accept incoming mail at subdomain.domain.com
- I added the A and MX records for the subdomain to properly route in google domains
- I configured SSL on the subdomain (confirmed working properly in ssllabs and through apache when navigating to said subdomain)
- I added some additional configuration to /etc/postfix/master.cf for triggering the php script (right now just a test script/placeholder):
smtp inet n - - - - smtpd
-o content_filter=myhook:dummy
...
# PHP SCRIPT HOOK
myhook unix - n n - - pipe
flags=F user=www-data argv=/path/to/script/MailParser.php ${sender} ${size} ${recipient}
The MailParser.php script just triggers a write to a log file saying "Successfully got the incoming mail at timestamp
"
If I send a mail through smtper.net with these settings
It successfully triggers the script to write to the log and I can see the "test" message from smtper.net in the user's system mail, so all seems good there.
If I try to send the mail through a normal email client such as my gmail account however, I get a bounce back undeliverable with error:
550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces. Learn more at https://support.google.com/mail/?p=NoSuchUser f16si1842833plj.1 - gsmtp
I'm stuck at this point.