Last active
January 7, 2019 11:09
-
-
Save RahulSaini91/e853d5af5cd3af44d36640417ff4ce5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php error_reporting(0); session_start(); $input = input(); date_default_timezone_set('Asia/Kolkata'); $mail = array(); | |
/* | |
****************************************** | |
********* READ FULL TUTORIAL AT: ******** | |
***** http://tutorials.weforit.com ****** | |
****************************************** | |
*/ | |
/* | |
****************************************** | |
******** MAKE CHANGES AS YOU WANT ******** | |
****************************************** | |
*/ | |
/* | |
***************************************** | |
********** MAIL CONFIGURATION *********** | |
***************************************** | |
*/ | |
// the path of PHP Mailer Directory, leave blank if you want to use default php mail function | |
$_config['phpmailer'] = ''; | |
$mail['to'] = 'contact@weforit.com'; //replace with your email, multiple email id seperated by comma | |
$mail['from_name'] = 'WeForIT - Get Free Tricks and Tutorials'; //replace with yours | |
$mail['from_mail'] = 'contact@weforit.com'; //replace with yours | |
$mail['subject'] = "A New Contact Message Received"; | |
$mail['message'] = ' | |
<p><b>Details of sender:</b></p> | |
{fields} | |
- Thanks & Regards | |
'; | |
$mail2['enable'] = 1; | |
$mail2['to'] = '{email}'; | |
$mail2['subject'] = 'Thanks for contacting us'; | |
$mail2['message'] = ' | |
<p> | |
Dear {name},<br/> | |
Thanks for Contacting us, our team will respond your message within 1-2 business days<br/> | |
<br/> | |
<b>- Thanks & Regards</b><br/> | |
WeForIT Team<br/> | |
contact@weforit.com | www.weforit.com | |
'; | |
/* | |
****************************************** | |
******** DON'T MODIFY CODE BELOW ********* | |
****************************************** | |
*/ | |
/* Mail headers */ | |
$mail['headers'][] = "MIME-Version: 1.0" . "\r\n"; | |
$mail['headers'][] = "Content-type:text/html;charset=UTF-8" . "\r\n"; | |
$mail['headers'][] = "From: ".$mail['from_name']." <".$mail['from_mail'].">"."\r\n"; | |
$mail['headers'] = join('',$mail['headers']); | |
if($_SERVER['REQUEST_METHOD'] == 'POST'){ | |
$field = array(); | |
foreach($_POST as $key => $value){ | |
$key = htmlentities(trim(utf8_encode(strip_tags($key)))); | |
$value = htmlentities(trim(utf8_encode(strip_tags($value)))); | |
$field[$key] = $value; | |
} | |
echo send_mail($field); | |
} | |
function send_mail($fields){ | |
global $mail,$mail2; | |
$m = '<html><head><title>'.$mail['subject'].'</title></head><body><table>'; | |
if(is_array($fields) && count($fields) > 0){ | |
foreach($fields as $key => $value){ | |
if(!$value){ | |
continue; | |
} | |
$m .= ' | |
<tr> | |
<th align="left" valign="top">'.ucwords(str_replace(array('_','-'),' ',$key)).'</th> | |
<th valign="top">:</th> | |
<td valign="top">'.nl2br($value).'</td> | |
</tr> | |
'; | |
} | |
} | |
$m .= '</table></body></html>'; | |
$mail['message'] = str_replace('{fields}',$m,$mail['message']); | |
$to = explode(",",$mail['to']); | |
$status = 0; | |
foreach($to as $_to){ | |
$_to = strtolower($_to); | |
if(!filter_var($_to,FILTER_VALIDATE_EMAIL)){ | |
continue; | |
} | |
//require_once 'PHPMailer.php'; /* COMING SOON */ | |
if(mail($_to,$mail['subject'],$mail['message'],$mail['headers'],'-f'.$mail['from_mail'])){ | |
$status = 1; | |
} | |
} | |
if($status == 1 && $mail2['enable'] == 1){ | |
//send second mail | |
$search = array(); | |
$replace = array(); | |
foreach($fields as $key => $value){ | |
$search[] = '{'.$key.'}'; | |
$replace[] = $value; | |
} | |
$mail2['to'] = str_replace($search,$replace,$mail2['to']); | |
$mail2['subject'] = str_replace($search,$replace,$mail2['subject']); | |
$mail2['message'] = str_replace($search,$replace,$mail2['message']); | |
mail($mail2['to'],$mail2['subject'],$mail2['message'],$mail['headers'],'-f'.$mail['from_mail']); | |
} | |
return $status; | |
} | |
function input(){ | |
$input = array(); | |
foreach($_POST as $key => $value){ | |
$key = htmlentities(trim(utf8_encode(strip_tags($key)))); | |
$value = htmlentities(trim(utf8_encode(strip_tags($value)))); | |
$input[$key] = $value; | |
} | |
foreach($_GET as $key => $value){ | |
$key = htmlentities(trim(utf8_encode(strip_tags($key)))); | |
$value = htmlentities(trim(utf8_encode(strip_tags($value)))); | |
$input[$key] = $value; | |
} | |
foreach($_REQUEST as $key => $value){ | |
$key = htmlentities(trim(utf8_encode(strip_tags($key)))); | |
$value = htmlentities(trim(utf8_encode(strip_tags($value)))); | |
$input[$key] = $value; | |
} | |
foreach($_FILES as $key => $value){ | |
$key = htmlentities(trim(utf8_encode(strip_tags($key)))); | |
$value = htmlentities(trim(utf8_encode(strip_tags($value)))); | |
$input[$key] = $value; | |
} | |
return (object)$input; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment