XAMPP+hMailServer+Roundcube builds a mailbox system on Windows Server


Under the premise of owning a domain name and server, build an email service on the Windows Server operating system based on XAMPP+hMailServer+Roundcube!

Preface

XAMPP: XAMPP is a free and easy-to-install integrated development environment (IDE) for developing and testing web applications locally. It includes the Apache server, MySQL database, PHP and Perl interpreters, and other commonly used development tools and components. XAMPP provides a complete development environment that enables developers to develop, test, and debug web applications locally.

hMailServer: hMailServer is a free open source mail server software used to provide mail services on Windows platforms. It supports SMTP, POP3, and IMAP protocols and provides functionality to manage and configure email accounts, domain names, and mail routing. hMailServer can be used to build your own mail server for sending and receiving emails.

Roundcube: Roundcube is a web-based mail client for accessing and managing email. It provides an intuitive and easy-to-use interface that allows users to send, receive and organize emails through a web browser. Roundcube supports multiple email protocols, including IMAP and SMTP, and can be integrated with different email servers. It has powerful functions for searching, filtering and organizing emails, and supports multi-language interface and plug-in extensions.

In summary, XAMPP is a development environment for developing and testing Web applications locally; hMailServer is a mail server software for building your own mail server; Roundcube is a Web mail client for accessing and Manage email. The three can be used in combination, for example, building a web application in a local development environment, using hMailServer to provide email services, and using Roundcube as the email client for email access and management.


1. Domain name


1. Purchase a domain name on Tencent Cloud: https://console.cloud.tencent.com/domain. Suppose you have a domain name: 1234.com.

2. Add resolution to the domain name, add A record and MX record, where 1.2.3.4 is the server IP in the second step.

Insert image description here


2. Server


1. Purchase a server on Tencent Cloud: https://console.cloud.tencent.com/lighthouse, select the Window Server operating system here. Suppose you have a server with IP 1.2.3.4.


2. Click Manage Rules in the server details, add a record, and open port 25.



3. Click Manage Domain Name in the server details and add two records so that the domain names are directly connected to port 80 of the server.


3. Log in to the server


1. Find the server administrator account and password in the site information on Tencent Cloud.


2. Connect to the server using Remote Desktop.


3. All subsequent operations are performed on the server.


4. Install XAMPP


1. Go to the XAMPP official website to download: https://www.apachefriends.org/, follow the instructions of the installer to install, and choose to install Apache, MySQL and PHP.

2. After the installation is complete, start the XAMPP control panel, then start the Apache and MySQL services to ensure that they are running normally.


5. Install hMailServer


1. Go to hMailServer official website to download: https://www.hmailserver.com/download, and install it step by step according to the instructions of the installation program.

2. Select an external database engine during the installation process.


3. You also need to set the hMailServer administrator password during the process. Set it yourself and remember it.


4. Then proceed to the database settings, select the first item, and create a database.
Insert image description here

5. Select MySQL as the database type.


6. Configure the database connection as shown below. The database connected is XAMPP. There is no password by default.


7. If you are prompted that libmysql.dll is missing, go to the official MySQL website https://downloads.mysql.com/archives/c-c/ to download mysql-connector-c-6.1.11-win32.zip and decompress libmysql. dll to the bin directory of hMailServer, click Next again to install successfully.




8. Click hMailAdmin.exe to open the management page. In the left navigation bar, select "Domains", right-click and select "Add..." to add a new domain name, such as 1234.com. Add an email account under "Accounts" and set a username and password, such as username [email protected] and password 1234.


6. Install Roundcube


1. Go to the official Roundcube website to download the full version of the compressed package: https://roundcube.net/download/. The latest version is 1.6.2.

2. Extract the compressed package to the XAMPP deployment directory C:\xampp\htdocs, and rename the folder to webmail.

3. Click the Admin button of MySQL in the XAMPP program to enter the database management page, add the database webmail in it, and import the sql file to initialize the database.




4. Enter the config folder of webmail, copy config.inc.php.sample and name it config.inc.php, and use Notepad to open config.inc.php.



5. Modify the config.inc.php configuration file.
Configure the following:

$config['db_dsnw'] = 'mysql://roundcube:pass@localhost/roundcubemail';

change to:

$config['db_dsnw'] = 'mysql://root:@localhost/webmail';

7. Add SSL/TLS certificate


1. Use Certbot to obtain Let’s Encrypt’s SSL/TLS certificate. You can download and install the Windows version of the installation package through the official website https://certbot.eff.org/. The default installation directory is C:\Program Files\Certbot.


2. Open CMD and enter the following command, and then follow the prompts to gradually complete the certificate installation. During this period, you need to enter the domain name 1234.com and www.1234.com, and also enter the location of webroot, which is the web root directory: C:\xampp\htdocs\ webmail.

cd C:\Program Files\Certbot\bin
certbot certonly --webroot

The location where the certificate is generated is generally:
C:\Certbot\live\1234.com\fullchain.pem
C:\Certbot\live \1234.com\privkey.pem


3. Modify Apache's httpd-vhosts.conf file. The file is in C:\xampp\apache\conf\extra. Completely modify it to the following content and save it.

<VirtualHost *:80>
    ServerName 1234.com
    ServerAlias  www.1234.com
    DocumentRoot "C:\xampp\htdocs\webmail"
    Redirect permanent / https://www.1234.com/
</VirtualHost>

<VirtualHost *:443>
    ServerName 1234.com
    ServerAlias  www.1234.com
    DocumentRoot "C:\xampp\htdocs\webmail"
    SSLEngine on
    SSLCertificateKeyFile "C:\Certbot\live\1234.com\privkey.pem"
    SSLCertificateFile "C:\Certbot\live\1234.com\fullchain.pem"
</VirtualHost>

8. Log in to your email


1. Restart Apache and MySQL in the XAMPP program.

2. Enter https://1234.com or https://www.1234.com in the browser to enter the login page, and then use the email account created in hMailServer to log in to the email.




hint


  1. When setting up an email system, for security reasons, be sure to set a strong password for the database.
  2. This method is suitable for setting up a development environment to facilitate development, debugging and testing, but is not suitable for real production environments.
  3. Use Flask to quickly write an admin page to call the hMailServer application interface to add, delete, modify and check mailboxes. You need to cooperate with Apache reverse proxy.
  4. Domestic cloud server providers basically block the export of port 25, so the system can only be used to receive letters. If you want to send letters, you must apply to the provider to unblock port 25.

This ends the tutorial

Please feel free to point out any errors or improvements!

Guess you like

Origin blog.csdn.net/embracestar/article/details/131750110