UnixServerAdmin

Server Administration & Management

How to configure Postfix MTA for Mail Server

# vim /etc/postfix/main.cf

myhostname = unixserveradmin.com     ## line no 75 – uncomment and enter your host name
mydomain = unixserveradmin.com     ## line no 83 – uncomment and enter your domain name
myorigin = $mydomain     ## line no 99 – uncomment
inet_interfaces = all     ## line no 116 – change to all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain     ## line no 164 – add $domain at the end
mynetworks = 192.168.1.0/24, 127.0.0.0/8     ## line no 264 – uncomment and add your network range
home_mailbox = Maildir/     ## line no 419 – uncomment

July 31, 2013 Posted by | Mail, Uncategorized | , | Leave a comment

How to configure Dovecot in RHEL/CentOS 6 for Plain Login

1. Install Dovecot Package

# yum install dovecot

2. Open the dovecot config file /etc/dovecot/dovecot.conf and Find and uncomment the line as shown below.

# vim /etc/dovecot/dovecot.conf

protocols = imap pop3 lmtp

3. Open the file /etc/dovecot/conf.d/10-mail.conf and uncomment the line as shown below.

# vim /etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:~/Maildir  ##line no 24 – uncomment

4. Open the /etc/dovecot/conf.d/10-auth.conf and edit as shown below.

# vim /etc/dovecot/conf.d/10-auth.conf

disable_plaintext_auth = no  ##line no 9 – uncomment and change from yes to no.
auth_mechanisms = plain login  ##line no 97 – add the text “login”

5. Open the /etc/dovecot/conf.d/10-master.conf and edit as shown below.

# vim /etc/dovecot/conf.d/10-master.conf

unix_listener auth-userdb {
    #mode = 0600
    user = postfix  ##line no 83 – uncomment and enter postfix
    group = postfix  ##line no 84 – uncomment and enter postfix

6. Start the dovecot service

# /etc/init.d/dovecot restart

July 26, 2013 Posted by | Mail | , | Leave a comment

Webmail error:Warning: main(../config/config.php): failed to open stream in cPanel

I got the following error in webmail

===============================================================
Warning: main(../config/config.php): failed to open stream: No such file or directory in /usr/local/cpanel/base/3rdparty/squirrelmail/functions/global.php on line 18
Fatal error: main(): Failed opening required ‘../config/config.php’ (include_path=’/usr/local/cpanel/3rdparty/lib/php/:.’) in /usr/local/cpanel/base/3rdparty/squirrelmail/functions/global.php on line 18
===============================================================

To Fix this issue, type the following command:-

# /scripts/fixwebmail

After running /scripts/fixwebmail you may get error like this:-

===============================================================
chown: failed to get attributes of `/usr/local/etc/cpanel/base/webmail/data’: No such file or directory
chmod: failed to get attributes of `/usr/local/etc/cpanel/base/webmail/data’: No such file or directory
===============================================================

For fixing this just issue the following command:-

# cp -p /usr/local/cpanel/base/3rdparty/squirrelmail/config/config_default.php /usr/local/cpanel/base/3rdparty/squirrelmail/config/config.php

December 23, 2012 Posted by | cPanel, Mail | , , | Leave a comment

RoundCube – Service currently not available errror no. [0x01F4]

Mostly we received following error after browsing RoundCube – “RoundCube – Service currently not available errror no. [0x01F4]

As well as RoundCube error logs showing following logs

[02-Oct-2012 08:34:56 -0400] DB Error: _doQuery: [Error message: Could not execute statement] [Last executed query: PREPARE MDB2_STATEMENT_mysql_8c77e0752a8db2da365c3c7a19fe8842c84663aa7 FROM ‘INSERT INTO messages\n (user_id, del, cache_key, created, idx, uid, subject, `from`, `to`, cc, date, size, headers, structure)\n         VALUES (?, 0, ?, now(), ?, ?, ?, ?, ?, ?, FROM_UNIXTIME(), ?, ?, ?)’]
[Native code: 1064] [Native message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘), ?, ?, ?)’ at line 3] in /usr/local/cpanel/base/3rdparty/roundcube/program/include/rcube_mdb2.inc on line 265
[02-Oct-2012 08:35:20 -0400] DB Error: _doQuery: [Error message: Could not execute statement] [Last executed query: PREPARE MDB2_STATEMENT_mysql_d6ee872839dbf41a18e11e2f09d1f4d9790e462d7 FROM ‘INSERT INTO messages\n (user_id, del, cache_key, created, idx, uid, subject, `from`, `to`, cc, date, size, headers, structure)\n         VALUES (?, 0, ?, now(), ?, ?, ?, ?, ?, ?, FROM_UNIXTIME(), ?, ?, ?)’]
[Native code: 1064] [Native message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘), ?, ?, ?)’ at line 3] in /usr/local/cpanel/base/3rdparty/roundcube/program/include/rcube_mdb2.inc on line 265

The error is occur because MySQL could not insert the values from UNIXTIME. To avoid this error simply open file /usr/local/cpanel/base/3rdparty/roundcube/program/include/rcube_mdb2.php and replace following code

# vim /usr/local/cpanel/base/3rdparty/roundcube/program/include/rcube_mdb2.php

From

return “FROM_UNIXTIME($timestamp)”;

To

return sprintf(“FROM_UNIXTIME(%d)”, $timestamp);

Now clear cache from your local machine refresh RoundCube error page.

October 9, 2012 Posted by | Mail | , | Leave a comment

How to relay localhost mails to remote smtp server

sSMTP is a simple MTA to deliver mail from a computer to a mail hub (SMTP server). sSMTP is simple and lightweight, there are no daemons or anything hogging up CPU; Just sSMTP. If linux based system have running internet, then we can send email to any account using remote smtp authentication, here is following steps :-

ssmtp download link

# wget dl.fedoraproject.org/pub/epel/5/i386/ssmtp-2.61-15.el5.i386.rpm

# wget dl.fedoraproject.org/pub/epel/5/x86_64/ssmtp-2.61-15.el5.x86_64.rpm

# vim /etc/ssmtp/ssmtp.conf

For StartTLS smtp authentication
###########################################
Root=example@gmail.com
Mailhub=smtp.gmail.com:587
#RewriteDomain=gmail.com
AuthUser=example # (before the @gmail.com part)
AuthPass=example@123
FromLineOverride=Yes
UseSTARTTLS=Yes
AuthMethod=LOGIN
###########################################

For TLS smtp authentication
###########################################
Root=example@gmail.com
Mailhub=smtp.gmail.com:465
#RewriteDomain=gmail.com
AuthUser=example # (before the @gmail.com part)
AuthPass=example@123
FromLineOverride=Yes
UseTLS=Yes
AuthMethod=LOGIN
###########################################

Username :- example
Password :- example@123
Smtp Server :- gmail.com

After done above process, we can also send email through mutt from command line interface (CLI) by following change :-

# vim /root/.muttrc
set sendmail = “/usr/sbin/ssmtp -aexample@gmail.com -apexample@123 -v”

June 13, 2012 Posted by | Mail, Tips & Tricks, Unix/Linux | , , , | Leave a comment

How to enable viewing HTML content in Horde

By default it is not possible for us to view the emails in HTML format using Horde webmail interface. All the html content will be displayed at the top of the page and will be requested to download. To enable the html display for horde webmail you need to modify /usr/local/cpanel/base/horde/imp/config/mime_drivers.php file.

Proceed with the following steps:-

# cd /usr/local/cpanel/base/horde/imp/config

Edit the file mime_drivers.php using your favorite editor.

# vim mime_drivers.php

Change the following line
=================================
$mime_drivers[‘imp’][‘plain’][‘inline’] = false;
=================================
To
=================================
$mime_drivers[‘imp’][‘plain’][‘inline’] = true;
=================================

Restart cPanel service:-

# /etc/init.d/cpanel restart

May 30, 2012 Posted by | cPanel, Mail | , , , | 1 Comment

Horde Failed to connect to localhost:25 error message

On Shared server as well  as on Dedicated server some time we are facing large connection issue to SMTP port 25 at that time mostly we disable SMTP port 25 and enable any other port for SMTP but after changing SMTP port mostly we receive following error message in Horde webmail.

There was an error sending your message: Failed to connect to localhost:25 [SMTP: Invalid response code received from server (code: 421, response: Too many concurrent SMTP connections; please try again later.)]

To resolve above error simply change SMTP port from 25 to new SMTP port  in following file.

[/usr/local/cpanel/base/horde/imp/config]# vim servers.php

And change following line

From
‘smtpport’ => 25,
To
‘smtpport’ => 26,

We have taken new port as 26 for example you can use any port as per your requirement.

Similar problem with “Squirrelmail” then refer following steps.

[/usr/local/cpanel/base/3rdparty/squirrelmail/config]# vim config_default.php

Change following line

From
$smtpPort = 25;
To
$smtpPort = 26;

Save file and exit and now open the webmail.

May 20, 2012 Posted by | cPanel, Mail | , | Leave a comment

How to enable html display for horde

You can enable the html display for horde by using following steps but please make sure that you have been logged in as root.

# vi /usr/local/cpanel/base/horde/imp/config/mime_drivers.php

Search for the line
—-
/**
* HTML driver settings
*/
$mime_drivers[‘imp’][‘html’][‘inline’] = false;
—–

and replace it with

——–
/**
* HTML driver settings
*/
$mime_drivers[‘imp’][‘html’][‘inline’] = true;
——–
Save the changes and restart the following services.

# service cpanel restart

# /scripts/restartsrv_courier

May 16, 2012 Posted by | cPanel, Mail | , , , | Leave a comment

How to transfer root’s emails to another email address

If you have ‘root’ access to the server then open the file /etc/aliases in your favorite editor. Look for the section “# Person who should get root’s mail” and make the change as required.

# vim /etc/aliases

## Person who should get root’s mail  ##
root:   info@unixserveradmin.com

January 13, 2012 Posted by | Mail, Tips & Tricks | , | Leave a comment

How to fix error in Mailing list

Error:-

Bug in Mailman version 2.1.9.cp2
We’re sorry, we hit a bug!
Please inform the webmaster for this site of this problem. Printing of traceback and other system information has been explicitly inhibited, but the webmaster can find this information in the Mailman error logs.

Fix:-

1. Go to /usr/local/cpanel/3rdparty/mailman

# cd /usr/local/cpanel/3rdparty/mailman

# ls -al

#chmod -R 2775 ./*

Check if this has fixed the issue, If not run the fixmailman script.

# /scripts/fixmailman

If this wont fix the issue.

# /scripts/reinstall mailman

December 16, 2011 Posted by | cPanel, Mail | , , , | Leave a comment

How to change language for Roundcube webmail

1. Edit Roundcube main config (/usr/local/cpanel/base/roundcube/config/main.inc.php)

# vi /usr/local/cpanel/base/roundcube/config/main.inc.php

To change language from English to Portuguese Brasil

Find

$rcmail_config[‘locale_string’] = ‘en’;

Replace it to

$rcmail_config[‘locale_string’] = ‘pt_BR’;

You can see the installed languages such as fr(french), en_US(english US) from the folder /usr/local/cpanel/base/roundcube/program/localization.

December 15, 2011 Posted by | cPanel, Mail | , , , | Leave a comment

How to Email Alert on Root SSH Login

If you want to receive email alert when someone makes a root login to the Server.

1. open the file /root/.bashrc

# vi /root/.bashrc

2. Scroll to the end of the file then add the following:

echo ‘ALERT – Root Shell Access (YourserverName) on:’ `date` `who` | mail -s “Alert: Root Access from `who | cut -d'(‘ -f2 | cut -d’)’ -f1`” you@yourdomain.com

September 10, 2011 Posted by | Mail, Security, SSH, Tips & Tricks | , , , , | 1 Comment

How to enable log selector in Exim

Add the following entry in advanced configuration editor in exim:-

=====================================================================
log_selector = +address_rewrite +all_parents +arguments +connection_reject +delay_delivery +delivery_size +dnslist_defer +incoming_interface +incoming_port +lost_incoming_connection +queue_run +received_sender +received_recipients +retry_defer +sender_on_delivery +size_reject +skip_delivery +smtp_confirmation +smtp_connection +smtp_protocol_error +smtp_syntax_error +subject +tls_cipher +tls_peerdn
======================================================================

Restart exim after this :-

# /scripts/restartsrv_exim “OR”

# /etc/init.d/exim restart

Once this is done , you will be able to find the location of the script which is sending mails as nobody user. For this Just issue the following command:-

# tail -f /var/log/exim_mainlog | grep cwd

====================================================================
2011-08-26 23:03:46 cwd=/var/spool/exim 3 args: /usr/sbin/exim -Mc 1LnPlq-000810-Sl
2011-08-26 23:03:46 cwd=/var/spool/exim 3 args: /usr/sbin/exim -Mc 1LnPlq-000811-St
2011-08-26 23:03:46 cwd=/home/icicemac/public_html 3 args: /usr/sbin/sendmail -t -i
2011-08-26 23:03:46 cwd=/var/spool/exim 3 args: /usr/sbin/exim -Mc 1LnPlq-000813-T9
2011-08-26 23:05:48 cwd=/home/icicemac/public_html 3 args: /usr/sbin/sendmail -t -i
2011-08-26 23:05:48 cwd=/var/spool/exim 3 args: /usr/sbin/exim -Mc 1LnPno-00087I-CT
====================================================================

July 26, 2011 Posted by | Exim, Mail | , , | Leave a comment

ERROR: Could not complete request. Query: SELECT “INBOX”

If you are getting this error while accessing webmail.

ERROR: Could not complete request.
Query: SELECT “INBOX”
Reason Given: Unable to open this mailbox.

It means that there is some an issue while accessing email accounts via webmail. To resolve the issue, create the following folder at its location and assign the correct permission. You can do it with the help of following commands.

# cd /home/UserName/mail/Domainname.com/emailIDUsername/

# mkdir new; mkdir cur; mkdir tmp

# chown username.username*

May 14, 2011 Posted by | Mail | | 6 Comments

mail_queue.sh

#################################################
# Script for Mail Queue Delete for Exim in cPanel
#################################################
# mail_queue.sh
#################################################
##### Mail Queue Cleaner #####
#!/bin/bash
echo Clearing Mail Queue..
cd /var/spool/exim/input
rm -rf *
exit
#################################################

May 4, 2011 Posted by | Mail, Shell Script | , | 1 Comment

How to install DomainKeys on a cPanel Server

Delivering mail to yahoo and google is so hard those days. Almost every server has had this problem even if it is not used to relay spam. Installing DomainKeys can help your server deliver “clean” emails directly to your user’s inbox.

Installation is simple and it’s done on a domain basis. Here is following steps to install DomainKeys on a specific domain.

First check that you are running the latest version on RELEASE or CURRENT of cPanel 11. Run the script

# /usr/local/cpanel/bin/domain_keys_installer username

Where username is the cPanel user.

If you get an error similar to “Domain keys are not installed on this machine.” you either are not running the latest release or current version of cPanel or you have not converted yet to maildir. Maildir conversion is required before you install DomainKeys.

Ok, we just installed DomainKeys for a domain, but how about if we want to install it for all the domains (users)?
Well, here is bash script that will parse all the cpanel users and then run the installation for each of them.

——————————————————————————–
for i in `ls /var/cpanel/users` ;
do /usr/local/cpanel/bin/domain_keys_installer $i ;
done
——————————————————————————–

Ok, but what about if we want that every new created account to have DomainKeys installed. Well this is a bit harder to do. But we recommend editing /scripts/postwwwacct and adding:

# vi /scripts/postwwwacct

——————————————-
my %OPTS = @ARGV;
my $user = $OPTS{’user’};
/usr/local/cpanel/bin/domain_keys_installer $user
——————————————-

Now test this by creating a new account.

April 23, 2011 Posted by | cPanel, Mail | , , , | 10 Comments

E-Mail Issue with SquirrelMail

While sending emails using SquirrelMail,Sometimes you would be getting following error message;

ERROR: Could not append message to INBOX.Sent.
Server responded: [ALERT] Cannot create message – no write permission or out of disk space.

ERROR: Could not append message to INBOX.Sent.
Server responded: Error in IMAP command received by server.

ERROR: Connection dropped by IMAP server.
Query: LOGOUT

Solutions of this issue is you have to create tmp directory in /home/cPanel-Username/mail/Domain-Name/xyz/.Sent folder and issue get resolved.

Note:-
1. cPanel-Username is username of cPanel account
2. Domain-Name is the domain on which email address is created
3. xyz is a initial of email address

April 14, 2011 Posted by | cPanel, Mail | , | 4 Comments

How to view maillog for particular domain

SSH to Server and run following commands as root user :-

# cat /var/log/exim_mainlog | grep “unixserveradmin.com” > mail_log.txt

this should create a file called mail_log.txt with the desired mail log for unixserveradmin.com domain

January 15, 2011 Posted by | Mail | , , | 1 Comment