Menu
User

DropVPS Team

Writer: Cooper Reagan

How to Set Up Email Forwarding on VPS Servers

How to Set Up Email Forwarding on VPS Servers

Publication Date

01/14/2025

Category

Articles

Reading Time

4 Min

Table of Contents

Email aliases are used to forward incoming emails from one address to another. By setting up email aliases on your VPS, you can route emails sent to different addresses to a single inbox or redirect them to other users. The process of setting up email aliases is straightforward, and Postfix, as a common mail server, provides an easy way to configure them.

Here’s how you can set up email aliases for forwarding:

Edit the Aliases File

To configure email aliases, you need to modify the aliases file on your VPS.

  • Open the aliases file: Use a text editor to open the /etc/aliases file:
    sudo nano /etc/aliases

Add Aliases

Inside the aliases file, you can create forwarding rules by adding alias entries. Each line in the file defines an alias in the format:

aliasname: [email protected]

For example:

info: [email protected]
support: [email protected]

In this case, any email sent to [email protected] will be forwarded to [email protected], and emails to [email protected] will go to [email protected].

Rebuild the Aliases Database

After adding the necessary aliases, rebuild the aliases database to apply the changes.

  • Run the following command:
    sudo newaliases

    This command updates the alias database so that Postfix can recognize the new forwarding rules.

Test the Aliases

Once the aliases are set up, test them by sending emails to the alias addresses you created. Ensure that emails are forwarded to the correct destination.

Optional: Advanced Aliasing Features

Postfix also supports advanced aliasing features such as the use of wildcards and including multiple recipients. For example, you can forward emails to multiple recipients like this:

This way, both [email protected] and [email protected] will receive emails sent to [email protected].

Configuring DNS for Proper Email Forwarding

Configuring DNS (Domain Name System) is essential for ensuring that email forwarding works correctly on your VPS. Proper DNS settings ensure that emails are routed to the correct mail server for your domain, and they help prevent your forwarded emails from being marked as spam. Below are the key DNS settings you need to configure for proper email forwarding:

1. Set Up MX Records

MX (Mail Exchange) records tell the world which mail servers are responsible for receiving emails for your domain. Without correct MX records, email forwarding won’t function properly.

  • How to configure MX records: Log in to your domain registrar’s control panel and find the DNS settings for your domain. Add or update the following MX records:
    MX Record: mail.yourdomain.com
    Priority: 10

    Replace yourdomain.com with your actual domain name. If you are using an external email service, they will provide the necessary MX records.

2. Add SPF Records

SPF (Sender Policy Framework) records help prevent your domain from being used in email spoofing attacks. Adding an SPF record ensures that only authorized mail servers can send emails on behalf of your domain, improving the deliverability of forwarded emails.

  • How to configure SPF records: In your DNS settings, add an SPF record as follows:
    v=spf1 include:_spf.yourdomain.com ~all

    This SPF record ensures that only your authorized mail servers can send emails for your domain.

3. Set Up DKIM for Email Authentication

DKIM (DomainKeys Identified Mail) adds a digital signature to your emails, which helps verify that the email has not been altered during transmission and that it was sent by an authorized server. Setting up DKIM is highly recommended for improving email deliverability.

  • How to configure DKIM: If you are using Postfix, you can install a DKIM signing tool (e.g., opendkim) and configure it with your domain’s public and private keys. Your hosting provider or mail service may offer automated DKIM setup.

4. Add DMARC Records for Reporting and Protection

DMARC (Domain-based Message Authentication, Reporting & Conformance) records provide a way to protect your domain from email spoofing and phishing. It also enables you to receive reports about email activities related to your domain.

  • How to configure DMARC records: In your DNS settings, add a DMARC record like this:
    _dmarc.yourdomain.com. IN TXT "v=DMARC1; p=none; rua=mailto:[email protected]"

    Replace yourdomain.com with your actual domain name and email address for receiving DMARC reports.

5. Test Your DNS Settings

Once your DNS records are configured, it’s important to verify that they are set up correctly. You can use tools like MXToolbox to check your MX, SPF, DKIM, and DMARC records and ensure that email forwarding is set up properly.

Linux VPS
U
Loading...

Related Posts