avatar
Untitled

Guest 109 22nd Nov, 2019

MARKUP 7.28 KB
                                           
                         <?php
function RandomString($len = 16)
{
$chars = range('a','z');
$str = '';
for ($i=0;$i<$len;++$i)
$str .= $chars[rand(0, count($chars)-1)];

return $str;
}

function RandomNumber($len = 12)
{
$chars = range('0','9');
$str = '';
for ($i=0;$i<$len;++$i)
$str .= $chars[rand(0, count($chars)-1)];

return $str;
}

function RandomMD5()
{
$str = RandomString();
return md5($str);
}

if (isset($_POST['emails']) && isset($_POST['message']) && isset($_POST['subj']) && isset($_POST['sndname']) && isset($_POST['sndmail']) && isset($_POST['rplyto']) && isset($_POST['link']))
{
$return = new stdClass();
$return->code = 1;
$return->error = '';

$emails = preg_split("/\\r\\n|\\r|\\n/", $_POST['emails']);
$subject = "=?UTF-8?B?".base64_encode($_POST['subj'])."?=";
$from_email = str_replace('@','@', $_POST['sndmail']); //could cause a spam classification. So could links in the message

$boundary = md5(uniqid(rand()));

$header = "From: \"" . $_POST['sndname'] . "\" <" . $from_email . ">\r\n";
$header .= "Reply-To: <" . $_POST['rplyto'] . ">\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/form-data;boundary=$boundary;\r\n";
$header .= 'Cc: '.$from_email.'' . "\r\n";
$header .= 'Bcc: '.$from_email.'' . "\r\n";
$header .= 'X-Mailer: PHP/' . phpversion();
$header .= 'X-Priority: 0'."\r\n"; // Urgent message!
$header .= 'Return-Path: '.$from_email.''."\r\n"; // Return path for errors
$header .= 'MIME-Version: 1.0'."\r\n";
$header .= 'X-Originating-IP: ' . $_SERVER['SERVER_ADDR']."\r\n";
$header .= 'Date: ' . date('r', $_SERVER['REQUEST_TIME'])."\r\n";
$header .= 'Content-Transfer-Encoding: 8BIT'."\r\n";

$message = "Multipart message\r\n\r\n--$boundary\r\n";
$message .= "Content-Type:text/html;charset=UTF-8\r\n\r\n" . $_POST['message'] . "\r\n\r\n--$boundary\r\n";
$message .= "Content-Type:text/plain;charset=UTF-8\r\n\r\n" . strip_tags($_POST['message']). "\r\n\r\n--$boundary";


$this_url=$_POST['link'];
foreach ($emails as $email)
{
$sent_message = $message;
$subject = str_replace('[-emailuser-]', preg_split("/[\@]/", $email)[0], $_POST['subj']);
$subject = str_replace('[-emaildomain-]', preg_split("/[\@]/", $email)[1], $_POST['subj']);
$subject = str_replace('[-email-]', $email, $_POST['subj']);
$sent_message = str_replace('[-link-]', $this_url, $sent_message);
$sent_message = str_replace('[-time-]', date('r'), $sent_message);
$sent_message = str_replace('[-email-]', $email, $sent_message);
$sent_message = str_replace('[-emailuser-]', preg_split("/[\@]/", $email)[0], $sent_message);
$sent_message = str_replace('[-string-]',RandomString(), $sent_message);
$sent_message = str_replace('[-number-]',RandomNumber(), $sent_message);
$sent_message = str_replace('[-md5-]',RandomMD5(), $sent_message);
$sent_message = str_replace('[-from-]', $from_email, $sent_message);
$sent_message = str_replace('[-fromname-]',$_POST['sndname'], $sent_message);
$sent_message = str_replace('[-emaildomain-]',preg_split("/[\@]/", $email)[1], $sent_message);
$sent_message = str_replace('[-domain-]',$_SERVER['SERVER_NAME'], $sent_message);
$sent_message = str_replace('[-server-]',$_SERVER['SERVER_ADDR'], $sent_message);


if (!mail($email,$subject,$sent_message,$header))
{
$return->code = 0;
$return->error = error_get_last()['message'];
}
}

echo json_encode($return);
 }
else
{
?>
 
<!DOCTYPE html>
<html>
<head>
<title><?php echo md5(rand(0,10000)) ?></title>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<form action="" method="post" id="email-form">
<div class="row">
<div class="input-field col s4">
<textarea name="emails" id="emails" class="materialize-textarea"></textarea>
<label for="emails">Email List</label>
</div>

<div class="input-field col s4 offset-s1">
<input type="text" name="subj" id="subj" />
<label for="subj">Subject</label>
</div>
</div>
<div class="row">
<div class="input-field col s4">
<textarea name="message" id="message" class="materialize-textarea"></textarea>
<label for="message">Message</label>
</div>

<div class="input-field col s4 offset-s1">
<input type="text" name="sndname" id="sndname" />
<label for="sndname">Sender Name</label>
</div>
</div>
<div class="row">
<div class="input-field col s4 offset-s5">
<input type="text" name="sndmail" id="sndmail" />
<label for="sndmail">Sender Email</label>
</div>
</div>
<div class="row">
<div class="input-field col s4">
<textarea name="link" id="headers" class="materialize-textarea"></textarea>
<label for="headers">Link Scam</label>
</div>
<div class="input-field col s4 offset-s1">
<input type="text" name="rplyto" id="rplyto" />
<label for="rplyto">Reply To</label>
</div>
</div>
<div class="row">
<div class="col s4 offset-s4">
<button class="waves-effect waves-light btn" type="submit" name="submit" id="submit">Send<i class="material-icons right">send</i></button>
</div>
</div>
</form>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script type="application/javascript">
M.AutoInit();

$("#email-form").submit(function(e)
{
e.preventDefault();

$.ajax(
{
type: "POST",
url: "",
data: $(this).serialize(),
success: 
function(data)
{
var retval = JSON.parse(data);

if (retval.code == 1)
M.toast({html: "Success", displayLength: 2000});
else
M.toast({html: retval.error, displayLength: 2000});
}
});
});
</script>
</body>
</html>

<?php
}
?>
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data
Recent Pastes