Skip to content

Install and configure a simple mail server for sending mails using PHP mail function in Faveo on Ubuntu 16.04 server

Arjunladybird edited this page May 7, 2018 · 3 revisions

Introduction

This document will list steps on how to install a simple mail server for Faveo.

We need following dependencies in order to make mail server work:

  • PHP 7.1
  • PHP Extensions: listed in server requirement
  • Composer

If you have installed composer already skip this step

Install Composer

curl -sS https://getcomposer.org/installer | php

mv composer.phar /usr/bin/composer

chmod +x /usr/bin/composer

Install PHP-Mailer

composer require phpmailer/phpmailer

Firewall Access

You will need to set your firewall(s) to allow access to the following ports:

  • SMTP: 25
  • POP3: 110
  • IMAP: 143
  • SMTP Secure: 465

By default, the Cloud Panel Firewall denies access to all but the most commonly-used ports. For instructions on how to allow port access, consult our article "Creating a Cloud Panel Firewall".

Install Postfix

sudo apt-get update

sudo apt-get install postfix

Configure Postfix

After the installation is complete, run the command to configure Postfix:

sudo dpkg-reconfigure postfix

Enter the following values at the prompts, replacing example.com with your own domain name. Use the up arrow and down arrow to move up and down to highlight answers, and Enter to select your answer.

Select OK to proceed

Choose Internet Site

System Mail Name: example.com

Root and postmaster mail recipient:root

Other destinations for mail: example.com, localhost.example.com, localhost

Force synchronous updates on mail queue?: No

Local networks: 127.0.0.0/8

Use procmail for local delivery?: No

Mailbox size limit (bytes): 0

Local address extension character: +

Internet protocols to use: all

After the initial Postfix configuration has been done, you can change Postfix settings with the command:

sudo postconf -e '[new setting]'

Restart Postfix

sudo systemctl restart postfix

Replace example.com with your own domain name:

sudo postconf -e 'myhostname = example.com'

Test Postfix With Telnet

To test Postfix we will telnet to the server and perform a basic "handshake protocol," just as an email program would. First, install Telnet:

sudo apt-get install telnet

Once Telnet is installed, use it to connect to the server's SMTP port:

telnet localhost 25

The server will respond with:

[user@localhost ~]$ telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 localhost.localdomain ESMTP Postfix (Ubuntu)
Start by telling the server who the mail is being sent from:

mail from: some-person@some-other-server.com

Then tell the server who you are sending mail to, replacing user@example.com with your own username and domain name:

rcpt to: root@example.com

Now add a simple message. Tell the server your message body starts here:

data

Type the message, then follow it with [Enter], a period ., and [Enter]:

hello world 
.

Close the session by typing quit and hitting Enter.

Installation and Upgrade Guide

Administrator's Guide

Agent's Guide

Email Integration

Release & Upgrade Notes

Known Issues

Contribute & Feedback

Knowledge Base

Third Party Integration

Plugins

API

Clone this wiki locally