Home MiscellaneousSetting Up a Mail Server on Your RunCloud Servers

Setting Up a Mail Server on Your RunCloud Servers

by SupportPRO Admin

By default, RunCloud does not come with email services. However, you can set up an email service on your RunCloud server yourself.

Although RunCloud does not provide an email service out of the box, Postfix is already installed once you connect your server to RunCloud. Postfix is a popular, highly configurable mail transfer agent (MTA) that is free and open-source.

Let’s walk through the steps to set up a mail server on your RunCloud server:

Prerequisites :

  • 1.  Ensure your server is configured with a fully qualified domain name (FQDN).
  • 2. You will need a non-root user with sudo privileges.
  • 3. Make sure you have added MX and A records for the FQDN of your server.

Configuring Postfix :

Since Postfix is already installed on your server, you can begin configuring the mail server. To do this, log in as a sudo user and use the following command:

sudo dpkg-reconfigure postfix

Configuration Steps:

  • When prompted, choose “Internet Site” as the mail configuration type.
  • Enter your domain name as the system mail name.
  • On the next screen, specify the destinations to accept mail.

For the additional options, you can provide the following settings:

l Force synchronous updates on mail queue: No

l Mailbox size limit (bytes): 0

l Local address extension character: +

l Internet protocol to use: All

Testing the Mail Server:

Once the mail server is set up, you can verify that the server is connected to port 25 by using the following command:

telnet gmail-smtp-in.l.google.com 25

 To test the mail service, you can use applications such as mailutils. Run the following command to send a test email:

/usr/sbin/sendmail youremailaddress

Check your email inbox/spam to confirm if the email was received successfully.

Important Notes:  Make sure to open ports 25, 465, and 587 in both your server and external firewalls for the mail service to function properly.

How to send mails through PHP files:

There are multiple ways to send emails from PHP. Here, we explore how to do this using the mail() function, which is a PHP function used for sending emails.

1. Install Dependencies for Sending Emails

sudo apt update && sudo apt install mailutils sendmail-base

2. Update the sendmail_path in php.ini

update the php.ini file for the corresponding PHP version to specify the sendmail path. If your PHP version for the web app is 7.4, the php.ini file will be located at /etc/php74rc/php.ini.

Search for the sendmail_path option and update its value to:

sendmail_path = /usr/sbin/sendmail -t -i

After making the change, restart the corresponding service:

systemctl restart php74rc-fpm

3. Configure Sendmail :

To configure Sendmail, you can simply run the following command:

sendmailconfig

You can update the values by entering the necessary details. If you do not wish to make any changes, you can proceed with the default values.

4. Create a mail.php file

For testing purposes, create a mail.php file with the following code:

<?php

$to = ‘recepientaddress@gmail.com’; // Recipient’s email address

 $subject = ‘Test Email from Postfix’;

 $message = ‘Hello, this is a test email sent using Postfix and PHP.’;

 $headers = ‘From: sender@yourdomain.com’;

 if(mail($to, $subject, $message, $headers)) {

     echo “Email sent successfully!”;

     } else {

         echo “Failed to send email.”;

         }

         ?>

You can place this file under the public directory of any web application you wish to test.

5.Set Correct Permissions

Once the file is created, ensure that the correct permissions and ownership are set for the corresponding file.

For testing purposes, you can access the file by visiting domainname/email.php.Check your inbox or spam folder to verify if the email was received successfully.

How to send mails from wordpress through plugins :

You can easily send emails from your WordPress website by using plugins like WP Mail SMTP. Follow these steps to set it up:

1. Install the Plugin

Start by installing the WP Mail SMTP plugin from your WordPress dashboard.

2. Configure the Plugin

After the plugin is installed, head to the plugin’s settings page by going to WP Mail SMTP » Settings, then click on the Launch Setup Wizard to begin the configuration.

3. Complete the Setup Wizard

Follow the on-screen instructions in the Setup Wizard. Once you finish the setup, the plugin will verify the configuration. If everything is correctly set up, you’ll see a success message.

4. Test Email

To ensure that the plugin is working, go to WP Mail SMTP » Tools » Email Test and click the Send Email button to check if the emails are being sent successfully.

Still having trouble or need some help? Don’t hesitate to reach out – we’re here to assist you every step of the way!!!

Facing issues?

Our technical support
engineers can solve it.

Contact Us today!
guy server checkup

You may also like

Leave a Comment