Archive for the ‘Qmail’ category

How to tell what version / kernel your linux server is running.

December 16th, 2008

If you ever work on other linux servers (other than your own) and need to see what OS or kernel they are running, you can connect via SSH and type the following to find out;

Determine the Installed Version of Redhat-based Systems:

#cat /etc/redhat-release

Determine the Installed Version of Debian

#cat /etc/debian_version Dete

Determine the Installed Version of Ubuntu

#cat /etc/issue or #cat /etc/lsb-release

Determine the Version of the Linux Kernel

#uname -a

Changing Plesk email hostname/hostname

October 31st, 2008

In order to change the hostname in Plesk (6+) you will need to make the change in the following locations below. This is needed if you want to change the hostname that is included on any emails sent from the plesk server.

  • /etc/hosts
    Your current hostname should be here behind the server’s IP address, change this to the new hostname
  • /etc/sysconfig/network
    You should have a HOSTNAME variable here, change this to your new hostname.
  • /var/qmail/control/me
    This contains the old hostname, change it to your new hostname to make qmail identify itself as the new hostname.
  • Change the servers hostname while it’s running, normally this is set at boot.
    hostname <newhostname>
  • Set the new hostname inside Plesk’s database:
    mysql -u admin -p`cat /etc/psa/.psa.shadow`
    use psa;
    update misc set val=’NEWHOSTNAME’ where param=’FullHostName’;

Now restart Plesk to activate your changes:
/etc/init.d/psa stopall
/etc/init.d/psa stop
/etc/init.d/psa start

After this, the server will now reply, you can test this by sending an email out or by sending an telnet out;

[root@vps2 ~]# telnet 10.25.2.1 25
Trying  10.25.2.125…
Connected to  10.25.2.1.
Escape character is ‘^]’.
220 Seemynamehaschanged.com ESMTP

How to change maximum number of connections in Qmail / Plesk

October 11th, 2008

By default, the maximum number of concurrent connections from one ip in Qmail (plesk) is set to 4. Anymore than that and it will start to fail or reject the connections. Normally this isn’t an issue, but if you use an email client that tries to establish more than 4 connections at once, you will run into an issue.

To bypass this, you can edit the following files and change the MAXPERIP value to a different number. Remember, however the path’s may be different depending on your OS, so if it’s not the same as the path’s I list, you will need to locate/find or Grep for them. The path’s and files are;

/etc/courier-imap/imapd

/etc/courier-imap/pop3d

(another path is also /usr/lib/courier-imap/etc/imapd and /usr/lib/courier-imap/etc/pop3d)

Once you’ve made the edits, you will need to restart the mail service;

/etc/init.d/courier-imap stop and /etc/init.d/courier-imap start

=)

How to configure Qmail / Plesk to listen to additional SMTP port

September 17th, 2008

Many IPS block the use of the standard mail SMTP port (port 25).
In order to deal with this SMTP can be configured to run on alternate/additional ports.

The process for this is fairly simple:

Copy /etc/xinetd.d/smtp_psa to smtp2_psa

In the new file, REPLACE service smtp WITH service smtp2

Then modify /etc/services and add the smtp2 service (port 26 in this example).

smtp2 26/tcp mail
smtp2 26/udp mail

Then restart xinetd
/etc/init.d/xinetd restart

Check that the new port is now listening
# netstat -plunt |grep :26

That should return something similar to

tcp 0 0 0.0.0.0:26 0.0.0.0:* LISTEN 2345/xinetd

Test connection by telnetting from an outside box to port 26 on the server:
telnet 123.123.123.123 26

High CPU usage with Qmail processes

June 24th, 2008

If you happen to notice that your server (dedicated or vps) is running at 100% cpu usage or close to it, and you notice the following that qmail is using all of your cpu usage;

Code:

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
28141 qmaild 25 0 4600 1376 1168 R 27 0.1 0:28.09 qmail-smtpd
27851 qmaild 25 0 4708 1372 1168 R 26 0.1 1:23.48 qmail-smtpd
28268 qmaild 25 0 3948 1372 1168 R 24 0.1 0:05.79 qmail-smtpd
27507 qmaild 25 0 4468 1372 1168 R 23 0.1 1:56.58 qmail-smtpd
28244 qmaild 25 0 4520 1372 1168 R 20 0.1 0:06.82 qmail-smtpd
28045 qmaild 25 0 3820 1376 1168 R 20 0.1 0:48.50 qmail-smtpd
28117 qmaild 25 0 3724 1372 1168 R 20 0.1 0:33.20 qmail-smtpd
28118 qmaild 25 0 4452 1372 1168 R 20 0.1 0:33.59 qmail-smtpd
28163 qmaild 25 0 5200 1380 1168 R 20 0.1 0:25.30 qmail-smtpd

You can check on the /var/qmail/control directory for 2 files;

dh512.pem
dh1024.pem
If you don’t see them or with another naming (dhparam512 and dhparam1024), rename them accordingly.

After that, you will need to restart qmail and xinetd;

# service qmail restart

# service xinetd restart

Without dh512.pem and dh1024.pem, qmail has to create certificate and key pairs when other mail servers or mail users connect to qmail via TLS. If qmail is forced to create them on the fly, you will see a huge performance hit, and your load will be higher than it normally should be. By copying the dhparam files over, you will pre-populate the SSL key and certificate for qmail to use, and all it has to do is pick it up off the file system rather than regenerating it each time, thus saving your cpu usage from maxing out. Usually it will drop your cpu usage.