D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
balhit1357
/
balhit.ac.in
/
OldSite
/
Filename :
SendMail.php
back
Copy
<?php require('recaptcha-master_new/src/autoload.php'); include "include/z_db.php"; /*Here we are going to declare the variables*/ echo $sMessage = "Name : ".$_POST('Name')."<br>E-mail : ".$_POST('email')."<br>Birth Date : ".$_POST('Birth_Date')."<br>Citizenship : ".$_POST('Citizenship')."<br>Designation : ".$_POST('Father_Name')."<br>Phone No : ".$_POST('Tel_No')."<br>Office Address : ".$_POST('Office_Address')."<br>Marital Status : ".$_POST('Marital_Status')."<br>Father / Husband Name : ".$_POST('Husband_Name')."<br>permanent Address : ".$_POST('Permanent_Address')."<br>Year of Passing Out : ".$_POST('Year_of_Passing_out')."<br>Faculty : ".$_POST('Faculty')."<br>Additional Qualification : ".$_POST('Add_Qualfi_')."<br>Professional Qualification : ".$_POST('Prof_Qualfi')."<br>College / University : ".$_POST('Col2')."<br>Higher Qualification : ".$_POST('Higher_Qualfi')."<br>College / University : ".$_POST('Col3')."<br>Suggestions : ".$_POST('Suggestion'); //Save visitor name and entered message into one variable: $formcontent=$sMessage; $recipient = "balvidyalaya74@gmail.com, mayanksagrawal@gmail.com"; $subject = "Alumni Request"; $mailheader = "From: balvidyalaya74@gmail.com"; $mailheader .= "Reply-To: balvidyalaya74@gmail.com\\r\\n"; $mailheader .= "MIME-Version: 1.0\\r\\n"; $res = sock_mail(1,$recipient,"Alumni Request",$formcontent,$mailheader,"info@spiralspecialist.com");//sock version, usable on Win32 //this is the sock mail function function sock_mail($auth,$to, $subj, $body, $head, $from){ $lb="\r\n"; //linebreak $body_lb="\r\n"; //body linebreak $loc_host = "74.50.110.226"; //localhost $smtp_acc = "info@spiralspecialist.com"; //account $smtp_pass="098890"; //password $smtp_host="localhost"; //server SMTP $hdr = explode($lb,$head); //header if($body) {$bdy = preg_replace("/^\./","..",explode($body_lb,$body));} // build the array for the SMTP dialog. Line content is array(command, success code, additonal error message) if($auth == 1){// SMTP authentication methode AUTH LOGIN, use extended HELO "EHLO" $smtp = array( // call the server and tell the name of your local host array("EHLO ".$loc_host.$lb,"220,250","HELO error: "), // request to auth array("AUTH LOGIN".$lb,"334","AUTH error:"), // username array(base64_encode($smtp_acc).$lb,"334","AUTHENTIFICATION error : "), // password array(base64_encode($smtp_pass).$lb,"235","AUTHENTIFICATION error : ")); } else {// no authentication, use standard HELO $smtp = array( // call the server and tell the name of your local host array("HELO ".$loc_host.$lb,"220,250","HELO error: ")); } // envelop $smtp[] = array("MAIL FROM: <".$from.">".$lb,"250","MAIL FROM error: "); $smtp[] = array("RCPT TO: <".$to.">".$lb,"250","RCPT TO error: "); // begin data $smtp[] = array("DATA".$lb,"354","DATA error: "); // header $smtp[] = array("Subject: ".$subj.$lb,"",""); $smtp[] = array("To:".$to.$lb,"",""); foreach($hdr as $h) {$smtp[] = array($h.$lb,"","");} // end header, begin the body $smtp[] = array($lb,"",""); if($bdy) {foreach($bdy as $b) {$smtp[] = array($b.$body_lb,"","");}} // end of message $smtp[] = array(".".$lb,"250","DATA(end)error: "); $smtp[] = array("QUIT".$lb,"221","QUIT error: "); // open socket $fp = @fsockopen($smtp_host, 25); if (!$fp) echo "<b>Error:</b> Cannot conect to ".$smtp_host."<br>"; $banner = @fgets($fp, 1024); // perform the SMTP dialog with all lines of the list foreach($smtp as $req){ $r = $req[0]; // send request @fputs($fp, $req[0]); // get available server messages and stop on errors if($req[1]){ while($result = @fgets($fp, 1024)){if(substr($result,3,1) == " ") { break; }}; if (!strstr($req[1],substr($result,0,3))) echo"$req[2].$result<br>"; } } $result = @fgets($fp, 1024); // close socket @fclose($fp); return 1; } $recaptchaSecret = '6Led0qsUAAAAAHAxEQj-6aS41WNOU5eDSv0dj8M9'; // let's do the sending // if you are not debugging and don't need error reporting, turn this off by error_reporting(0); error_reporting(E_ALL & ~E_NOTICE); try { if (!empty($_POST)) { // validate the ReCaptcha, if something is wrong, we throw an Exception, // i.e. code stops executing and goes to catch() block if (!isset($_POST['g-recaptcha-response'])) { throw new \Exception('ReCaptcha is not set.'); } // do not forget to enter your secret key from https://www.google.com/recaptcha/admin $recaptcha = new \ReCaptcha\ReCaptcha($recaptchaSecret, new \ReCaptcha\RequestMethod\CurlPost()); // we validate the ReCaptcha field together with the user's IP address $response = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']); if (!$response->isSuccess()) { throw new \Exception('ReCaptcha was not validated.'); } // everything went well, we can compose the message, as usually $emailText = "You have a new message from your contact form\n=============================\n"; foreach ($_POST as $key => $value) { // If the field exists in the $fields array, include it in the email if (isset($fields[$key])) { $emailText .= "$fields[$key]: $value\n"; } } // All the neccessary headers for the email. $headers = array('Content-Type: text/plain; charset="UTF-8";', 'From: ' . $from, 'Reply-To: ' . $from, 'Return-Path: ' . $from, ); // Send email mail($sendTo, $subject, $emailText, implode("\n", $headers)); $responseArray = array('type' => 'success', 'message' => $okMessage); } } catch (\Exception $e) { $responseArray = array('type' => 'danger', 'message' => $e->getMessage()); } if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { $encoded = json_encode($responseArray); header('Content-Type: application/json'); echo $encoded; } else { echo $responseArray['message']; } ?>