Score:0

Mail server set up for inbound mail on a subdomain to trigger php script

cm flag

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.

anx avatar
fr flag
anx
Getting a Google-specific answer means the mail was sent to Google. I don't think this question is answerable without investigating the fully non-delivery notification / the MX records.
Score:0
cm flag

The issue turned out to be with the MX records as @anx pointed out. Additionally the SSL Certificate on the domain was not fully configured so that was also causing issues. Otherwise my local server configurations were set up correctly.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.