Can’t receive emails WHM/Cpanel – Sender Verification Callouts

When you understood that many email are not delivered in your inbox which are sent from (Hotmail,Google or custom server) first of all you must check logs whats happening, if dns is configured properly and you see “Could not complete sender verify callout” in your logs which you can check in whm “Email”->” Mail Delivery Reports ” then this is because of Sender Verification Callouts

Use callouts to verify the existence of email senders. Exim will connect to the mail exchanger for a given address to verify it exists before accepting mail from it.

we can fix it very fast just go to “Exim Configuration Manager” in WHM and search for “Sender Verification Callout” check off which by the way is default, click save and test your mails.

Setup NSF backup WHM/CPanel

This is tutorial how to enable NFS backup for WHM running on CENTOS 6

first of all we need to install NSF soft on centos use this commands to do this

yum install nfs-utils nfs-utils-lib

also install Portmap if it’s not installed

yum install rpcbind

Now we must start services

chkconfig nfs on 
service rpcbind start
service nfs start

Okay now everything is installed and we must create directory and mount NFS

mkdir /home/nfsdir
mount -t nfs 15.15.45.65:/folder /home/nfsdir

Now just go to Backup Configuration in whm and set Default Backup Directory to in our situation /home/nfsdir, that’s all now backup will be saved in NFS which is mounted in your system.

PHP Script To Send Email Using SMTP

It’s very easy to send email using PHP via SMTP, first of all you must downloads PHP Mailer (https://github.com/PHPMailer/PHPMailer), after we will use small script as an example which will connect to smtp and send email.

<?php
 
require_once "PHPMailer-master/PHPMailerAutoload.php";
 
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "mail.domain.com";
$mail->SMTPAuth = true;
$mail->Username = "username";
$mail->Password = "password";
$mail->From = "[email protected]";
$mail->FromName = "Your Name";
$mail->AddAddress("[email protected]");
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = "This is subject";
$mail->Body = "THis is body <b>html</b>";
$mail->AltBody = "This is the body in plain text.";
if (!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

Beautify XML to print in C#

You can print XML normally but it will not be formatted, we have solution which can help you to output XML in nice format We will use XmlTextWriter function to do this here is simple function which you can use in project.

public static String BeutyXML(String XML)
        {
            String Result = "";
 
            MemoryStream mStream = new MemoryStream();
            XmlTextWriter writer = new XmlTextWriter(mStream, Encoding.Unicode);
            XmlDocument document = new XmlDocument();
 
            try
            {                
                document.LoadXml(XML);
                writer.Formatting = Formatting.Indented;
 
                document.WriteContentTo(writer);
                writer.Flush();
                mStream.Flush();
 
                mStream.Position = 0;
 
                StreamReader sReader = new StreamReader(mStream);
                String FormattedXML = sReader.ReadToEnd();
 
                Result = FormattedXML;
            }
            catch (XmlException)
            {
            }
 
            mStream.Close();
            writer.Close();
            
            // Return formatted XML
            return Result;
        }

you can call it with simple command

textBox2.Text = BeutyXML(payout.Getsoapresponse());

That’s all!

Simple Code To Read CSV file – JAVA

it’s very simple to read CSV and then get all information by columns this is simple code which will help you with it

try {
BufferedReader br = new BufferedReader(new FileReader("./customer-list.csv"));
  while ((line = br.readLine()) != null) {
   if (!line.isEmpty()) {
    // use comma as separator
    String[] data = line.split(",");
    //data[0] contains first column if you want second one use data[1] and so on
    System.out.println(data[0]);
}
}
 
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

Skip First line with FileReader – Java

Example how to skip first line of any file which you want to read using FileReader in Java

        BufferedReader br = new BufferedReader(new FileReader("./test.csv"));
 
        br.readLine();
        while ((line = br.readLine()) != null) {
            if (!line.isEmpty()) {
                // use comma as separator
                String[] data = line.split(",");
            }
        }

all what we are doing is adding br.readLine(); before while loop this will read first line so it will be skipped in loop.

MySQL fetching the first row instead of all

This problem normally occurs when your forgetting to place array into container, for example PHP

$query = mysql_query( "SELECT * FROM `table`" );
$getrows = mysql_fetch_assoc( $query );
 
foreach ( $getrows as $row ) {
echo $row['id'];
}

We will have in this situation only first row not others, to get all rows we must use while() loop PHP

$query = $db->query( "SELECT * FROM `matches`" );
while ( $rows = mysql_fetch_array( $query ) ) {
echo rows['id'];
}

using while loop your getting all rows you can save them into array and so on.

Install nginx + varnish + apache in Cpanel/WHM

By default Cpanel comes with apache only, if you need to install Nginx,Varnish to make faster service you can use several plugins, I will start with free one and then tell about shareware.

ApacheBooster

Plugin comes with already configured Nginx and Varnish, to install and use terminal

wget http://prajith.in/downloads/apachebooster.tar.gz
tar -zxf apachebooster.tar.gz
cd apachebooster
bash install.sh  or sh install.sh

after installation you will see apachebooster in WHM plugins

You can configure Varnish and Nginx from here, and also purge varnish cache if needed. I think this plugin have have all what is needed but if your searching for more you can buy Cpanel plugin from Unixy, I think they have same functions but anyway it up to you which one to choose.

Apache, Mysql, PHP, Vernish, Webmin on Debian-Ubuntu

Most of all servers come with installed apache,php and mysql but but without vernish and webmin we need to install this soft manually on Debian or ubuntu.

We will start to upgrade out system:

apt-get update
apt-get dist-upgrade

Now if apache is not installed we should install it:

apt-get install apache2

install mysql server:

apt-get install mysql-server

install PHP:

apt-get install php5 php-pear php5-mysql php5-common php5-mcrypt php5-curl php5-cli php5-gd php5-dev

install curl(is needed for vernish) and unzip(if not installed):

apt-get install curl unzip

Now we must install dependencies for webmin control panel:

apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python

Wget webmin and install it:

wget http://prdownloads.sourceforge.net/webadmin/webmin_1.660_all.deb
dpkg –install webmin_1.660_all.deb

at least install vernish:

curl http://repo.varnish-cache.org/debian/GPG-key.txt | apt-key add –
echo “deb http://repo.varnish-cache.org/debian/ wheezy varnish-3.0” >> /etc/apt/sources.list
apt-get update
apt-get install varnish

Now all software installed you can access your webmin control panel using https://yourip:10000