Update #2 on Installing qpsmtpd on Xenial

[2008-11: New installation on 10.3/8.6.0]
[2007-04: Implementing SMTP Authorization with qpsmtpd running under SuSE 10.0 and Plesk 8.0
[2014-01: Here's an update to these instructions.]
[2018-09: Update #2 on Installing qpsmtpd on Xenial, completely replaces 2014-01]

This is another update to my original instructions and replacement for Update on Installing qpsmtpd for installing qpsmtpd on a Linux system running under Plesk.

qpsmtpd is on GitHub, but we need some preliminaries first:

Just in case you don't have cc yet:
apt-get install build-essential

apt-get install libcrypt-openssl-random-perl libcrypt-openssl-rsa-perl
apt-get install libssl-dev
perl -MCPAN -e 'install Crypt::OpenSSL::Random'
# ^ This will install CPAN if you haven't done that already!
perl -MCPAN -e 'install Crypt::OpenSSL::RSA'
perl -MCPAN -e 'install Geo::IP'
perl -MCPAN -e 'install Mail::DKIM'
apt-get install libxml2-dev
perl -MCPAN -e 'install XML::LibXML'
perl -MCPAN -e 'install Mail::DMARC'
# ^ This seems to install half of the world...
apt-get install libidn2-0-dev

libidn2 in Xenial is 0.10-3, but because of "wrong result: 'idn2'" when building Net::LibIDN2 in Net::DNS we need 2.0+, i.e. 2.0.2-5 from here.

After these preliminaries we can build qpsmtpd according to its README: Installing the following "required Perl modules:
perl -MCPAN -e 'install Net::DNS'
perl -MCPAN -e 'install MIME::Base64'
perl -MCPAN -e 'install Mail::Header'

In addition the default plugins now also require
perl -MCPAN -e 'install Mail::SPF'

Then get GeoLiteCity.dat and GeoIPASNum.dat from http://dev.maxmind.com/geoip/legacy/install/city/ into usr/local/share/GeoIP/ and install
perl -MCPAN -e 'install Math::Complex'

For the auth_imap plugin, install
perl -MCPAN -e 'install Net::IMAP::Simple'

Running the watch and summarize utilities recommended in the FAQ requires yet another dependency:
perl -MCPAN -e 'install File::Tail'

Now proceed with installing qpsmtpd.