Monday, October 14, 2024

How to Create Email Server on VPS

Setting up your own email server can provide you with greater flexibility and control over your email system compared to using a third-party service. This is especially beneficial for businesses that need to host a large number of email accounts.

This article will guide you through the process of creating an email server on a Hostinger VPS using the CyberPanel control panel.

Benefits of Setting Up Your Own Email Server

There are several advantages to hosting your own email server compared to relying on external services, including:

  • Flexible configuration: You can select the Mail Transfer Agent (MTA), configure your email server software, and customize its features according to your preferences. This level of control is often restricted with third-party providers, who typically offer pre-configured packages with limited customization options.

  • Data privacy: A VPS provides an isolated environment for each account, preventing other users from accessing your data. This ensures greater privacy for your email server.

  • Reputation: Free email providers usually don't offer dedicated IP addresses. This can affect your email deliverability rate, as your emails might be flagged as spam if other services on the same server have been marked as spam senders.

  • Cost efficiency: While email hosting services might be cheaper in the short term, self-hosted servers can accommodate more email accounts and offer more storage space.

  • Scalability: You can customize your own email server's hardware and set up load balancers, allowing you to scale the system as needed. In contrast, email hosting providers typically offer limited packages with fixed resources.

  • Security: A self-hosted and properly configured server can be more secure because you can implement any security measures and firewall rules based on your specific needs.

How to Set Up an Email Server on a VPS

Setting up an email server on a VPS involves several steps:

  1. Choose the Right VPS Package

While you can technically host your email service on your personal computer, managing it will require more time and effort. Additionally, you'll need server-grade hardware to run it 24/7, which can significantly increase the total cost.

Hosting your email using a VPS is easier because the provider handles the hardware setup and management for you. This makes it more cost-effective and provides various features that simplify the email server configuration process.

When choosing the best VPS hosting package for your needs, consider factors like:

  • Resources: Your VPS package should offer sufficient bandwidth, storage, and computing power to host your email service.

  • Reliability and uptime: Ideally, your VPS hosting package should have a high uptime guarantee to ensure your email service is always available.

  • Dedicated IP: A dedicated IP address isolates your email service from other users, improving security and deliverability.

  • Management tools: Management tools like graphical control panels and one-click installers can simplify email server maintenance and configuration.

Hostinger offers four VPS packages starting from $7.99 per month, with a 30-day money-back guarantee. They utilize advanced hardware and network infrastructure to ensure a 99.9% uptime for your business emails.

All Hostinger VPS hosting packages include a dedicated IP address to enhance email delivery and reputation. Additionally, users can configure various operating systems and control panels with a single click through hPanel.

Hostinger also provides Kodee, an AI VPS assistant to help resolve server issues using simple prompts. For instance, ask, "I have configured my domain using custom nameservers, but the domain isn't being propagated. What's the issue and how do I fix it?", and the tool will guide you through the solution.

  1. Start Your VPS Setup

After purchasing a VPS package, select "VPS" from the top menu in your hPanel and choose your new server. Complete the setup process by entering the hostname, choosing the server location, and selecting an operating system.

For this tutorial, we'll use AlmaLinux 8 with CyberPanel. You can change the operating system at any time by following these steps:

  • Log in to your hPanel and open "VPS" in the sidebar menu, then select your server.

  • In the sidebar, navigate to "Settings" → "OS & Panel" → "Operating System."

  • Choose "OS with Control Panel."

  • From the dropdown menu, select "AlmaLinux 8 with CyberPanel."

  • Click "Change OS."

Note: Changing the operating system and control panel of your VPS will erase all your data. It's highly recommended to create a backup before proceeding.

If you prefer another Linux distribution, install CyberPanel using commands. To do this, connect to your remote server using an SSH client like PuTTY.

Enter your SSH login credentials, which you can find in the "SSH Access" tab under your VPS summary in hPanel. Run the following command to initiate the installation wizard and follow the instructions:

      sh <(curl https://cyberpanel.net/install.sh || wget -O - https://cyberpanel.net/install.sh)
    
  1. Point Your Domain to the Email Server

After setting up your VPS, obtain a domain from Hostinger. Open your hPanel and follow these steps to point it to your outgoing mail server:

  • Navigate to "Domains" from the top menu.

  • Select the domain you want to configure.

  • Find "DNS/Nameserver" in the sidebar → "Child Nameserver."

  • Name your child nameservers. For simplicity, we'll call them "ns1.domain.tld" and "ns2.domain.tld."

  • Enter your VPS's IP address. You can find this information in the "VPS Summary" menu. Then, press both "Save" buttons.

Now, go to the "DNS Record" tab.

  • Under the "Nameserver" section, click "Change nameserver."

  • Choose "Change nameserver" and enter the two child nameservers you created. Leave the other fields blank.

  • Click "Save" to apply the changes.

Wait for the propagation process to complete, which can take up to 24 hours.

Note that after this, your domain might still not point to some DNS records. Don't worry; we'll configure them in CyberPanel later.

  1. Create a Website Container

When creating a mail server in a CyberPanel VPS, you need to create an empty website as a container. This step is crucial for linking the domain and DNS configurations.

To do this, enter "https://your_vps_ip:8090" in your web browser to access CyberPanel. Alternatively, click the panel access link in the "Operating System" menu in your hPanel.

Enter your admin username and password to log in. If you forget your credentials, reset them through the "Operating System" menu. On the CyberPanel dashboard, follow these steps:

  • Go to "Websites" → "Create Website."

  • Select "Default" from the "Select Package" dropdown menu.

  • Choose "admin" as the "Owner."

  • Slide the "Test Domain" button to inactive, then enter your domain name without "www."

  • Enter your email address. This account will be used for email server administration.

  • Select a PHP version, ideally the latest one.

  • Check the "DKIM Support" box. This option enhances your email security, prevents spoofing, and ensures smoother delivery.

  • Click "Create Website" to complete the process.

Important: When accessing CyberPanel for the first time, your web browser might display a security warning about the website. You can ignore this warning and proceed to the login page.

  1. Create Nameservers in CyberPanel

Next, you need to create nameservers in CyberPanel to connect the email service to your domain. Here's how:

  • On the CyberPanel dashboard, navigate to "DNS" → "Create Nameserver."

  • Enter your child nameserver and your VPS's IP address in the appropriate fields.

  • Select "Create Nameserver."

CyberPanel will generate all the DNS records, including MX, which enable your server to receive and send emails. Verify these records through the "DNS" → "Add/Delete record" section.

After that, go to "Email" → "DKIM Manager" and select your website from the list. Ensure your domain has a pair of public and private keys. If not, email providers like Gmail might flag your messages as spam.

Wait for the propagation to complete before creating email accounts. Use an online DNS checker tool to see if all records appear, then move on to the next step.

  1. Enable SSL Certificate for Your Domain

A Secure Sockets Layer (SSL) certificate will enable encryption to improve your mail server's security. CyberPanel provides unlimited free Let's Encrypt SSL that you can activate through the control panel dashboard.

To do this, go to "SSL" → "MailServer SSL." Choose your domain from the dropdown menu, then click "Issue SSL." The process might take a few minutes.

  1. Set Up Reverse DNS for Your VPS

Setting up reverse DNS helps improve message deliverability. This allows other email servers like Gmail and Yahoo to trace back your server's IP address using your domain, bypassing spam filters.

Hostinger users can configure reverse DNS using PTR records through their hPanel. Here's how:

  • In your hPanel, click "VPS" in the top menu bar.

  • Select the VPS in question, then click "Settings" in the sidebar.

  • Go to the "IP Address" tab → "Set up PTR record."

  • Enter your domain name and click "Save."

Wait for the propagation process to complete. To check if your VPS IP address is linked to the correct domain, run the following command in your Terminal:

      dig -x ip_address
    
  1. Create Email Accounts

Once your server and domain are ready, it's time to create email addresses. Open your CyberPanel dashboard, then navigate to "Email" → "Create Email."

Select your domain from the dropdown menu. Enter your email address and password, then click "Create Email."

To view all your email accounts, go to the "Email" → "List Emails" section in the sidebar. This menu also shows the SMTP and POP3/IMAP server configurations for setting up email clients like Thunderbird.

Integrating your email server's SMTP with your email service will help improve delivery and security.

  1. Test Your New Email Server

After completing the above steps, you need to test if your server is working as expected by sending an email message. Here's how to do it using CyberPanel's built-in Webmail client:

  • In your CyberPanel dashboard, go to "Email" → "Access Webmail."

  • You'll be redirected to the email client dashboard. Enter your login credentials, then press Enter.

  • Click the "New" button in the top left corner to create a new email.

  • Compose a test email and send it to another account.

  • Open the recipient's inbox to check if your mail server successfully delivered the message.

Alternatively, change the email message destination to your server's inbox to check if your server receives it.

Useful Tips:

  • For mobile devices, change the Webmail view by enabling "Mobile version" in your account settings.

  • Additionally, test your email server's spam score. To do this, use online tools like Mail Tester, which will assess your email delivery capabilities from the recipient server's perspective.

  • When using this tool, ensure your test email is long enough and doesn't contain words like "test." Spam filters might misinterpret these, negatively impacting your spam score.

  • Afterward, review the report details to identify suggested areas for improvement, such as configuring spam protection software. You can also use our AI VPS assistant to help identify late delivery issues and their solutions.

Conclusion

By setting up your own mail server on a VPS, you gain greater flexibility to customize various aspects of your email configuration.

These servers also offer higher performance, storage, and scalability compared to external providers. These benefits will be particularly useful for businesses that need to host a large number of accounts.

In this tutorial, we've outlined the steps for setting up an email server with your own domain on a VPS. Here's a summary:

  • Get a VPS hosting package. Purchase a VPS hosting package that offers a dedicated IP address, control panel support, and high uptime guarantees, like those provided by Hostinger.

  • Complete your VPS setup. Choose a data center location, set your root password, and install the AlmaLinux 8 with CyberPanel template through hPanel.

  • Point your domain. Create child nameservers that point to your VPS's IP address and configure your domain.

  • Create a website container. Open the CyberPanel dashboard, then go to the "Website" menu to create a new empty website.

  • Create nameservers in CyberPanel. Create the nameservers "ns1.domain.tld" and "ns2.domain.tld" through the "DNS" menu in CyberPanel.

  • Enable SSL certificate. Go to the "SSL" section in CyberPanel and install a free Let's Encrypt SSL certificate to enhance your email hosting security.

  • Set up reverse DNS. Open your hPanel and add your domain as a reverse PTR record for your VPS's IP address.

  • Create email accounts. Go to the "Email" section in the CyberPanel dashboard and create new email accounts.

  • Test your email server. Go to the "Access Webmail" menu, then log in to your new account. Send a test email to another inbox and check the delivery rate using tools like Mail Tester.

Remember that the process might vary depending on your hosting provider and server requirements. If you have any questions, feel free to leave a comment below! Good luck!

0 comments:

Post a Comment