-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendmail.php
150 lines (119 loc) · 4.24 KB
/
sendmail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
/**
* BynaMailer.
* PHP Version 5
* @package PHPMailer
* @link https://github.com/bynalab/bynamailer-v4
* @author Abubakar Abdusalam (bynalab) <[email protected], [email protected]>
* @website https://bynalab.com
* @copyright 2012 - 2014 Marcus Bointon
* @note This program is distributed in the hope that it will be useful - WITHOUT
*/
error_reporting(0);
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
//Checks for malicious url
require 'check_malicious.php';
$bynamailer = new PHPMailer(true);
$tos = b_trim($_POST['recipient']);
$subject = b_trim($_POST['subject']);
$message = b_letter($_POST['message']);
$bynaAttach = $_FILES['bynaAttach'];
$delay = $_POST['delay'];
$bynapostmaster = b_trim($_POST['bynapostmaster']);
$sender = b_trim($_POST['sender']);
$link = $_POST['link'];
$smtpserver = $_POST['smtpserver'];
$smtpuser = $_POST['smtpuser'];
$smtppass = $_POST['smtppass'];
$link = explode("\n", $link);
$clinks = count($link);
function smtp_exist($smtpserver) {
if( $smtpserver != ""){
return true;
}
else {
return false;
}
}
function b_letter($letter){
$letter= b_trim($letter);
$letter = urlencode($letter);
$letter = preg_replace("/%5C%22/", "/%22/", $letter);
$letter = urldecode($letter);
$letter = stripslashes($letter);
return $letter;
}
function b_replace($text,$email, $link = array()){
$user = explode('@',$email);
$host = explode('.', $user[1])[0];
$text = str_replace('{random}', strtoupper(substr(md5(microtime()),10,10)), $text);
$text = str_replace('{md5}', substr(md5(microtime()),10,10), $text);
$text = str_replace('{time}', date("h:i:s A"), $text);
$text = str_replace('{date}', date("m/d/Y"), $text);
$text = str_replace('{email}', $email, $text);
$text = str_replace('{base64email}', base64_encode($email), $text);
$text = str_replace('{mename}', $user[0], $text);
$text = str_replace('{domain}', $user[1], $text);
$text = str_replace('{frmsite}', $host, $text);
$text = str_replace('{link}', $link[rand(0, $GLOBALS['clinks']-1)], $text);
return $text;
}
function b_trim($string){
return stripslashes(ltrim(rtrim($string)));
}
function b_check($email){
$exp = "^[a-z\'0-9]+([._-][a-z\'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+))+$";
if(eregi($exp,$email)){
if(@checkdnsrr(array_pop(explode("@",$email)),"MX")){return true;}
else{return false;}
}
else{return false;}
}
try {
if( smtp_exist($smtpserver) ){
//$bynamailer->SMTPDebug = SMTP::DEBUG_SERVER;
$bynamailer->isSMTP();
$bynamailer->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$bynamailer->Host = $smtpserver;
$bynamailer->SMTPAuth = true;
$bynamailer->Username = $smtpuser;
$bynamailer->Password = $smtppass;
$bynamailer->Port = 587;
}
$bynamailer->setFrom($bynapostmaster, $sender);
$bynamailer->addReplyTo('[email protected]', 'No Reply');
$to = explode("\n", $tos);
$countEmail = count($to);
$countArray = 0;
$over = 0;
while($to[$countArray])
{
$mail = str_replace(array("\n","\r\n"),'',$to[$countArray]);
$bynamailer->addAddress($mail);
//Content
$bynamailer->isHTML(true);
$bynamailer->Subject = b_replace($subject, $mail);
$bynamailer->Body = b_replace($message, $mail, $link);
if($bynaAttach['tmp_name'] != ""){
$bynamailer->AddAttachment($bynaAttach['tmp_name'],$bynaAttach['name']);
}
if($resp != 1){
$bynamailer->send();
} else {
//Prevent mailer from sending flagged url to recipients.
echo "Link is Malicious.";
break;
}
$countArray++;
$over++;
$bynamailer->ClearAddresses();
echo "<font color=green face=verdana size=2>Successfully sent to ".trim($mail)." (".$over." OF ".$countEmail.") <br>\n";
//sleep(rand(3, $delay));
}
} catch (Exception $e) {
echo "<font color=red face=verdana size=2>Oops! Message could not be sent to ".trim($mail)."... Mailer Error: {$bynamailer->ErrorInfo}. <br>\n";
}
?>