This is the second part of a 2 series tutorial to setup action mailbox with postfix. In this part, we will configure postfix in production server to forward incoming emails to our rails app so action mailbox can process it. If you haven't read the first part where we setup action mailbox and test it in development, you can read it here You should have Postfix configured in production server (same server as your rails app) Existing app built with rails 6 Ruby with rbenv setup Patience Steps Login to your production server first and then; Step 1: Create bash script Create a script inside to forward all incoming emails to our rails app /usr/local/bin/ shell $ nano email_forwarder.sh Add following to the script shell export HOME=YOUR_HOME_PATH export PATH=YOUR_PATH export RBENV_ROOT=YOUR_RBENV_PATH cd /path/to/your/project && bin/rails action_mailbox:ingress:postfix URL='https://truemark.com.np/rails/action_mailbox/relay/inbound_emails' INGRESS_PASSWORD='YOUR_INGRESS_PASSWORD' # !/bin/sh Replace value of , , , and as described below: HOME PATH RBENV_ROOT URL INGRESS_PASSWORD Copy your home directory for HOME and copy what you get from command cd pwd shell $ cd $ pwd Copy what you get from and command for and respectively $PATH which rbenv PATH RBENV_PATH shell $ $PATH $ rbenv which Copy the password you added to or your | file for credentials ENV application.yml INGRESS_PASSWORD For , if your application lived at , the full command would look like this: URL https://example.com bin/rails action_mailbox:ingress:postfix =https://example.com/rails/action_mailbox/relay/inbound_emails =YOUR_STRONG_PASSWORD URL INGRESS_PASSWORD Step 2: Configure Postfix to Pipe Incoming emails to script We will follow steps as described . here Create to add a catch-all alias; needs to be an existing local user: /etc/postfix/virtual_aliases localuser .tld localuser .tld file # /etc/postfix/virtual_aliases @mydomain @mydomain Create `/etc/postfix/transport` to add a transport mapping. "forward_to_rails" can be whatever you want; it will be used later in `master.cf` mydomain.tld forward_to_rails: file # /etc/postfix/transport Next, both transport and virtual_aliases need to be compiled into berkeley db files: shell $ sudo postmap /etc/postfix/virtual_aliases $ sudo postmap /etc/postfix/transport Add the transport to /etc/postfix/master.cf file forward_to_rails unix - n n - - pipe =Xhq =deploy:deploy =/usr/local/bin/email_forwarder.sh # /etc/postfix/master.cf flags user argv ${nexthop} ${user} We should specify so script is run by that user and not postfix or nobody. user user=deploy:deploy` ~ `user=user:group Add following in /etc/postfix/main.cf file transport_maps = hash: virtual_ _maps = hash: # /etc/postfix/main.cf /etc/postfix/transport alias /etc/postfix/virtual_aliases You can view postfix log with tail / / /mail. -f var log log You must have everything now to receive email in your rails app. Test it with any of your email provider; just send the email to and check if it is being received in the log. If you have any comments or suggestions, please let me know in comments below. email@your-configured-domain.com References https://guides.rubyonrails.org/action_mailbox_basics.html https://serverfault.com/questions/258469/how-to-configure-postfix-to-pipe-all-incoming-email-to-a-script Previously published at https://thedevpost.com/blog/setup-action-mailbox-with-postfix-part-2/