public List <string> Send() { List <string> data = new List <string>(); List <Task> tasks = new List <Task>(); foreach (dynamic server in Servers) { tasks.Add( Task.Factory.StartNew(() => { try { Pmta p = new Pmta((string)server.mainip, (string)server.password, (string)server.username, (int)server.port); foreach (dynamic ip in server.ips) { string email_ip = ip.ip; string domain = ip.domain; string rdns = Text.Rdns(email_ip, domain); string vmta = ip.vmta; for (int i = 0; i < Loop; i++) { foreach (string email in Emails) { string emailName = email.Split('@')[0]; string boundary = Text.Random("[rndlu/30]"); string bnd = Text.Boundary(Header); string hd = Text.ReplaceBoundary(Header); string rp = Text.Build_rp(Return_path, domain, rdns, emailName, "", "", (string)ip.idi, (string)ip.idd, (string)ip.ids, (string)server.name); hd = Text.Build_header(Header, email_ip, (string)server.name, domain, rdns, email, emailName, boundary, bnd, "", "", (string)ip.idi, (string)ip.idd, (string)ip.ids); hd = Text.Inject_header(hd, "t", "0", Username, email_ip, (string)ip.idd); string bd = Text.Build_body(Body, email_ip, (string)server.name, domain, rdns, email, emailName, null, null, null, boundary, bnd, "", "", (string)ip.idi, (string)ip.idd, (string)ip.ids); Message Message = new Message(rp); Message.AddData(Text.ReplaceBoundary(hd + "\n" + bd + "\n\n", bnd)); Message.AddRecipient(new Recipient(email)); Message.VirtualMTA = vmta; Message.JobID = $"0_WARMUP_{Username}_{Id}"; Message.EnvID = Id; Message.Verp = false; Message.Encoding = Encoding.EightBit; p.Send(Message); Thread.Sleep(Sleep * 1000); //sleep } } } data.Add($"SERVER {server.mainip} OK"); p.Close(); } catch (Exception ex) { data.Add($"ERROR SERVER {server.mainip} - {ex.Message}"); logger.Error(ex.Message); } }) ); } Task.WaitAll(tasks.ToArray()); return(data); }
public List <string> Send() { List <string> Result = new List <string>(); Campaign campaign = new Campaign(Artisan); int c_seed = 0; int placeholder_counter = 1; Random random = new Random(); dynamic cdata = campaign.Campaign_info(Id); if (cdata != null) { string raw_rp = Convert.ToString(cdata.return_path) ?? ""; string[] seed_emails = Campaign.Convert_emails(Convert.ToString(cdata.email_test)); string raw_hd = Text.Base64Decode(Convert.ToString(cdata.header)); string raw_bd = Text.Base64Decode(Convert.ToString(cdata.body)); var servers = Campaign.Convert_ips(Convert.ToString(cdata.ips), Convert.ToString(cdata.option)); if (servers.Count == 0) { Result.Add("No Servers To Process"); logger.Error("No Servers To Process"); campaign.Campaign_update_progress(Id, "start", true, 0); return(Result); } string file = "/" + Convert.ToString(cdata.send_file); bool IsPlaceholder = Convert.ToString(cdata.is_placeholder) == "1"; if (IsPlaceholder) { Placeholder = new Placeholder(cdata.placeholder_data, (int)cdata.placeholder_every); } bool IsAutoReply = Convert.ToString(cdata.is_auto_reply) == "1"; if (IsAutoReply) { Reply = new Rotation(cdata.auto_reply_data, (int)cdata.auto_reply_every); } bool IsNegative = Convert.ToString(cdata.is_negative) == "1"; if (IsNegative && string.IsNullOrEmpty(Negative)) { Negative = campaign.Campaign_negative(Convert.ToString(cdata.negative)); } if (IsNegative) { raw_bd = Text.Build_negative(raw_bd, Negative); } //read all config then loop, fixed content for (int i = 0; i < Loop; i++) //loop { Console.WriteLine("Reply Loop : " + i); foreach (var server in servers) { try { var details_server = campaign.Server_info(int.Parse((string)server.Key)); if (details_server != null) { Pmta p = new Pmta((string)details_server.ip, Password); //load pmta foreach (var ip in server.Value) { var info_send = campaign.Campaign_send_info(Id); if (info_send != null) { int total_send = 0, value_to_send = 0; //check fraction int total_sended = int.Parse((string)info_send.send_progress); int file_count = int.Parse((string)info_send.send_count); if (total_sended + Fraction >= file_count) { if (file_count - total_sended <= 0) { campaign.Campaign_update_progress(Id, "finish", true, 0); Result.Add("Campaign Ended" + Id); p.Close(); //close return(Result); } else { value_to_send = file_count - total_sended; } } else { value_to_send = Fraction; } //load emails List <string[]> emails = File.ReadLines(Storage + file).Skip(total_sended).Take(value_to_send) .Select(t => t.Trim().Split(',')) .Where(item => item.Length == 2) .ToList(); if (emails.Count > 0) { string rdns = Text.Rdns(ip["ip"], ip["domain"]); foreach (string[] email in emails) { string currentEmail = IsAutoReply ? Reply.GetAndRotate() : email[1]; string key = Text.Adler32($"{Id}{email[0]}"); string redirect = Text.Base64Encode($"{Id}-{email[0]}-{key}-{SendId}-{random.Next(1000, 999999)}"); string unsubscribe = Text.Base64Encode($"{Id}-{email[0]}-{key}-{SendId}-{random.Next(1000, 999999)}"); string open = Text.Base64Encode($"{Id}-{email[0]}-{key}-{SendId}-{random.Next(1000, 999999)}"); string boundary = Text.Random("[rndlu/30]"); string bnd = Text.Boundary(raw_hd); string hd = Text.ReplaceBoundary(raw_hd); string bd = Text.ReplaceBoundary(raw_bd); string emailName = email[1].Split('@')[0]; string rp = Text.Build_rp(raw_rp, ip["domain"], rdns, emailName, currentEmail, ip["idi"], ip["idd"], ip["ids"], (string)details_server.name + ip["ids"], email[1]); rp = IsPlaceholder ? Placeholder.ReplaceRotate(rp, placeholder_counter) : rp; // replace and rotate return path hd = Text.Build_header(hd, ip["ip"], (string)details_server.name + ip["ids"], ip["domain"], rdns, email[1], emailName, boundary, bnd, currentEmail, ip["idi"], ip["idd"], ip["ids"], email[0]); hd = IsPlaceholder ? Placeholder.ReplaceRotate(hd, placeholder_counter) : hd; //replace and rotate header hd = Text.Inject_header(hd, "x", Id.ToString(), Username, ip["ip"], ip["idd"], email[0]); bd = Text.Build_body(bd, ip["ip"], (string)details_server.name + ip["ids"], ip["domain"], rdns, email[1], emailName, redirect, unsubscribe, open, boundary, bnd, currentEmail, ip["idi"], ip["idd"], ip["ids"], email[1]); bd = IsPlaceholder ? Placeholder.ReplaceRotate(bd, placeholder_counter) : bd; //replace and rotate body Message message = new Message(rp); message.AddData(Text.ReplaceBoundary(hd + "\n" + bd + "\n\n", bnd)); message.AddRecipient(new Recipient(currentEmail)); message.VirtualMTA = ip["vmta"]; message.JobID = Id.ToString(); message.EnvID = Id.ToString(); message.Verp = false; message.Encoding = Encoding.EightBit; p.Send(message); total_send++; c_seed++; //Task.Run(() => campaign.Campaign_update_send(Id, total_send + total_sended)); campaign.Campaign_update_send(Id, total_send + total_sended); if (Seed != 0 && c_seed % Seed == 0 && seed_emails.Length > 0) { foreach (string test_email in seed_emails) { string currentTest = IsAutoReply ? Reply.GetCurrent() : test_email; string tkey = Text.Adler32($"{Id}0"); string tredirect = Text.Base64Encode($"{Id}-0-{tkey}-{SendId}-{random.Next(1000, 999999)}"); string tunsubscribe = Text.Base64Encode($"{Id}-0-{tkey}-{SendId}-{random.Next(1000, 999999)}"); string topen = Text.Base64Encode($"{Id}-0-{tkey}-{SendId}-{random.Next(1000, 999999)}"); string tboundary = Text.Random("[rndlu/30]"); string tbnd = Text.Boundary(raw_hd); string thd = Text.ReplaceBoundary(raw_hd); string tbd = Text.ReplaceBoundary(raw_bd); string temailName = test_email.Split('@')[0]; string trp = Text.Build_rp(raw_rp, ip["domain"], rdns, temailName, currentTest, "", ip["idi"], ip["idd"], ip["ids"], (string)details_server.name + ip["ids"]); trp = IsPlaceholder ? Placeholder.ReplaceCurrent(trp) : trp; //return path placeholder thd = Text.Build_header(thd, ip["ip"], (string)details_server.name + ip["ids"], ip["domain"], rdns, test_email, temailName, tboundary, tbnd, currentTest, "", ip["idi"], ip["idd"], ip["ids"]); thd = IsPlaceholder ? Placeholder.ReplaceCurrent(thd) : thd; //head placeholder thd = Text.Inject_header(thd, "x", Id.ToString(), Username, ip["ip"], ip["idd"]); tbd = Text.Build_body(tbd, ip["ip"], (string)details_server.name + ip["ids"], ip["domain"], rdns, test_email, temailName, tredirect, tunsubscribe, topen, tboundary, tbnd, currentTest, "", ip["idi"], ip["idd"], ip["ids"]); tbd = IsPlaceholder ? Placeholder.ReplaceCurrent(tbd) : tbd; // body placeholder Message testMessage = new Message(trp); testMessage.AddData(thd + "\n" + tbd + "\n\n"); testMessage.AddRecipient(new Recipient(currentTest)); testMessage.VirtualMTA = ip["vmta"]; testMessage.JobID = Id.ToString(); testMessage.EnvID = Id.ToString(); testMessage.Verp = false; testMessage.Encoding = Encoding.EightBit; p.Send(testMessage); } } if (IsPlaceholder) { placeholder_counter++; //increment placeholder counter } } } else { Result.Add("Emails Empty" + Id); logger.Error("Emails Empty" + Id); campaign.Campaign_update_progress(Id, "start", true, 0); p.Close(); return(Result); } } else { Result.Add("Cant get Send progress campaign" + Id); logger.Error("Cant get Send progress campaign" + Id); campaign.Campaign_update_progress(Id, "start", true, 0); p.Close(); return(Result); } Thread.Sleep(Delay * 1000); //sleep delay } p.Close(); //close pmta connection } else { Result.Add("Server Not Found " + server.Key); logger.Error("Server Not Found " + server.Key); campaign.Campaign_update_progress(Id, "start", true, 0); return(Result); } } catch (Exception ex) { Console.WriteLine($"ERR SERVER ID {server.Key} {ex.Message} -- {ex.StackTrace}"); logger.Error($"ERR SERVER ID {server.Key} {ex.Message} -- {ex.StackTrace}"); } } Thread.Sleep(Sleep * 1000); } campaign.Campaign_update_progress(Id, "start", true, 0); return(Result); } else { Result.Add("Campaign Not Found " + Id); logger.Debug("Campaign Not Found " + Id); campaign.Campaign_update_progress(Id, "start", true, 0); return(Result); } }
public List <string> Send() { List <string> Result = new List <string>(); Campaign campaign = new Campaign(Artisan); int placeholder_counter = 1; int c_seed = 0; Random random = new Random(); for (int i = 0; i < Loop; i++) //loop { Console.WriteLine("Loop : " + i); try { dynamic cdata = campaign.Campaign_info(Id); if (cdata != null) { string raw_rp = Convert.ToString(cdata.return_path) ?? ""; string[] seed_emails = Campaign.Convert_emails(Convert.ToString(cdata.email_test)); string raw_hd = Text.Base64Decode(Convert.ToString(cdata.header)); string raw_bd = Text.Base64Decode(Convert.ToString(cdata.body)); var servers = Campaign.Convert_ips(Convert.ToString(cdata.ips), Convert.ToString(cdata.option)); if (servers.Count == 0) { Result.Add("No Servers To Process"); logger.Error("No Servers To Process"); campaign.Campaign_update_progress(Id, "start", true, 0); return(Result); } string file = "/" + Convert.ToString(cdata.send_file); string platform = Convert.ToString(cdata.platform); string redirect_link = Convert.ToString(cdata.redirect_link); string unsubscribe_link = Convert.ToString(cdata.unsubscribe_link); bool IsPlaceholder = Convert.ToString(cdata.is_placeholder) == "1"; if (IsPlaceholder) { Placeholder = new Placeholder(cdata.placeholder_data, (int)cdata.placeholder_every); } bool IsAutoReply = Convert.ToString(cdata.is_auto_reply) == "1"; if (IsAutoReply) { Reply = new Rotation(cdata.auto_reply_data, (int)cdata.auto_reply_every); } bool IsNegative = Convert.ToString(cdata.is_negative) == "1"; if (IsNegative && string.IsNullOrEmpty(Negative)) { Negative = campaign.Campaign_negative(Convert.ToString(cdata.negative)); } if (IsNegative) { raw_bd = Text.Build_negative(raw_bd, Negative); } foreach (var server in servers) { try { var details_server = campaign.Server_info(int.Parse((string)server.Key)); if (details_server != null) { Pmta p = new Pmta(Convert.ToString(details_server.ip), Password); //load pmta foreach (var ip in server.Value) { var info_send = campaign.Campaign_send_info(Id); if (info_send != null) { int total_send = 0, value_to_send = 0; //check fraction int total_sended = int.Parse((string)info_send.send_progress); int file_count = int.Parse((string)info_send.send_count); if (total_sended + Fraction >= file_count) { if (file_count - total_sended <= 0) { campaign.Campaign_update_progress(Id, "finish", true, 0); Result.Add("Campaign Ended" + Id); p.Close(); //close return(Result); } else { value_to_send = file_count - total_sended; } } else { value_to_send = Fraction; } //load emails List <string[]> emails = File.ReadLines(Storage + file).Skip(total_sended).Take(value_to_send) .Select(t => t.Trim().Split(',')) .Where(item => item.Length == 2) .ToList(); if (emails.Count > 0) { string rdns = Text.Rdns(ip["ip"], ip["domain"]); string rp = Text.Build_rp(raw_rp, ip["domain"], rdns, "info"); rp = IsPlaceholder ? Placeholder.ReplaceRotate(rp, placeholder_counter) : rp; Message message = new Message(rp); string header = Text.Header_normal(raw_hd); string genB = Text.ReplaceBoundary(header + "\n" + raw_bd + "\n\n"); message.AddMergeData(Text.Generate(genB)); message.VirtualMTA = ip["vmta"]; message.JobID = Id.ToString(); message.EnvID = Id.ToString(); message.Verp = false; message.Encoding = Encoding.EightBit; foreach (string[] email in emails) { string currentEmail = IsAutoReply ? Reply.GetAndRotate() : email[1]; Recipient r = new Recipient(currentEmail); //links string key = Text.Adler32($"{Id}{email[0]}"); r["red"] = Text.Base64Encode($"{Id}-{email[0]}-{key}-{SendId}-{random.Next(1000, 999999)}"); r["unsub"] = Text.Base64Encode($"{Id}-{email[0]}-{key}-{SendId}-{random.Next(1000, 999999)}"); r["opn"] = Text.Base64Encode($"{Id}-{email[0]}-{key}-{SendId}-{random.Next(1000, 999999)}"); //header body r["pe"] = $"n,{Id},{Username},{ip["ip"]},{ip["idd"]},{email[0]}"; r["ip"] = ip["ip"]; r["server"] = (string)details_server.name + ip["ids"]; r["domain"] = ip["domain"]; r["idi"] = ip["idi"]; r["idd"] = ip["idd"]; r["ids"] = ip["ids"]; r["ide"] = email[0]; r["rdns"] = rdns; r["name"] = currentEmail.Split('@')[0]; r["to"] = email[1]; r["reply"] = currentEmail; r["date"] = Text.GetRFC822Date(); r["boundary"] = Text.Random("[rndlu/30]"); r["bnd"] = Text.Boundary(header); r["*parts"] = "1"; if (IsPlaceholder) { r = Placeholder.ReplaceRotateReciption(r, placeholder_counter); } message.AddRecipient(r); total_send++; c_seed++; placeholder_counter++; if (Seed != 0 && c_seed % Seed == 0 && seed_emails.Length > 0) { foreach (string test_email in seed_emails) { string currentTest = IsAutoReply ? Reply.GetCurrent() : test_email; Recipient t = new Recipient(currentTest); //links string tkey = Text.Adler32($"{Id}0"); t["red"] = Text.Base64Encode($"{Id}-0-{tkey}-{SendId}-{random.Next(1000, 999999)}"); t["unsub"] = Text.Base64Encode($"{Id}-0-{tkey}-{SendId}-{random.Next(1000, 999999)}"); t["opn"] = Text.Base64Encode($"{Id}-0-{tkey}-{SendId}-{random.Next(1000, 999999)}"); //header body t["pe"] = $"t,{Id},{Username},{ip["ip"]},{ip["idd"]},0"; t["ip"] = ip["ip"]; t["server"] = (string)details_server.name + ip["ids"]; t["domain"] = ip["domain"]; t["idi"] = ip["idi"]; t["idd"] = ip["idd"]; t["ids"] = ip["ids"]; t["ide"] = "0"; t["rdns"] = rdns; t["name"] = currentTest.Split('@')[0]; t["to"] = test_email; t["reply"] = currentTest; t["date"] = Text.GetRFC822Date(); t["boundary"] = Text.Random("[rndlu/30]"); t["bnd"] = Text.Boundary(header); t["*parts"] = "1"; if (IsPlaceholder) { t = Placeholder.ReplaceCurrentReciption(t); } message.AddRecipient(t); } } } p.Send(message); //Task.Run(() => campaign.Campaign_update_send(Id, total_send + total_sended)); campaign.Campaign_update_send(Id, total_send + total_sended); } else { Result.Add("Emails Empty" + Id); logger.Error("Emails Empty" + Id); campaign.Campaign_update_progress(Id, "start", true, 0); p.Close(); return(Result); } } else { Result.Add("Cant get Send progress campaign" + Id); logger.Error("Cant get Send progress campaign" + Id); campaign.Campaign_update_progress(Id, "start", true, 0); p.Close(); return(Result); } Thread.Sleep(Delay * 1000); //sleep delay } p.Close(); //close pmta connection } else { Result.Add("Server Not Found " + server.Key); logger.Error("Server Not Found " + server.Key); campaign.Campaign_update_progress(Id, "start", true, 0); return(Result); } } catch (Exception ex) { Console.WriteLine($"ERR SERVER ID {server.Key} {ex.Message} -- {ex.StackTrace}"); logger.Error($"ERR SERVER ID {server.Key} {ex.Message} -- {ex.StackTrace}"); } } } else { Result.Add("Campaign Not Found " + Id); logger.Debug("Campaign Not Found " + Id); campaign.Campaign_update_progress(Id, "start", true, 0); return(Result); } } catch (Exception ex) { Console.WriteLine($"ERR {ex.Message} -- {ex.StackTrace}"); logger.Error($"ERR {ex.Message} -- {ex.StackTrace}"); } Thread.Sleep(Sleep * 1000); } campaign.Campaign_update_progress(Id, "start", true, 0); return(Result); }
public List <string> Send() { List <string> data = new List <string>(); List <Task> tasks = new List <Task>(); Random random = new Random(); int placeholder_counter = 1; foreach (dynamic server in Servers) { tasks.Add( Task.Factory.StartNew(() => { try { Pmta p = new Pmta((string)server.mainip, (string)server.password, (string)server.username, (int)server.port); foreach (dynamic ip in server.ips) { string email_ip = ip.ip; string domain = ip.domain; string rdns = Text.Rdns(email_ip, domain); string vmta = ip.vmta; string job = $"0_CAMPAIGN-TEST_{Id}_{Username}"; string key = Text.Adler32($"{Id}0"); string redirect = Text.Base64Encode($"{Id}-0-{key}-{TestId}-{random.Next(1000, 999999)}"); string unsubscribe = Text.Base64Encode($"{Id}-0-{key}-{TestId}-{random.Next(1000, 999999)}"); string open = Text.Base64Encode($"{Id}-0-{key}-{TestId}-{random.Next(1000, 999999)}"); if (IsNegative) { Body = Text.Build_negative(Body, Negative); } foreach (string email in Emails) { string currentEmail = IsAutoReply ? Reply.ThreadGetAndRotate() : email; string boundary = Text.Random("[rndlu/30]"); string bnd = Text.Boundary(Header); string hd = Text.ReplaceBoundary(Header); string bd = Text.ReplaceBoundary(Body); string emailName = email.Split('@')[0]; string rp = Text.Build_rp(Return_path, domain, rdns, emailName, currentEmail, (string)ip.idi, (string)ip.idd, (string)ip.ids, (string)server.name, email); rp = IsPlaceHolder ? Placeholder.ReplaceRotate(rp, placeholder_counter, true) : rp; hd = Text.Build_header(hd, email_ip, (string)server.name, domain, rdns, email, emailName, boundary, bnd, currentEmail, (string)ip.idi, (string)ip.idd, (string)ip.ids, "0"); hd = IsPlaceHolder ? Placeholder.ReplaceRotate(hd, placeholder_counter, true) : hd; hd = Text.Inject_header(hd, "t", Id, Username, Convert.ToString(ip.ip), Convert.ToString(ip.idd)); bd = Text.Build_body(bd, email_ip, (string)server.id, domain, rdns, email, emailName, redirect, unsubscribe, open, boundary, bnd, currentEmail, (string)ip.idi, (string)ip.idd, (string)ip.ids, "0"); bd = IsPlaceHolder ? Placeholder.ReplaceRotate(bd, placeholder_counter, true) : bd; Message Message = new Message(rp); Message.AddData(Text.ReplaceBoundary(hd + "\n" + bd + "\n\n", bnd)); Message.AddRecipient(new Recipient(currentEmail)); Message.VirtualMTA = vmta; Message.JobID = job; Message.EnvID = Id; Message.Verp = false; Message.Encoding = Encoding.EightBit; p.Send(Message); Interlocked.Increment(ref placeholder_counter); } } data.Add($"SERVER {server.mainip} OK"); p.Close(); } catch (Exception ex) { data.Add($"ERROR SERVER {server.mainip} - {ex.Message}"); logger.Error(ex.Message); } }) ); } Task.WaitAll(tasks.ToArray()); return(data); }
public List <string> Send() { List <string> Result = new List <string>(); Campaign campaign = new Campaign(Artisan); List <Task> tasks = new List <Task>(); Random random = new Random(); int c_seed = 0; int placeholder_counter = 1; for (int l = 0; l < Loop; l++) //loop { Console.WriteLine("Loop : " + l); try { dynamic cdata = campaign.Campaign_info(Id); if (cdata != null) { string raw_rp = Convert.ToString(cdata.return_path) ?? ""; string[] seed_emails = Campaign.Convert_emails(Convert.ToString(cdata.email_test)); string raw_hd = Text.Base64Decode(Convert.ToString(cdata.header)); string raw_bd = Text.Base64Decode(Convert.ToString(cdata.body)); var servers = Campaign.Bulk_split(Convert.ToString(cdata.ips)); if (servers.Count == 0) { Result.Add("No Servers To Process"); logger.Error("No Servers To Process"); campaign.Campaign_update_progress(Id, "start", true, 0); return(Result); } string file = "/" + Convert.ToString(cdata.send_file); string platform = Convert.ToString(cdata.platform); string redirect_link = Convert.ToString(cdata.redirect_link); string unsubscribe_link = Convert.ToString(cdata.unsubscribe_link); bool IsPlaceholder = Convert.ToString(cdata.is_placeholder) == "1"; if (IsPlaceholder) { Placeholder = new Placeholder(cdata.placeholder_data, (int)cdata.placeholder_every); } bool IsAutoReply = Convert.ToString(cdata.is_auto_reply) == "1"; if (IsAutoReply) { Reply = new Rotation(cdata.auto_reply_data, (int)cdata.auto_reply_every); } bool IsNegative = Convert.ToString(cdata.is_negative) == "1"; if (IsNegative && string.IsNullOrEmpty(Negative)) { Negative = campaign.Campaign_negative(Convert.ToString(cdata.negative)); } if (IsNegative) { raw_bd = Text.Build_negative(raw_bd, Negative); } string mta = Convert.ToString(cdata.option); int progress = int.Parse(Convert.ToString(cdata.send_progress)); int total = int.Parse(Convert.ToString(cdata.send_count)); int countIps = servers.Count; if (total - progress <= 0) { campaign.Campaign_update_progress(Id, "finish", true, 0); return(Result); } int toSend = countIps * Fraction; if (total - (progress + (countIps * Fraction)) < 0) { toSend = total - progress; } List <int> ipLimit = Campaign.DistributeInteger(toSend, countIps).ToList(); for (int i = 0; i < countIps; i++) { int current = i; tasks.Add( Task.Factory.StartNew(() => { try { if (ipLimit[current] > 0) { var details_server = campaign.Server_info(int.Parse(servers[current][4])); if (details_server != null) { Pmta p = new Pmta(Convert.ToString(details_server.ip), Password); //load pmta int skip = (current == 0 ? 0 : ipLimit.Take(current).Sum()) + progress; Console.WriteLine("skip " + skip); List <string[]> emails = File.ReadLines(Storage + file).Skip(skip).Take(ipLimit[current]) .Select(t => t.Trim().Split(',')) .Where(item => item.Length == 2) .ToList(); if (emails.Count > 0) { string vmta = "mta-" + servers[current][0].Replace(":", "."); if (servers[current].Length == 6) { vmta = $"{mta}-{servers[current][0].Replace(":", ".")}-{servers[current][5]}"; } string rdns = Text.Rdns(servers[current][0], servers[current][1]); string rp = Text.Build_rp(raw_rp, servers[current][1], rdns, "info"); rp = IsPlaceholder ? Placeholder.ReplaceRotate(rp, placeholder_counter, true) : rp; Message message = new Message(rp); string header = Text.Header_normal(raw_hd); string genB = Text.ReplaceBoundary(header + "\n" + raw_bd + "\n\n"); message.AddMergeData(Text.Generate(genB)); message.VirtualMTA = vmta; message.JobID = Id.ToString(); message.EnvID = Id.ToString(); message.Verp = false; message.Encoding = Encoding.EightBit; foreach (string[] email in emails) { string currentEmail = IsAutoReply ? Reply.ThreadGetAndRotate() : email[1]; Recipient r = new Recipient(currentEmail); //links string key = Text.Adler32($"{Id}{email[0]}"); r["red"] = Text.Base64Encode($"{Id}-{email[0]}-{key}-{SendId}-{random.Next(1000, 999999)}"); r["unsub"] = Text.Base64Encode($"{Id}-{email[0]}-{key}-{SendId}-{random.Next(1000, 999999)}"); r["opn"] = Text.Base64Encode($"{Id}-{email[0]}-{key}-{SendId}-{random.Next(1000, 999999)}"); //header body r["pe"] = $"b,{Id},{Username},{servers[current][0]},{servers[current][3]},{email[0]}"; r["ip"] = servers[current][0]; r["server"] = (string)details_server.name + servers[current][4]; r["domain"] = servers[current][1]; r["idi"] = servers[current][2]; r["idd"] = servers[current][3]; r["ids"] = servers[current][4]; r["ide"] = email[0]; r["rdns"] = rdns; r["name"] = currentEmail.Split('@')[0]; r["to"] = email[1]; r["reply"] = currentEmail; r["date"] = Text.GetRFC822Date(); r["boundary"] = Text.Random("[rndlu/30]"); r["bnd"] = Text.Boundary(header); r["*parts"] = "1"; if (IsPlaceholder) { r = Placeholder.ReplaceRotateReciption(r, placeholder_counter, true); } message.AddRecipient(r); Interlocked.Increment(ref c_seed); Interlocked.Increment(ref placeholder_counter); if (Seed != 0 && c_seed % Seed == 0 && seed_emails.Length > 0) { foreach (string test_email in seed_emails) { string currentTest = IsAutoReply ? Reply.GetCurrent() : test_email; Recipient t = new Recipient(currentTest); //links string tkey = Text.Adler32($"{Id}0"); t["red"] = Text.Base64Encode($"{Id}-0-{tkey}-{SendId}-{random.Next(1000, 999999)}"); t["unsub"] = Text.Base64Encode($"{Id}-0-{tkey}-{SendId}-{random.Next(1000, 999999)}"); t["opn"] = Text.Base64Encode($"{Id}-0-{tkey}-{SendId}-{random.Next(1000, 999999)}"); //header body t["pe"] = $"t,{Id},{Username},{servers[current][0]},{servers[current][3]},0"; t["ip"] = servers[current][0]; t["server"] = (string)details_server.name + servers[current][4]; t["domain"] = servers[current][1]; t["idi"] = servers[current][2]; t["idd"] = servers[current][3]; t["ids"] = servers[current][4]; t["ide"] = "0"; t["rdns"] = rdns; t["name"] = currentTest.Split('@')[0]; t["to"] = test_email; t["reply"] = currentTest; t["date"] = Text.GetRFC822Date(); t["boundary"] = Text.Random("[rndlu/30]"); t["bnd"] = Text.Boundary(header); t["*parts"] = "1"; if (IsPlaceholder) { t = Placeholder.ReplaceCurrentReciption(t); } message.AddRecipient(t); } } } p.Send(message); p.Close(); } } } } catch (Exception ex) { logger.Error($"ERR {ex.Message} -- {ex.StackTrace}"); Console.WriteLine($"ERR {ex.Message} -- {ex.StackTrace}"); } }) ); } Task.WaitAll(tasks.ToArray()); campaign.Campaign_update_send(Id, toSend + progress); } else { Result.Add("Campaign Not Found " + Id); logger.Debug("Campaign Not Found " + Id); campaign.Campaign_update_progress(Id, "start", true, 0); return(Result); } } catch (Exception ex) { Console.WriteLine($"ERR {ex.Message} -- {ex.StackTrace}"); logger.Error($"ERR {ex.Message} -- {ex.StackTrace}"); } Thread.Sleep(Sleep * 1000); } campaign.Campaign_update_progress(Id, "start", true, 0); return(Result); }