
<?php
if($_REQUEST['action']=='mail' && $_REQUEST['id']!='')
{
//**************************mail functin ***********************************************************
 
function dateDiff1($d1, $d2)
  {
        return round(abs(strtotime($d1)-strtotime($d2))/86400)+1;
  } 
   
    require_once('mailerfunction/phpmailer/class.phpmailer.php'); 
   // include("../../class.smtp.php"); 

  function sendMail($to_mail,$maildata,$email_id)
  {
    

    //$to="manoj@acgil.com,dinesh@acgil.com,ravindra@acgil.com";
  
       
      // optional, gets called from within class.phpmailer.php if not already loaded
        // telling the class to use SMTP
      
     
       $to  =  $to_mail;
      //die;
        $email=$email_id;
        $subject="Offer letter";
         $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
        $mail->IsSMTP();
        try {
        
            $mail->Host       = "mail.marketing.i2k2.com"; // SMTP server
            $mail->SMTPDebug  = 0;                     // enables SMTP debug information (for testing)
            $mail->SMTPAuth   = true;                  // enable SMTP authentication
            //$mail->Host       = "host2.777networks.com"; // sets the SMTP server
            $mail->Host       = "mail.marketing.i2k2.com"; // sets the SMTP server
            $mail->Port       = 25;
            $mail->Username   = "authsasl@marketing.i2k2.com"; // SMTP account username
            $mail->Password   = "MtaMyNetwork?1024?";        // SMTP account password
            //$mail->Password   = "123456";        // SMTP account password
            $mail->AddReplyTo($email);
            $mail->AddAddress($to);
            //$mail->SetFrom($email);
            $mail->SetFrom($email);
            $mail->Subject = $subject;
            $mail->AltBody = $maildata; // optional - MsgHTML will create an alternate automatically
            //$mail->MsgHTML(file_get_contents('contents.html'));
            $mail->MsgHTML($maildata);
            //$mail->AddAttachment('images/phpmailer.gif');      // attachment
            //$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
             if($mail->Send())
              $errorMsg="Sucessfully send";
             else
              $errorMsg="Not Sucessfully send";
            
          } catch (phpmailerException $e) {
          
          } catch (Exception $e) {
          }
       
      return 1;
  }

   $to=$s->getField('hr_applcnt_rgstn','id',$_REQUEST['id'],'email1');
   $fromemail=$s->getField('www_users','id',$_SESSION['UserID'],'email');  
  
   $from='From'. ':- '. ' '.$fromemail ;
  $name=$s->getField('hr_applcnt_rgstn','id',$_REQUEST['id'],'first_name');
 $message="Mr / Ms". ":- ". $name. " " ."<br>". "This is a offer letter confirmation mail";
  $asd=0;
if(sendMail($to,$message,$fromemail)){
  $qt=DB_query("UPDATE hr_applcnt_rgstn SET no_mail=no_mail+1 where id='".$_REQUEST['id']."'",$db);
    echo "<script> alert('Email is sent '); </script>";
    $s->pageLocation("index.php?route=HRModule/Master/offered"."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']);
}
else
{
  echo "<script> alert('Email is not sent '); </script>";
  $s->pageLocation("index.php?route=HRModule/Master/offered"."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']);
     }
}

?>

