How to Easily Set up a Full-Fledged Mail Server on Ubuntu 16.04 with iRedMail

Setting up your own mail server from scratch on Linux is complex and tedious, until you meet iRedMail. This tutorial is going to show you how you can easily and quickly set up a full-fledged mail server on Ubuntu 16.04 with iRedMail under 30 minutes.

What is iRedMail?

iRedMail is a shell script that automatically install and configure all necessary mail server components on your Linux/BSD server and thus eliminates manual installation and configuration. Supported OS are as follows:

  • RHEL/CentOS
  • Debian/Ubuntu
  • FreeBSD/OpenBSD

Open-source software used in iRedMail:

  • Postfix
  • Dovecot
  • Apache, Nginx
  • OpenLDAP, ldapd
  • MySQL/MariaDB, PostgreSQL
  • Amavised-new
  • SpamAssassin
  • ClamAV
  • Roundcube webmail
  • SOGo Groupware
  • Fail2ban
  • Awstats
  • iRedAPD

iRedMail features:

  • All components are open-source.
  • TLS is enabled by default. SMTP/IMAP over TLS, HTTPS webmail
  • Create as many virtual mailboxes as you want in a web-based admin panel.
  • Stores mail accounts in OpenLDAP, MySQL/MariaDB, or PostgreSQL.

It is recommended that you follow the instructions below on a clean install of Ubuntu 16.04 system that has at least 2GB of RAM, as after the installation your server will use more than 1GB of RAM. Don’t run this iRedMail server alongside your website or blog on the same machine, unless you are confident that you can restore the virtual host file for your website or blog, because the installation process will break your existing virtual hosts. If you need to do this on a VPS, then I recommend Linode, from which you can get a 2GB VPS for only 10 USD per month. Without further ado, let’s get started.

Before the Installation

First, make sure your server IP isn’t listed in any email blacklist. You can go to mxtoolbox.com and dnsbl.info to check your server IP address. If it’s in a blacklist, you can delete your VPS instance in Linode and create a new one. As Linode uses an hourly billing model, you won’t be charged by month, but by how many hours you used, which makes it convenient to delete a VPS instance.

Once you have a server with good IP reputation, SSH into your Ubuntu 16.04 server and update all software.

sudo apt update;sudo apt upgrade

Then set a fully qualified domain name (FQDN) for your server with the following command.

sudo hostnamectl set-hostname mail.your-domain.com

We also need to update /etc/hosts file.

sudo nano /etc/hosts

Edit it like below:

127.0.0.1       mail.your-domain.com localhost

Save and close the file. To see the changes, re-login and use the following command to see your hostname.

hostname -f

Don’t forget to set MX record and A record for your domain name. The MX record should point to your mail server’s FQDN,

Record Type    Name      Value

MX             @         mail.your-domain.com

The A record points to your mail server’s IP address.

Record Type    Name     Value

A              mail     IP-address-of-mail-server

If your server uses IPv6 address, be sure to add AAAA record.

Setting up a Mail Server on Ubuntu 16.04 with iRedMail

Next, download the iRedMail Bash installer with wget. At the time of writing, the latest version of iRedMail is 0.9.7, released on July 1, 2017. Please go to iRedMail download page (http://www.iredmail.org/download.html)  to check out the latest version.

wget https://bitbucket.org/zhb/iredmail/downloads/iRedMail-0.9.7.tar.bz2

Extract the tarball.

tar xvf iRedMail-0.9.7.tar.bz2

Then cd into the newly created directory.

cd iRedMail-0.9.7/

Add executable permission to the iRedMail.sh script.

chmod +x iRedMail.sh

Next, run the Bash script with sudo privilege.

sudo bash iRedMail.sh

The ncurse-based setup wizard will appear. Select Yes.

iredmail ubuntu 16.04

The next screen will ask you to select the mail storage path. You can use the default one /var/vmail.

iredmail ubuntu

Next, choose your preferred web server: Apache or Nginx. You need to use up and down arrow and press the spacebar to select.

iredmail installation

Then select the storage backend. Choose one that you are familiar with. This tutorial chose MariaDB.

iredmail server

If you selected MariaDB or MySQL, then you will need to set the MySQL root password.

iredmail ubuntu setup

Please note that if you selected MariaDB, then you don’t need password to log into MariaDB shell. Instead of running the normal command:

mysql -u root -p

you can run the following command to login, with sudo and without providing MariaDB root password. This is because MariaDB uses unix_socket authentication plugin, which allows users to use OS credentials to connect to MariaDB. But you still need to set root password in iRedMail setup wizard.

sudo mysql -u root

Next, enter your first mail domain. You can add multiple mail domains later in the web-based admin panel. This tutorial assumes that you want an email account like [email protected], in that case, you need to enter your-domain.com here, without sub-domain.

email server software

Next, set a password for the mail domain administrator.

install iredmail ubuntu

Choose optional components.

install iredmail server

Now you can review your configurations. Type Y to begin the installation of all mail server components.

install iredmail on ubuntu 16.04

At the end of installation, choose y to use firewall rules provided by iRedMail and restart firewall.

install iredmail server on ubuntu 16.04

Now iRedMail installation is complete. You will be notified the URL of webmail, SOGo groupware and web admin panel and the login credentials. The iRedMail.tips file contains important information about your iRedMail server.

********************************************************************
* URLs of installed web applications:
*
* - Roundcube webmail: httpS://mail.your-domain.com/mail/
* - SOGo groupware: httpS://mail.your-domain.com/SOGo/
*
* - Web admin panel (iRedAdmin): httpS://mail.your-domain.com/iredadmin/
*
* You can login to above links with below credential:
*
* - Username: [email protected]
* - Password: *********
*
*
********************************************************************
* Congratulations, mail server setup completed successfully. Please
* read below file for more information:
*
*   - /home/gourd/iRedMail-0.9.5-1/iRedMail.tips
*
* And it's sent to your mail account [email protected]
*
********************* WARNING **************************************
*
* Please reboot your system to enable all mail services.
*
********************************************************************

Reboot your Ubuntu 16.04 server.

sudo shutdown -r now

Once your server is back online, you can visit the web admin panel.

https://mail.your-domain.com/iredadmin/

Because it’s using a self-signed TLS certificate, so you need to add security exception. Login with the postmaster mail account.

iredmail web admin panel

In the Add tab, you can add multiple domains or mail users.

iredmail add mailboxes

After you create a user, you can visit the Roundcube webmail address and login with the new mail user account.

https://mail.your-domain.com/mail/

iredmail roundcube

And test email sending and receiving. Please note that you may need to wait for a few minutes to receive emails because greylisting is enabled by default. You can change password and create filter in RoundCube.

Installing Let’s Encrypt TLS Certificate

Since the mail server is using a self-signed TLS certificate, both desktop mail client users and webmail client users will see a warning. To fix this, we can obtain and install a free Let’s Encrypt TLS cert.

Obtaining the Certificate

First, install Let’s Encrypt (certbot) client on Ubuntu 16.04.

sudo apt install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install certbot

The Apache and Nginx configuration directories are heavily modified by iRedMail, so here I recommend using the webroot plugin, instead of using apache or nginx plugin, to obtain certificate. Run the following command. Replace red text with your actual data.

sudo certbot certonly --webroot --agree-tos --email your-email-address -d mail.your-domain.com -w /var/www/html/

You will see the following text indicating that you have successfully obtained a TLS certificate. Your certificate and chain have been saved at /etc/letsencrypt/live/mail.your-domain.com/ directory.

Let's encrypt free tls certificate

Installing the Certificate

After obtaining a TLS certificate, let’s configure web server to use it.

Apache

If you use Apache web server, then edit the default virtual host file.

sudo nano /etc/apache2/sites-available/000-default.conf

Add the following 3 lines above </VirtualHost>.

RewriteEngine on
RewriteCond %{SERVER_NAME} =mail.your-domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

The above 3 directives will redirect HTTP connection to HTTPS. The rewrite module needs to be enabled for them to work, which is achieved by executing the following command.

sudo a2enmod rewrite

Then edit the https version of the default virtual host.

sudo nano /etc/apache2/sites-available/default-ssl.conf

Find the following 2 lines.

SSLCertificateFile /etc/ssl/certs/iRedMail.crt
SSLCertificateKeyFile /etc/ssl/private/iRedMail.key

We need to replace the self-signed certificate with Let’s Encrypt issued certificate. So the above two lines need to be changed to the following.

SSLCertificateFile /etc/letsencrypt/live/mail.your-domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mail.your-domain.com/privkey.pem

Save and close the file. Then reload Apache web server.

sudo systemctl reload apache2

Now if you visit iRedMail admin panel or Roundcube webmail again, you shall see a green lock in the browser address bar.

Nginx

If you use Nginx, then edit the SSL template file.

sudo nano /etc/nginx/templates/ssl.tmpl

Find the following 2 lines.

ssl_certificate /etc/ssl/certs/iRedMail.crt;
ssl_certificate_key /etc/ssl/private/iRedMail.key;

Replace them with:

ssl_certificate /etc/letsencrypt/live/mail.your-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mail.your-domain.com/privkey.pem;

Save and close the file. Then test nginx configuration and reload.

sudo nginx -t

sudo systemctl reload nginx

Visit iRedMail admin panel or Roundcube webmail again, you shall see a green lock in the browser address bar.

Configuring Postfix and Dovecot

We also need to configure Postfix and Dovecot to use the Let’s Encrypt issued certificate so that desktop mail client won’t display security warning. Edit the main configuration file of Postfix.

sudo nano /etc/postfix/main.cf

Find the following 3 lines. (line 95, 96, 97).

smtpd_tls_key_file = /etc/ssl/private/iRedMail.key
smtpd_tls_cert_file = /etc/ssl/certs/iRedMail.crt
smtpd_tls_CAfile = /etc/ssl/certs/iRedMail.crt

Replace them with:

smtpd_tls_key_file = /etc/letsencrypt/live/mail.your-domain.com/privkey.pem
smtpd_tls_cert_file = /etc/letsencrypt/live/mail.your-domain.com/cert.pem
smtpd_tls_CAfile = /etc/letsencrypt/live/mail.your-domain.com/chain.pem

Save and close the file. Then reload Postfix.

sudo postfix reload

Next, edit the main configuration file of Dovecot.

sudo nano /etc/dovecot/dovecot.conf

Fine the following 2 lines. (line 47, 48)

ssl_cert = </etc/ssl/certs/iRedMail.crt
ssl_key = </etc/ssl/private/iRedMail.key

Replace them with:

ssl_cert = </etc/letsencrypt/live/mail.your-domain.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/mail.your-domain.com/privkey.pem

Save and close the file. Then reload dovecot.

sudo dovecot reload

From now on, desktop mail users won’t see security warnings.

Auto Renew TLS Certificate

To auto renew certificate, simply open root user’s crontab file.

sudo crontab -e

Then add the following line at the bottom of the file.

@daily letsencrypt renew --quiet && /usr/sbin/postfix reload && /usr/sbin/dovecot reload && systemctl reload apache2

If you use Nginx, then replace systemctl reload apache2 with systemctl reload nginx. Reloading is necessary to make these programs pick up the new certificate and private key.

Creating PTR, SPF, DKIM Records

To prevent your emails from being flagged as spam, you should set PTR, SPF and DKIM records.

PTR record

A pointer record, or PTR record, maps an IP address to a FQDN. It’s the counterpart to the A record and is used for reverse DNS lookup. Reverse resolution of A record with PTR record can help with blocking spammers. Many MTAs accept email only if the server is really responsible for a certain domain.

To check the PTR record for an IP address:

dig -x <IP> +short

or

host <IP>

Because you get IP address from your hosting provider, not from your domain registrar, so you must set PTR record for your IP in the control panel of your hosting provider and its value should be your mail server’s hostname: mail.your-domain.com. If your server uses IPv6 address, be sure to add a PTR record for your IPv6 address.

SPF Record

SPF (Sender Policy Framework) record specifies which hosts or IP address are allowed to send emails on behalf of a domain. You should allow only your own email server or your ISP’s server to send emails for your domain.

In your DNS management interface, create a new TXT record like below.

TXT  @   v=spf1 mx ~all

create spf record in DNS

Explanation:

  • TXT indicates this is a TXT record.
  • Enter @ in the name field.
  • v=spf1 indicates this is a SPF record and the SPF record version is SPF1.
  • mx means all hosts listed in the MX records are allowed to send emails for your domain and all other hosts are disallowed.
  • ~all indicates that emails from your domain should only come from hosts specified in the SPF record. Emails that are from other hosts will be flagged as forged.

Note that some DNS managers require you to wrap the SPF record with quotes like below.

TXT  @   "v=spf1 mx ~all"

To check if your SPF record is propagated to the public Internet, you can use the dig utility on your Linux machine like below:

dig your-domain.com txt

The txt option tells dig that we only want to query TXT records.

DKIM Record

DKIM (DomainKeys Identified Mail) use a private key to add a signature to emails sent from your domain. Receiving SMTP servers verify the signature using the pubic key published in your DNS manager.

The iRedMail script automatically configured DKIM for your server. The only thing left to do is creating DKIM record in DNS manager. Open the iRedMail.tips file under iRedMail-0.9.7 directory.

sudo nano iRedMail.tips

Scroll down to DNS record for DKIM support section.

iredmail DKIM

Then in your DNS manager, create a TXT record, enter dkim._domainkey in the name field. Copy everything in the parentheses and paste into the value field. Delete all double quotes and white spaces.

iredmail dkim record

After creating PTR, SPF, DKIM record, go to https://www.mail-tester.com. You will see a unique email address. Send an email from your domain to this address and then check your score.

DMARC test

Mail-tester.com can only show you a sender score. There’s a better service called GlockApps that allow you to check if your email is landed in the recipient’s inbox or spam folder, or rejected outright. It supports many popular email providers like Gmail, Outlook, Hotmail, YahooMail, iCloud mail, etc.

spam test

Adding Multiple Mail Domains

If you want to add another mail domain, then you need to

  • add a new mail domain and user in iRedMail admin panel.
  • create MX, A and SPF record for the new mail domain.
  • tell amavisd to sign email messages for the new domain.

Add MX record like below.

Record Type    Name      Value

MX             @         mail.new-domain.com

The A record points to your mail server’s IP address.

Record Type    Name     Value

A              mail     IP-address-of-mail-server

If your servers uses IPv6 address, be sure to add AAAA record.

Then create SPF record to allow the MX host to send email for the new mail domain.

Record Type    Name      Value

TXT            @         v=spf1 mx ~all

Next, you need to tell amavisd to sign every email message for the new mail domain. You can use the existing private key to sign the new domain. Edit /etc/amavis/conf.d/50-user file.

sudo nano /etc/amavis/conf.d/50-user

Find the following lines in the file.

@dkim_signature_options_bysender_maps = ( {
    ...
    "your-domain.com"  => { d => "your-domain.com", a => 'rsa-sha256', ttl => 10*24*3600 },
    ...
});

Add the following line to tell amavisd to sign with the same private key. Note that new_domain.com is your second mail domain. your-domain.com is the first mail domain.

"new_domain.com" => { d => "your-domain.com", a => 'rsa-sha256', ttl => 10*24*3600 },

So the configurations will be changed to the following.

@dkim_signature_options_bysender_maps = ( {
    ...
    "your-domain.com"  => { d => "your-domain.com", a => 'rsa-sha256', ttl => 10*24*3600 },
    "new_domain.com" => { d => "your-domain.com", a => 'rsa-sha256', ttl => 10*24*3600 },
    ...
});

Save and close the file. Then restart amavisd.

sudo systemctl restart amavis

Since we are using the the same private key for signing, there’s no need to add DKIM record for the new domain. Reverse DNS check is used to check if the sender’s IP address match the HELO hostname (the hostname you set at the beginning of this tutorial), so you don’t need to add another PTR record when adding a new mail domain. Now you can use the new domain to send and receive emails. Don’t forget to test your score at https://www.mail-tester.com.

Using Separate Domain for RoundCube

It makes sense to let users of the first domain use mail.domain1.com and users of the second domain use mail.domain2.com when using RoundCube webmail. All you need to do is create another virtual host in Apache or another server block in Nginx. However, as I said before, the Apache/Nginx directory structure is heavily modified by iRedmail, which makes the process a little complicated.

Don’t worry, just follow the instructions below if you use Nginx. (I currently don’t use Apache on my mail server, so I can’t show the exact step for Apache users, but the idea applies to Apache. You just need to change a few things to make it work.)

Change working directory to /etc/nginx/.

cd /etc/nginx/

Create a blank server block file for the second domain in /etc/nginx/sites-enabled/ directory.

sudo touch sites-enabled/mail.domain2.com.conf

Copy the default HTTP site configurations to the file.

cat sites-conf.d/default/* | sudo tee -a sites-enabled/mail.domain2.com.conf

Copy the default SSL site configurations to the file.

cat sites-conf.d/default-ssl/* | sudo tee -a sites-enabled/mail.domain2.com.conf

Edit the file.

sudo nano sites-enabled/mail.domain2.com.conf

Make the following changes.

  • Wrap all configurations with server {...} block.
  • Change the vaule of server_name to mail.domain2.com.
  • Comment out include /etc/nginx/templates/redirect_to_https.tmpl;.
  • Comment out include /etc/nginx/templates/ssl.tmpl; .
  • Comment out duplicate lines.

Now the file looks like below.

iredmail multiple domains ssl

Save and close the file. Then test Nginx configurations.

sudo nginx -t

If the test is successful, reload Nginx.

sudo systemctl reload nginx

Install Certbot Nginx plugin.

sudo apt install python-certbot-nginx

Obtain and install a free Let’s Encrypt certificate by using the Nginx plugin.

sudo certbot --nginx --agree-tos --redirect --staple-ocsp -d mail.domain2.com --email your-email-address

Now you should be able to use separate domains to access RoundCube webmail.

That’s it! I hope this tutorial helped you set up a mail server with iRedMail on Ubuntu 16.04. Subscribe to our free newsletter to get latest Linux tutorials. You can also follow us on Google+Twitter or like our Facebook page.

Rate this tutorial
[Total: 73 Average: 3.8]

60 Responses to “How to Easily Set up a Full-Fledged Mail Server on Ubuntu 16.04 with iRedMail

  • Michael B.
    1 month ago

    ### EDIT ####
    never mind! got SSL interception enabled – installed certificate and works right now 🙂

    I have tried to install iRedMail-0.9.6:
    during installation I get following error:

    Err:7 https://packages.inverse.ca/SOGo/nightly/3/ubuntu xenial/xenial amd64 Packages
      server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
    Ign:8 https://packages.inverse.ca/SOGo/nightly/3/ubuntu xenial/xenial i386 Packages
    Ign:9 https://packages.inverse.ca/SOGo/nightly/3/ubuntu xenial/xenial all Packages
    Ign:10 https://packages.inverse.ca/SOGo/nightly/3/ubuntu xenial/xenial Translation-en
    Ign:11 https://packages.inverse.ca/SOGo/nightly/3/ubuntu xenial/xenial Translation-en_GB
    Reading package lists... Done
    W: The repository 'https://packages.inverse.ca/SOGo/nightly/3/ubuntu xenial Release' does not have a Release file.
    N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
    N: See apt-secure(8) manpage for repository creation and user configuration details.
    E: Failed to fetch https://packages.inverse.ca/SOGo/nightly/3/ubuntu/dists/xenial/xenial/binary-amd64/Packages  server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

    any one else with that?
    only happens when SGO(webmail, calendar,..) is selected from setup.

    Ubuntu 16.04.2 LTS
    clean install

    ### EDIT ####
    never mind! got SSL interception enabled – installed certificate and works right now 🙂

  • Chris Amow
    1 month ago

    Awesome post! Thanks Xiao Guoan!
    A setup like this has been long overdue – I’m planning to switch over.
    Would I be able to set this up before I switch the domain over? (So I can configure everything and make sure it is running smoothly by testing against the ip address and then finally doing the switch for minimal downtime.)

  • David Bucknell
    1 month ago

    Hello,
    Thank you very much Xiao Guoan!
    Ok. I found iRedMail.tips in the mail. Working on dkim now.
    Thank you!

  • Cks Stv
    1 month ago

    how do you access the pop3 or imap?

  • jauyzed
    1 month ago

    Hello! this is a great post. I had the mail server setup within 30 mins. I used my own SSL certs from sslforfree website. I created a user apart from postmaster and Im able to send emails between the new user and postmaster but mails are not passing thro if I use the SMTP server locally. I tried using the smtp.mywebsite.com and also the ip address of the linux machine. This is a private mailserver which I use within my home network (subnet). Although I can access webmail from any server in that subnet. Are the messages blocked somewhere in the fail2ban? I have abt 17 ports open including ports 587, 25 etc

  • Xiao, thank you for this tutorial. I am new to Ubuntu and Linux but your guide makes it look easy. My question before I try this is, will this tutorial work the same on Ubuntu as a guest OS running in virtual box? Thank you

  • SteG G.
    1 month ago

    Hello and thanks for this great tutorial.
    Everything goes well but when i try to log in to iredadmin the server return error 404 not found.
    the roundcube works perfect.
    any suggestions ?
    thanks
    Ubuntu 16.04

    • Xiao Guo-An (Admin)
      1 month ago

      Please add more details to your situation, like what web server you use (Apache or Nginx). If possible, upload a screenshot and check your web server error log.

  • Lucas M4C
    1 month ago

    Hello, excuse me for my lousy English …

    I set up iredmail with multiple domains, and until now everything worked! But I wanted to know how to add a custom url for each domain, each with its own SSL certificate.

    Can someone help me?

  • This is an excellent guide, except for one fatal flaw in iRedmail which I discovered to my chagrin. I already run a server with letsencrypt, so I thought I could just add mail.example.com to the letsencrypt-auto –apache script. Although this gave me SSL access for the subdomain, it replaced the previously working iRedmail and Roundcube with the 404 page and my homepage respectively.

    What can I do to get roundcube and iRedmail back?

  • masked pro
    1 month ago

    Dear Friends,

    is there anyone here who can assist set up my mail server? I have purchased a linux VPS from qhoster and i have 2 extra IP. I have also bought a domain from google.

    I want to be able to send unlimited emails.

  • JonHain
    1 month ago

    Will this overwrite existing mysql databases and settings? Is it possible to skip the mysql section if it is already installed and functional?

    • Xiao Guo-An (Admin)
      1 month ago

      I think it will create new database but not overwrite your existing database. You can backup your existing database before installing iRedMail to be on the safe side.

    • JonHain
      1 month ago

      Ok – I’ll do good backups before installing. Thanks.

  • This broke my other ssl enabled sites. Don’t recommend using this on any webserver.

    • “my other ssl enabled sites” indicates you did this on a previously configured server. I think maybe you overlooked the bold here:

      “It is recommended that you follow the instructions below on a CLEAN INSTALL of Ubuntu 16.04 system that has at least 2GB of RAM”

      You should read prerequisites before trying to discredit someone’s work.

    • zacgarby1
      1 month ago

      You don’t need to be so defensive, he’s just trying to be helpful :/

  • Harshil Gupta
    1 month ago

    I am not using any hosting service. The mail server is created in the lab. My os is ubuntu 16.04.
    How to achieve PTR stuff.

    • phishing frenzy
      1 month ago

      Harshil, the PTR record should be done by your ISP. For example ISP gave u an IP 123.123.123.123 and you bought a domain name gupta.com, but your host name is mail.gupta.com, you pass mail.gupta.com to your isp technician they should be able to configure for you

    • Harshil Gupta
      1 month ago

      I got the point.
      Thank you 🙂

  • Andrew Hansen
    1 month ago

    Hi Thanks for this, I set it up on my Ubuntu server and all seems to be running fine now. I did have a syntax error in sudo nano /etc/apache2/sites-available/000-default.conf when I added these 3 lines RewriteEngine on
    RewriteCond %{SERVER_NAME} =mail.your-domain.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

    When I restarted Apache it came up with this error: syntax error on line 29 of /etc/apache2/sites-enabled/000-default.conf: invalid command ‘rewriteengine’, perhaps misspelled or defined by a module no action ‘configtest’ failed.

    I remmed out those 3 lines and everything seems to be working fine, is there something I did wrong and is there something I need to do to fix this.

  • Hi Xiao, i followed the steps in this tutorial on a server already running apache, php and mysql with a let’s encrypt SSL certificate, everything went well during the installation but i can not access https://mail.your-domain.com/iredadmin/ it shows the error The requested URL /iredadmin/ was not found on this server. but ?mail shows the roundcube login page. what could i be doing wrong

  • Michel1504
    1 month ago

    Thanks for the guide i installed it perfectly. got 10/10 out of mailtester. Next step is connection with ldap / ms ad or samba4. I tried to follow https://docs.iredmail.org/active.directory.html but got stuck at dovecot. and finding config files for rouncube (ngnix other place ?) and missing guide for sogo. do you have any plans to make a guide for that ?

  • Daniel Papa
    1 month ago

    Hello Xiao, this tutorial helped me very well in setting up an email server. I’m a newbie in linux and I had to do it because the boss does not want any MS licences purchased. I have two concerns though: 1) it seems that my ISP is blocking port 25, I am planning to use 2525, but can you tell me where should I configure this? I really need this to work; 2) I have three domains, I successfully created three mail domains based on your tutorial, however users from domain B and C can login to mail.A.com and vice versa, how do I prevent this? Thank you so much!

  • benisameme
    1 month ago

    Hiya,
    I set this thing up and I can recive email but if I send anything it gets lost into the dark abyss of cyber space plz help.
    – Ben

  • zacgarby1
    1 month ago

    Hi, I’m wondering why I have to set my hostname to `mail.my-domain.com` instead of `my-domain.com` as it was previously. I’m not an expert, but since this is the same server I host a HTTP server on, won’t setting the hostname to `mail.my-domain.com` make it so people have to access my website using `mail.my-domain.com`?

    • Xiao Guo-An (Admin)
      1 month ago

      This hostname will be used by your mail server. It has nothing to do with website address. Please note that iRedMail will change the web server configuration directory. Your website may stop working. You can bring it up with a little work, but I recommend that you back up web server configurations.

    • zacgarby1
      1 month ago

      Ah okay, thanks. What I don’t get is: isn’t the hostname system-wide? It’s also a bit annoying when I ssh in and the prompt says [email protected] instead of [email protected] (my previous hostname was zacgarby.co.uk)

    • Xiao Guo-An (Admin)
      1 month ago

      Yes, it’s system-wide, but almost always your Apache virtual host or Nginx server block is configured to use a different value. The Bash shell by default only shows the leftmost part of your hostname.

    • zacgarby1
      1 month ago

      Right, that makes sense! Thank you

  • casedup
    1 month ago

    hey bro got to the part when you are about to install lets encrypt….. been trying to send test emails to and from and am not getting anything at all…. everything seems to be up and working fine

    • casedup
      1 month ago

      update… able to send from roundcube to gmail. but replying doesnt seem to be getting anywhere… ive tried reading through the original messages sent from gmail but cant get any errors to show…

  • Displace Ignorance with Facts
    1 month ago

    Hi, I’m curious. The guide was fantastic! But since you have a lot of experience doing this, how much would you charge to set it up? It would be a linode and have domain name already. Very curious but extremely serious and will pay.

    • Xiao Guo-An (Admin)
      1 month ago

      Hi, it will be a fixed price of 35 USD. If interested, contact me via email. My email address can be found on the “Contact Us” page.

  • Xiao, thank you so much for your process here. I had a couple hiccups but in the end got the mail server running. Wonderful write-up, plenty of great information.

  • Hi, I cant get past this please help.
    [ INFO ] Installing package(s): postfix postfix-pcre mariadb-client mariadb-server postfix-mysql libdbd-mysql-perl php-json php-gd php-mcrypt php-curl mcrypt php-intl php-xml php-mbstring php-mysql nginx-full php-fpm dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-managesieved dovecot-sieve dovecot-mysql amavisd-new libcrypt-openssl-rsa-perl libmail-dkim-perl clamav-freshclam clamav-daemon spamassassin altermime arj zoo nomarch cpio lzop cabextract p7zip-full rpm ripole libmail-spf-perl unrar-free pax lrzip python-sqlalchemy python-dnspython python-mysqldb python-pymysql python-jinja2 python-netifaces python-webpy python-beautifulsoup python-lxml python-pycurl uwsgi uwsgi-plugin-python python-bcrypt awstats fail2ban bzip2 acl patch cron tofrodos logwatch unzip bsdutils liblz4-tool
    Reading package lists…
    Building dependency tree…
    Reading state information…
    Package zoo is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source

    Package php-mcrypt is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source

    E: Package ‘php-mcrypt’ has no installation candidate
    E: Package ‘zoo’ has no installation candidate
    <> Installation failed, please check the terminal output.
    <> If you’re not sure what the problem is, try to get help in iRedMail
    <> forum: http://www.iredmail.org/forum/

  • Paul Fisher
    4 weeks ago

    Can this be done on an 18.04 installation as well?

  • Inbound takes a long time to deliver

  • Shubhankit Mishra
    3 weeks ago

    Hello

    i followed these steps now i can send the emails but when i am sending mails from gmail to this server mails are not coming in inbox. i created a @ mx record pointing to mail.mydomain.tld . Please help.

    • Hi, greylisting will delay incoming email for a few minutes. You can check your mail log with sudo nano /var/log/mail.log. If you see a mail address is greylisted, the emails will be delayed.

    • Also make sure you create an A record for mail.yourdomain.tld.

  • Shubhankit Mishra
    3 weeks ago

    Is it possible to create mx record without creating a record?? Obviously i created a A record mail.domain.tld. And delay after 6 hours i have not received any mail. How long??

    • If you created MX and A record correctly, then Gmail can find your mail server. Greylisting will delay emails no more than 15 minutes. Can you paste your mail log in the comments? Also can you tell me your domain just to make sure I can verify your MX and A records?

  • Shubhankit Mishra
    3 weeks ago

    You can find the log here:-
    https://pastebin.com/7318Bb7v

    • Shubhankit Mishra
      3 weeks ago

      and my domain is mail.devopshit.xyz
      thanks!

    • Hi, looks like you are using AWS. Please go to AWS web-based console and set firewall to allow incoming traffic to the following ports:

      TCP port 25 (smtp),
      TCP port 587 (submission)
      TCP port 993 (imaps)
      TCP port 995 (pop3s).

  • Shubhankit Mishra
    3 weeks ago

    oh shit!
    i forgotten to take care of these.. now working thanks.. your tutorial was awesome…

  • Hello, how can I take off redirect to /mail when browsing my-domain.com?

    I want it to redirect to my website.

    Thanks.

    • Hi, looks like you didn’t follow this tutorial exactly as I told. You need to find your virtual host configuration file for your-domain.com and replace it with the original one.

  • I am using nginx, I did every step.

    • Following this tutorial, you should be able to access your webmail from mail.your-domain.com. If you installed iRedmail alongside your website on the same machine, which broke your website, you should create a virtual host file for your website in /etc/nginx/sites-enabled directory, then reload Nginx. That will restore your website.

  • hi,

    I have the same problem as Zard with zoo and mcrypt. Insatlling on Ubuntu 18.04 LTS. Any pointers are greatly appreciated.

    thanks!

  • Jason Ramos
    1 week ago

    I followed this tutorial on out DigitalOcean Ubuntu 16.04 LTS server using the Nginx web server and OpenLDAP account storage. Everything seems to be working fine except for the sending of email, even from one internal email to another on our own system. My spam result tests show that our DigitalOcean droplet has a blacklisted IP in two cases. That would easily explain why our email isn’t hitting external inboxes. I tried sending to my personal gmail and AOL accounts and both received nothing.
    https://imgur.com/LPjGqA7
    This is the error I receive from the Mailer Daemon trying to send to my AOL address. Sending to either the internal email or my personal gmail yields nothing.
    Its clear that the server is sending something out when I try to email my AOL address but it is still being refused, and I cannot send anything internally either. I’m not sure what I’m missing and any help is appreciated.

    • Jason Ramos
      1 week ago

      Our*

    • Jason Ramos
      1 week ago

      Seems the issue was on DigitalOcean’s side, nevermind 🙂 Great tutorial.

  • Hi! Great tutorial, everything looks great, except for one thing: I cannot send mails. Receiving is fine, I’ve done many tests, but I can’t send anything. On the mail.log file, the problem appears to be “connection timed out” and after a little digging, I found that some ISP are blocking SMTP port 25 for outbound traffic. I tried tweaking the postfix configuration files, but no luck. Any suggestions?

  • What is the best method to encrypt emails at rest on your server. Has anybody tried this, for example?

    https://wiki2.dovecot.org/Plugins/MailCrypt

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • * Some of my previous answers are lost after I uninstalled Disqus comment system from my website. I try to recover those answers whenever I can.