if(isset($_POST['contmode']) && $_POST['contmode']=="submit"){
if(trim($_POST['cust_name']) == "" || !preg_match("/^[A-z ]{3,}$/",$_POST['cust_name']))
{
$error_msg[]="Please Enter Your Valid Name";
}
elseif(trim($_POST['emailid'])=="" || !preg_match("/^[A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/",$_POST['emailid']))
{
$error_msg[]="Please Enter Your Valid Email";
}
elseif(trim($_POST['phone'])=="" || !preg_match("/^[6-9]{1}[0-9]{9}$/",$_POST['phone']))
{
$error_msg[]="Please enter your Phone Number";
}
elseif(trim($_POST['message'])=="" || !preg_match("/^[A-z 0-9\.]+$/",$_POST['message']))
{
$error_msg[]="Please enter your Message";
}
elseif(trim($_POST['c_letters_code'])=="")
{
$error_msg[]="Please enter Captcha Code";
}
elseif (empty($_SESSION['c_letters_code'] ) || strcasecmp($_SESSION['c_letters_code'], $_POST['c_letters_code']) != 0){
$error_msg[]="The Captcha Validation code not match.";
}
if(isset($error_msg[0]) && $error_msg[0]!=''){
$cust_name = $_POST['cust_name'];
$emailid = $_POST['emailid'];
$phone = $_POST['phone'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$wrongcaptcha = $error_msg[0];
} else {
$upload_dir_1='uploaded_file/';
if($_FILES['uploaded_file']['name']!="")
{
$file_name1=$_FILES['uploaded_file']['name'];
$fname_arr=explode(".",$file_name1);
$file_namee=$fname_arr[count($fname_arr)-1];
$allowedExts = array('png', 'gif', 'jpg', 'jpeg', 'bmp','pdf','docx','xml','txt', 'PNG', 'GIF', 'JPG', 'JPEG', 'BMP','PDF','DOCX','XML','TXT');
if (in_array($file_namee, $allowedExts) && ($_FILES["uploaded_file"]["size"] <= 10485760)){
$file_name1=$fname_arr[0].time().".".$file_namee;
$tmp_name=$_FILES['uploaded_file']['tmp_name'];
$file_size=$_FILES['uploaded_file']['size'];
copy($tmp_name,$upload_dir_1.$file_name1);
}
}
$MailAttachment1=$upload_dir_1.$file_name1;
require_once("class/class.phpmailer.php");
$mail = new PHPMailer();
// emial Configuration info
$MailTo= 'dip@infosky.co.in';
$MailToName='';
$MailFrom=SMTP_USERNAME;
$MailFromName='';
$MailSubject='Contact form details from Stormnet Connect Private Limited for '.$_POST['cust_name'];
$MailHtmlMessage='
Stormnet Connect Private Limited Contact form details |
'.date('F j, Y, g:i:s a').' |
|
Name : |
'.stripslashes($_POST['cust_name']).' |
E-Mail : |
'.stripslashes($_POST['emailid']).' |
Phone : |
'.stripslashes($_POST['phone']).' |
Message : |
'.stripslashes($_POST['message']).' |
|
';
$IsMailType='SMTP';
$SmtpHost = SMTP_HOST; // sets the SMTP server
$SmtpDebug = 0; // enables SMTP debug information (for testing)
$SmtpAuthentication = true; // enable SMTP authentication
$SmtpPort = SMTP_PORT; // set the SMTP port for the GMAIL server
$SmtpUsername = SMTP_USERNAME; // SMTP account username
$SmtpPassword = SMTP_PASSWORD; // SMTP account password
if ( $IsMailType == "SMTP" ) {
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug = $SmtpDebug;
$mail->SMTPAuth = $SmtpAuthentication; // enable SMTP authentication
$mail->Port = $SmtpPort; // set the SMTP port
$mail->Host = $SmtpHost; // SMTP server
$mail->Username = $SmtpUsername; // SMTP account username
$mail->Password = $SmtpPassword; // SMTP account password
} elseif ( $IsMailType == "mail" ) {
$mail->IsMail(); // telling the class to use PHP's Mail()
} elseif ( $IsMailType == "sendmail" ) {
$mail->IsSendmail(); // telling the class to use Sendmail
} elseif ( $IsMailType == "qmail" ) {
$mail->IsQmail(); // telling the class to use Qmail
}
if ( $MailFromName != '' ) {
$mail->AddReplyTo($MailFrom,$MailFromName);
$mail->From = $MailFrom;
$mail->FromName = $MailFromName;
} else {
$mail->AddReplyTo($MailFrom);
$mail->From = $MailFrom;
$mail->FromName = $MailFrom;
}
if ( $MailToName != '' ) {
$mail->AddAddress($MailTo,$MailToName);
} else {
$mail->AddAddress($MailTo);
}
//$mail->AddBCC('pay2b@rediffmail.com');
$mail->Subject = $MailSubject;
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML($MailHtmlMessage);
if($file_name1!="")
{ $mail->AddAttachment($MailAttachment1); }
// attachment
// $mail->AddAttachment($MailAttachment2); // attachment
if ( !$mail->Send() ) {
$error = "Unable to send to: " . $to . "
";
throw new phpmailerAppException($error);
} else {
$succsscaptcha='Your Contact Form Successfully Submitted.';
if($file_name1!="")
{ unlink($MailAttachment1); }
}
}
}
?>