{"id":1095,"date":"2021-02-09T19:03:46","date_gmt":"2021-02-09T19:03:46","guid":{"rendered":"https:\/\/dft.wiki\/?p=1095"},"modified":"2026-04-21T13:34:48","modified_gmt":"2026-04-21T17:34:48","slug":"full-mail-server-on-ubuntu-20-04-iredmail","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=1095","title":{"rendered":"Full Mail Server on Ubuntu using iRedMail"},"content":{"rendered":"<p>iRedMail is a script that performs a huge amount of tasks and set up all sorts of services and applications to fulfill any e-mail necessity.<\/p>\n<ul>\n<li>Postfix SMTP server.<\/li>\n<li>Dovecot IMAP server.<\/li>\n<li><strong>Nginx<\/strong> webserver (admin panel and webmail).<\/li>\n<li>OpenLDAP, MySQL\/<strong>MariaDB<\/strong>, or PostgreSQL.<\/li>\n<li>Amavised-new (DKIM).<\/li>\n<li>SpamAssassin (anti-spam).<\/li>\n<li>ClamAV (anti-virus).<\/li>\n<li>Roundcube (webmail).<\/li>\n<li>SOGo (webmail, calendar, contacts, ActiveSync&#8230;).<\/li>\n<li>Fail2ban (security).<\/li>\n<li>mlmmj (mailing list).<\/li>\n<li>Netdata (monitoring).<\/li>\n<li>iRedAPD Postfix (greylisting).<\/li>\n<\/ul>\n<p>Set the domain name:<\/p>\n<pre>sudo apt update &amp;&amp; sudo apt upgrade -y\r\nsudo hostnamectl set-hostname <strong>mail.example.com<\/strong>\r\nsudo nano \/etc\/hosts\r\n\r\n    127.0.0.1 <strong>mail.example.com mail<\/strong> localhost\r\n<\/pre>\n<p>Download from any of the methods:<\/p>\n<pre>git clone https:\/\/github.com\/iredmail\/iRedMail\/\r\ncd iRedMail\r\nchmod +x iRedMail.sh\r\nsudo bash iRedMail.sh\r\n\r\n    <strong>OR<\/strong>\r\n\r\nwget https:\/\/github.com\/iredmail\/iRedMail\/archive\/<strong>1.4.0<\/strong>.tar.gz\r\ntar xvf 1.3.2.tar.gz\r\ncd iRedMail-1.3.2\/\r\nchmod +x iRedMail.sh\r\nsudo bash iRedMail.sh<\/pre>\n<p>Get the latest at [<a href=\"https:\/\/www.iredmail.org\/download.html\">Link<\/a>].<\/p>\n<p>Follow the screens:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1101\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-31-40.png\" alt=\"\" width=\"760\" height=\"418\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-31-40.png 760w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-31-40-300x165.png 300w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1102\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-32-00.png\" alt=\"\" width=\"760\" height=\"418\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-32-00.png 760w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-32-00-300x165.png 300w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1103\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-32-21.png\" alt=\"\" width=\"760\" height=\"418\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-32-21.png 760w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-32-21-300x165.png 300w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1104\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-32-39.png\" alt=\"\" width=\"760\" height=\"418\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-32-39.png 760w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-32-39-300x165.png 300w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1105\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-33-04.png\" alt=\"\" width=\"760\" height=\"418\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-33-04.png 760w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-33-04-300x165.png 300w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1106\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-33-44.png\" alt=\"\" width=\"761\" height=\"417\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-33-44.png 761w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-33-44-300x164.png 300w\" sizes=\"auto, (max-width: 761px) 100vw, 761px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1107\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-34-33.png\" alt=\"\" width=\"760\" height=\"418\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-34-33.png 760w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-34-33-300x165.png 300w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1108\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-34-58.png\" alt=\"\" width=\"760\" height=\"418\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-34-58.png 760w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-34-58-300x165.png 300w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1109\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-35-08.png\" alt=\"\" width=\"759\" height=\"417\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1110\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-40-22.png\" alt=\"\" width=\"760\" height=\"418\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-40-22.png 760w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-40-22-300x165.png 300w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1111\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-40-37.png\" alt=\"\" width=\"760\" height=\"418\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-40-37.png 760w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2021\/02\/Screenshot-from-2021-02-09-14-40-37-300x165.png 300w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/><\/p>\n<p>Your mail server is already working and as a good practice, it is now ready to start SSL\/TLS certificate on the webserver.<\/p>\n<pre>sudo apt install certbot\r\nsudo certbot certonly --webroot --agree-tos --email you@example.com -d mail.example.com -w \/var\/www\/html\/\r\nsudo nano \/etc\/nginx\/templates\/ssl.tmpl<\/pre>\n<p>Change the following lines accordingly for NGINX:<\/p>\n<pre>ssl_certificate \/etc\/letsencrypt\/live\/mail.example.com\/fullchain.pem;\r\nssl_certificate_key \/etc\/letsencrypt\/live\/mail.example.com\/privkey.pem;<\/pre>\n<p>Test and reload the webserver:<\/p>\n<pre>sudo nginx -t\r\nsudo systemctl reload nginx<\/pre>\n<p>Now, install the certificate in the Postfix (SMTP server) and Decovet (IMAP server):<\/p>\n<pre>sudo nano \/etc\/postfix\/main.cf\r\n\r\n<\/pre>\n<p>Change the following lines accordingly:<\/p>\n<pre>smtpd_tls_key_file = \/etc\/letsencrypt\/live\/mail.example.com\/privkey.pem\r\nsmtpd_tls_cert_file = \/etc\/letsencrypt\/live\/mail.example.com\/cert.pem\r\nsmtpd_tls_CAfile = \/etc\/letsencrypt\/live\/mail.example.com\/chain.pem<\/pre>\n<p>Same for the Decovet (IMAP server):<\/p>\n<pre>sudo nano \/etc\/dovecot\/dovecot.conf<\/pre>\n<p>Change the following lines accordingly:<\/p>\n<pre>ssl_cert = &lt;\/etc\/letsencrypt\/live\/mail.example.com\/fullchain.pem\r\nssl_key = &lt;\/etc\/letsencrypt\/live\/mail.example.com\/privkey.pem<\/pre>\n<p>Reload both services:<\/p>\n<pre>sudo systemctl reload postfix\r\nsudo systemctl reload dovecot<\/pre>\n<p><!-- https:\/\/www.linuxbabe.com\/mail-server\/ubuntu-20-04-iredmail-server-installation --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>iRedMail is a script that performs a huge amount of tasks and set up all [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,7],"tags":[],"class_list":["post-1095","post","type-post","status-publish","format-standard","hentry","category-linux","category-web"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/1095","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1095"}],"version-history":[{"count":15,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/1095\/revisions"}],"predecessor-version":[{"id":5489,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/1095\/revisions\/5489"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1095"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1095"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1095"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}