<?php 
function sendMail( $data ) {
  require 'PHPMailer/PHPMailerAutoload.php';

  $mail         = new PHPMailer(true); 
  try {

    $mail->isSMTP();
    $mail->SMTPDebug    = 0;
    $mail->Host         = 'smtp.gmail.com';  
    $mail->SMTPAuth     = TRUE;      
    $mail->Username     = 'attrans02@gmail.com'; 
    $mail->Password     = 'attrans@1110'; 
    $mail->SMTPSecure   = TRUE;          
    $mail->Port         = 465; 

      $mail->setFrom('attrans02@gmail.com', 'OM ROAD CARRIERS PVT.LTD.');

      $mail->addAddress($data['to_email']);

      if( isset( $data['cc_emails'] ) && !empty( $data['cc_emails'] ) ) {
        if( is_array($data['cc_emails']) ) {
          $e_mails = $data['cc_emails'];
        } else {
          $e_mails = explode(',', $data['cc_emails']);
        }

        foreach ($e_mails as $e_mail) {
          $mail->AddCC($e_mail);
        }
      }

      $mail->isHTML(true);

      $mail->Subject = $data['subject'];
      $mail->Body    = $data['message'];
    
    $mail->send();
    
    return true;
  } catch (Exception $e) {
    return false;
  }
}
?>