How to forward postfix mails to squirrelmaildirecotry

To forward Postfix emails to a SquirrelMail directory, you'll need to configure Postfix to deliver emails to a pipe command that will then forward the emails to the SquirrelMail directory. Here's a step-by-step guide:

Prerequisites:

  1. Postfix is installed and running on your system.
  2. SquirrelMail is installed and configured on your system.
  3. You have a SquirrelMail directory set up, e.g., /var/www/squirrelmail.

Step 1: Create a new Postfix alias

Create a new file in the /etc/postfix/aliases directory (or the equivalent directory on your system) with a name like squirrelmail (e.g., /etc/postfix/aliases/squirrelmail).

Add the following line to the file:

squirrelmail: "| /usr/bin/procmail -f-"

This creates a new alias called squirrelmail that will forward emails to a pipe command.

Step 2: Configure Procmail

Create a new file in the /etc/procmailrc directory (or the equivalent directory on your system) with a name like squirrelmail (e.g., /etc/procmailrc/squirrelmail).

Add the following lines to the file:

:0 h
* ^To: squirrelmail
| /usr/bin/squirrelmail -f /var/www/squirrelmail

This configuration tells Procmail to:

Step 3: Update Postfix configuration

Update the Postfix configuration to use the new alias and Procmail configuration. Run the following command:

postmap /etc/postfix/aliases

This updates the Postfix alias database.

Step 4: Restart Postfix

Restart the Postfix service to apply the changes:

service postfix restart

Step 5: Test the setup

Send an email to the squirrelmail address (e.g., [email protected]). The email should be delivered to the SquirrelMail directory.

That's it! With these steps, you should now be able to forward emails to a SquirrelMail directory using Postfix and Procmail.