Linux mail forward

A classic topic!

In Linux, you can forward emails using various methods. Here are a few:

1. Using procmail

procmail is a powerful mail processing tool that allows you to forward emails based on various conditions. You can install it on most Linux distributions.

Create a .procmailrc file in your home directory with the following content:

:0
* ^To: [email protected]
! [email protected]

This will forward all emails addressed to [email protected] to [email protected].

2. Using msmtp

msmtp is a simple mail forwarder that can be used to forward emails to another address.

Create a configuration file /etc/msmtprc (or ~/.msmtprc for a user-specific configuration) with the following content:

defaults
auth           on
host           smtp.gmail.com
port           587
from          [email protected]
to           [email protected]

Then, run msmtp -f /etc/msmtprc (or msmtp -f ~/.msmtprc for a user-specific configuration) to start the forwarder.

3. Using ssmtp

ssmtp is another simple mail forwarder that can be used to forward emails to another address.

Create a configuration file /etc/ssmtp.conf (or ~/.ssmtp.conf for a user-specific configuration) with the following content:

mailhub=smtp.gmail.com:587
[email protected]
AuthPass=your-password
FromLineOverride=YES
rewriteSubject=yes
rewriteBody=yes

Then, run ssmtp -v to start the forwarder.

4. Using a mail client

You can also forward emails using a mail client like mutt or alpine. For example, in mutt, you can set up a filter to forward emails using the following command:

set filter-hook = "To: [email protected]" "forward to [email protected]"

These are just a few examples of how you can forward emails in Linux. The specific method you choose will depend on your email setup and preferences.