# How to redirect all mail to one user in Postfix

To redirect all incoming mail to one user in Postfix, you can use the virtual alias map feature. This allows you to define a mapping for all incoming emails to be redirected to a specific user or email address. Here's how you can do it:

### 1. **Edit the Postfix Virtual Alias Map Configuration**

Open the Postfix main configuration file in your preferred text editor. The location of this file can vary depending on your system, but it's typically located at `/etc/postfix/main.cf`. You may need superuser privileges to edit this file, so use `sudo` or `su` if necessary.

```bash
sudo nano /etc/postfix/main.cf

```

### 2. **Add or Modify the Virtual Alias Map Configuration**

Add the following lines at the end of the `main.cf` file to specify the redirection:

```
virtual_alias_maps = hash:/etc/postfix/virtual

```

This line tells Postfix to use the `/etc/postfix/virtual` file as the source of virtual alias mappings.

### 3. **Create or Edit the Virtual Alias File**

Next, create or edit the virtual alias file (`/etc/postfix/virtual`). In this file, specify the email address you want to redirect and the target email address to which you want to redirect the mail. For example:

```
user@example.com   redirect@example.com

```

This means that all emails sent to `user@example.com` will be redirected to `redirect@example.com`.

### 4. **Create the Hash Table for Virtual Alias Maps**

After editing the virtual alias file, you need to create a hash table to make Postfix use the virtual alias mappings. Run the following command to build the hash table:

```bash
sudo postmap /etc/postfix/virtual

```

### 5. **Reload Postfix**

To apply the changes, reload the Postfix configuration:

```bash
sudo postfix reload

```

### **Test the Configuration**

Send an email to the email address you specified in step 3 (`user@example.com` in the example). It should be redirected to the target email address (`redirect@example.com`).

Please replace the example email addresses with your actual addresses. This configuration will redirect all incoming emails to the specified user or email address.