0

I am fairly new to Postfix, Dovecot and have only basic knowledge of mail routing.

There is a server that supposed to receive emails for variety of mailboxes with unlimited domains. (info@example.com, joe@blah.com, support@example.com, shmoe@foo.com - thousands of them.) I need to handle only few emails as regular IMAP boxes, the rest of emails must be handled by php script, actually forwarded to real mailbox hosted by 3rd party.

So info@example.com handled as regular mailbox, stored locally, IMAP, but joe@shmoe.com forwarded to joeshmoe@gmail.com.

Dont really understand how to implement such logic. Maybe I can use Postfix + Mysql with list of mailboxes to forward? List is dynamic

Or maybe some opposite arrangement: incoming emails first handled by php script and some piped to Postfix?

Need some help here..

  • 2
    Have you tried reading Postfix Virtual Domain Hosting Howto? – AlexD Jul 11 '18 at 18:39
1

If the only thing your php script would do is mail forwarding you don't need it at all. You can achieve the same with standard postfix functionality.

The mentioned Virtual Domain Hosting Howto is here http://www.postfix.org/VIRTUAL_README.html

You can find there a paragraph specifically about mail forwarding. What you basically do is you create a file with lines like this:

joe@example.com        joe@somewhere

the first column is the local mailbox and the second one is the email where you forward to.

If you need to deliver emails to a php script (or any other program) there is a similar way of doing it with a | character (but via aliases not virtual map - thanks for the comment) - look into "mailing list" section in the same document.

listname: "|/some/where/majordomo/wrapper ..."

Instead of files you can use MySQL as well - see http://www.postfix.org/MYSQL_README.html

  • Please, consider that (quoting your same source): "There is one major limitation: virtual aliases and virtual mailboxes can't directly deliver to mailing list managers such as majordomo.". So, even if it's definitely feasible, as stated there, you cannot simply/direcly "expand" a (sort of) alias to an executable, but you're forced to step through some intermediate redirection. This, again, when dealing with Virtual Delivery --like in your case. – Damiano Verzulli Jul 12 '18 at 5:33
  • Thanks for the comment, I am aware of that and I did not want to go to too much detail and copy&paste the docs, but it is probably worth to at least mention it for clarification – Petr Chloupek Jul 12 '18 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.