Set hostname for CyberPanel Postfix/Dovecot

Things that should be checked change ‘your.hostname.here’ to your hostname
Hostname set via

  1. hostnamectl set-hostname server.domain.com
  2. Postfix hostname should be configured
    postconf -e ‘myhostname = your.hostname.here’
  3. Find and replace/update of the below paths with new hostname
    /etc/hosts
    /etc/mailname
    /etc/dovecot/dovecot.conf

Then check for your hostname like the below. In my case it was ‘cyberpanel.example.com’

root@cyberpanel:~# grep -ril cyberpanel.example.com /etc/
/etc/mailname
/etc/aliases.db
/etc/hostname
/etc/postfix/main.cf
/etc/hosts
/etc/dovecot/dovecot.conf
root@cyberpanel:~#

If you have Ipv6 you should also add your hostname to the ::1 localhost in the /etc/hosts file line like it is for the 127.0.0.1 line

Semi scripted route:

HostName='your.hostname.here' ; hostnamectl set-hostname ${HostName} ; postconf -e "myhostname = $(hostname)"; echo $(hostname) > /etc/hostname ; echo $(hostname) > /etc/mailname;

Restart Services:

systemctl restart postfix||service postfix restart && systemctl status postfix -l||service postfix status; systemctl status postfix -l||service postfix status; systemctl restart dovecot||service dovecot restart; systemctl status dovecot||service dovecot status;

Tail logs while sending or receiving mail.

tail -f /var/log/{maillog,exim_mainlog,exim_rejectlog,mail.log,mail.err,syslog} 2> /dev/null | grep -vEi 'Firewall|ftp'

I know some cloud servers have their hostname only set by dhcp

so one thing to do is do

vpsname="your.hostname.here"; echo "hostnamectl set-hostname ${vpsname}" >> /etc/rc.d/rc.local

or via root crontab

@reboot hostnamectl set-hostname your.hostname.here

For those using the WizardAssistant app just search “Cyberpanel Set/Fix Hostname and Postfix” in the commands box and put your hostname in the domain field and click to copy or double click(Premium users) to run the fix and restart the services.

Cyberpanel Set/Fix Hostname and Postfix via WizardAssistant App

Leave a Comment

Item added to cart.
0 items - $0.00