#!/bin/bash

function InstallMailService {
    Message "Installing mail service: exim, dovecot.\n"
    if [ -f /etc/init.d/sendmail ]; then
        /etc/init.d/sendmail stop
    fi
    apt-get install -y exim4 exim4-daemon-heavy dovecot-sieve dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd || InstallationFailed

    /usr/local/fastpanel2/fastpanel services configure -f -p exim
    /usr/local/fastpanel2/fastpanel services handle --name=exim --action=enable
    /usr/local/fastpanel2/fastpanel services handle --name=exim --action=restart

    /usr/local/fastpanel2/fastpanel services configure -f -p dovecot
    /usr/local/fastpanel2/fastpanel services handle --name=dovecot --action=enable
    /usr/local/fastpanel2/fastpanel services handle --name=dovecot --action=restart

    Success
}
