remove email addresses from blacklist after MAX_ATTEMPTS to give them one more chance #7

Merged
laurentiu.constantin merged 1 commits from handle_email_address_in_blacklist into master 2024-06-13 11:04:29 +00:00
3 changed files with 216 additions and 112 deletions
Showing only changes of commit 4f3c7b5870 - Show all commits

View File

@ -22,7 +22,7 @@ namespace AppServer
private volatile DBsubsOperationManager dbsubsoperManage; private volatile DBsubsOperationManager dbsubsoperManage;
private volatile DBvehiclesManager dbvehs; private volatile DBvehiclesManager dbvehs;
private DBvehiclesManager DBvehInfo; private DBvehiclesManager DBvehInfo;
List<string> blackListAddress = new List<string>();
public static volatile Int32 LocationCheckQueuesCount = 0; public static volatile Int32 LocationCheckQueuesCount = 0;
Int64 count = 0; Int64 count = 0;
@ -185,12 +185,12 @@ namespace AppServer
{ {
Vehicle_Data v_data = (Vehicle_Data)MainForm.VehList[radioID2.ToString()]; Vehicle_Data v_data = (Vehicle_Data)MainForm.VehList[radioID2.ToString()];
Alarm alarm = v_data.alm; Alarm alarm = v_data.alm;
bool zone = false;
bool landMark = false;
String SpeedProccess = "";
if (alarm.Zone != "") zone = true;
if (alarm.Landmark != "") landMark = true;
bool zone = (alarm.Zone != "") ;
bool landMark = (alarm.Landmark != "") ;
String SpeedProccess = "";
if (zone || landMark) if (zone || landMark)
{ {
SpeedProccess = processZoneAlarm(radioID2, dec2.cell, zone, landMark, alarm.Email, !prevGps); SpeedProccess = processZoneAlarm(radioID2, dec2.cell, zone, landMark, alarm.Email, !prevGps);
@ -351,7 +351,7 @@ namespace AppServer
string test2 = "#210#1#Can't write GPS data in DB#"; string test2 = "#210#1#Can't write GPS data in DB#";
if (ex.Message == "AlarmError") test2 = "#210#5#Can't write Alarm data in DB#"; if (ex.Message == "AlarmError") test2 = "#210#5#Can't write Alarm data in DB#";
else if (ex.Message == "StolenError") test2 = "#210#6#Can't write Stolen data in DB#"; else if (ex.Message == "StolenError") test2 = "#210#6#Can't write Stolen data in DB#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test2), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test2).Length); MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test2), Utils.Convert_text_For_multicast("#0.0" + test2).Length);
} }
catch (Exception ex2) catch (Exception ex2)
{ {
@ -397,7 +397,7 @@ namespace AppServer
{ {
// send callout clear // send callout clear
string test = "#178#" + callout.RadioID.ToString() + "#" + callout.Severity + "#"; string test = "#178#" + callout.RadioID.ToString() + "#" + callout.Severity + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test).Length); MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
Utils.WriteLine($"Sent CallOut Stop request with Severity [{callout.Severity}] for unit {callout.RadioID.ToString()} "); Utils.WriteLine($"Sent CallOut Stop request with Severity [{callout.Severity}] for unit {callout.RadioID.ToString()} ");
} }
} }
@ -409,41 +409,48 @@ namespace AppServer
private void sendMailGeo(string mes, String subj, string mailAdr) private void sendMailGeo(string mes, String subj, string mailAdr)
{ {
if (Program.cfg.enableEmailService && !String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr)) if (Program.cfg.enableEmailService)
{ {
if (blackListAddress.Contains(mailAdr)) if (!String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
{ {
Utils.WriteLine($" sendMailGeo : The email was not sent. Email address '{mailAdr}' is in blacklist "); if (MainForm.IsBlacklistedAddress(mailAdr))
return;
}
try
{
MailAddress from = new MailAddress(Program.cfg.emailAddress);
String[] address = mailAdr.Split(";".ToCharArray());
MailAddress to = new MailAddress(address[0]);
MailMessage message = new MailMessage(from, to);
if (address.Count() > 1)
{ {
Boolean skipeFirst = true; Utils.WriteLine($"sendMailGeo : The email was not sent. Email address '{mailAdr}' is in blacklist ");
foreach (String obj in address) return;
{
if (skipeFirst)
{ skipeFirst = false; }
else
message.To.Add(new MailAddress(obj));
}
} }
message.Subject = subj;
message.Body = mes;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState);
}
catch (Exception ex)
{
if (ex.ToString().Contains("timed out"))
blackListAddress.Add(mailAdr);
Utils.WriteLine($"Exception in sendMailGeo: {ex.ToString()}"); try
{
MailAddress from = new MailAddress(Program.cfg.emailAddress);
String[] address = mailAdr.Split(";".ToCharArray());
MailAddress to = new MailAddress(address[0]);
MailMessage message = new MailMessage(from, to);
if (address.Count() > 1)
{
Boolean skipeFirst = true;
foreach (String obj in address)
{
if (skipeFirst)
{ skipeFirst = false; }
else
message.To.Add(new MailAddress(obj));
}
}
message.Subject = subj;
message.Body = mes;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState);
}
catch (Exception ex)
{
if (ex.ToString().Contains("timed out"))
MainForm.HandleTimeoutError(mailAdr);
Utils.WriteLine($"Exception in sendMailGeo: {ex.ToString()}");
}
}
else
{
Utils.WriteLine($"Missing email address From = {Program.cfg.emailAddress} To = {mailAdr})", ConsoleColor.Cyan);
} }
} }
else else
@ -453,32 +460,40 @@ namespace AppServer
} }
private void sendAlarmMail(string title, string mes, string mailAdr) private void sendAlarmMail(string title, string mes, string mailAdr)
{ {
if (Program.cfg.enableEmailService && !String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr)) if (Program.cfg.enableEmailService)
{ {
if (!String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
if (blackListAddress.Contains(mailAdr))
{ {
Utils.WriteLine($" sendAlarmMail : The email was not sent. Email address '{mailAdr}' is in blacklist ");
return; if (MainForm.IsBlacklistedAddress(mailAdr))
{
Utils.WriteLine($" sendAlarmMail : The email was not sent. Email address '{mailAdr}' is in blacklist ");
return;
}
try
{
MailAddress from = new MailAddress(Program.cfg.emailAddress);
MailAddress to = new MailAddress(mailAdr);
MailMessage message = new MailMessage(from, to);
message.Subject = title;
message.Body = mes;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState);
}
catch (Exception ex)
{
if (ex.ToString().Contains("timed out"))
MainForm.HandleTimeoutError(mailAdr);
Utils.WriteLine("Exception in sendMailAlarm2: {0}" + ex.ToString(), ConsoleColor.Red);
}
} }
else
try
{ {
MailAddress from = new MailAddress(Program.cfg.emailAddress); Utils.WriteLine($"Missing email address From = {Program.cfg.emailAddress} To = {mailAdr})", ConsoleColor.Cyan);
MailAddress to = new MailAddress(mailAdr);
MailMessage message = new MailMessage(from, to);
message.Subject = title;
message.Body = mes;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState);
}
catch (Exception ex)
{
if (ex.ToString().Contains("timed out"))
blackListAddress.Add(mailAdr);
Utils.WriteLine("Exception in sendMailAlarm2: {0}" + ex.ToString(), ConsoleColor.Red);
} }
} }
else else
@ -561,7 +576,7 @@ namespace AppServer
{ {
//send alarm on message buss //send alarm on message buss
test = "#136#" + radioID.ToString() + "#" + tmpresp + "#"; test = "#136#" + radioID.ToString() + "#" + tmpresp + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test).Length); MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
} }
String date = DateTime.Now.ToUniversalTime().DateTo70Format().ToString(); String date = DateTime.Now.ToUniversalTime().DateTo70Format().ToString();
@ -589,7 +604,7 @@ namespace AppServer
tmpX = dbvehs.getSystemPosition(Convert.ToInt32(keyobj)); tmpX = dbvehs.getSystemPosition(Convert.ToInt32(keyobj));
test = "#142#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + (String)tmpHashName[keyobj] + "#" + /*"Message from unit " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name + " :" +*/ obj2.msgbody + "#" + date + "#"; test = "#142#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + (String)tmpHashName[keyobj] + "#" + /*"Message from unit " + ((Vehicle_Data)MainForm.VehList[radioID.ToString()]).Name + " :" +*/ obj2.msgbody + "#" + date + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0." + date + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0." + date + test).Length); MainForm.udp.Send(Utils.Convert_text_For_multicast("#0." + date + test), Utils.Convert_text_For_multicast("#0." + date + test).Length);
Thread.Sleep(100); Thread.Sleep(100);
Utils.WriteLine($"Zone alert sms request [{obj2.msgbody}] for unit {(String)tmpHashName[keyobj]} on gw [{(tmpX.Gw_id + "." + tmpX.R_gw_id)}]"); Utils.WriteLine($"Zone alert sms request [{obj2.msgbody}] for unit {(String)tmpHashName[keyobj]} on gw [{(tmpX.Gw_id + "." + tmpX.R_gw_id)}]");
@ -601,7 +616,7 @@ namespace AppServer
{ {
tmpX = dbvehs.getSystemPositionIMEI(radioID); tmpX = dbvehs.getSystemPositionIMEI(radioID);
test = "#142#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + radioID + "#" + obj2.msgbody2 + "#" + DateTime.Now.ToUniversalTime().DateTo70Format().ToString() + "#"; test = "#142#" + tmpX.Gw_id + "." + tmpX.R_gw_id + "." + radioID + "#" + obj2.msgbody2 + "#" + DateTime.Now.ToUniversalTime().DateTo70Format().ToString() + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0." + date + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0." + date + test).Length); MainForm.udp.Send(Utils.Convert_text_For_multicast("#0." + date + test), Utils.Convert_text_For_multicast("#0." + date + test).Length);
Utils.WriteLine($"Zone alert sms request [{obj2.msgbody2}] for unit {radioID} on gw [{(tmpX.Gw_id + "." + tmpX.R_gw_id)}]"); Utils.WriteLine($"Zone alert sms request [{obj2.msgbody2}] for unit {radioID} on gw [{(tmpX.Gw_id + "." + tmpX.R_gw_id)}]");
} }
@ -611,7 +626,7 @@ namespace AppServer
{ {
tmpX = dbvehs.getSystemPositionIMEI(radioID); tmpX = dbvehs.getSystemPositionIMEI(radioID);
test = "#177#" + radioID.ToString() + "#" + obj2.calloutSeverity + "#" + obj2.name + "#"; test = "#177#" + radioID.ToString() + "#" + obj2.calloutSeverity + "#" + obj2.name + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test).Length); MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
callOutQueue.PostItem(new CallOut() { RadioID = radioID, Severity = obj2.calloutSeverity, Time = DateTime.Now}); callOutQueue.PostItem(new CallOut() { RadioID = radioID, Severity = obj2.calloutSeverity, Time = DateTime.Now});
Utils.WriteLine($"Zone CallOut request with Severity [{obj2.calloutSeverity}] for unit {radioID} on gw [{(tmpX.Gw_id + "." + tmpX.R_gw_id)}]"); Utils.WriteLine($"Zone CallOut request with Severity [{obj2.calloutSeverity}] for unit {radioID} on gw [{(tmpX.Gw_id + "." + tmpX.R_gw_id)}]");
@ -667,14 +682,14 @@ namespace AppServer
{ {
//send alarm on message buss //send alarm on message buss
string test = "#137#" + radioID.ToString() + "#" + tmpresp + "#"; string test = "#137#" + radioID.ToString() + "#" + tmpresp + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test).Length); MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
} }
//send CallOut //send CallOut
if(obj2.callout && tmpresp.ToString().Contains("IN ")) if(obj2.callout && tmpresp.ToString().Contains("IN "))
{ {
string test = "#177#" + radioID + "#" + obj2.calloutSeverity + "#" + obj2.name + "#"; string test = "#177#" + radioID + "#" + obj2.calloutSeverity + "#" + obj2.name + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test).Length); MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
callOutQueue.PostItem(new CallOut() { RadioID = radioID, Severity = obj2.calloutSeverity, Time = DateTime.Now }); callOutQueue.PostItem(new CallOut() { RadioID = radioID, Severity = obj2.calloutSeverity, Time = DateTime.Now });
Utils.WriteLine($"Landmark CallOut request with Severity [{obj2.calloutSeverity}] for unit {radioID} "); Utils.WriteLine($"Landmark CallOut request with Severity [{obj2.calloutSeverity}] for unit {radioID} ");
@ -743,7 +758,7 @@ namespace AppServer
//send alarm on message buss //send alarm on message buss
string speed4send = $"{speed}_{speedUnits}"; string speed4send = $"{speed}_{speedUnits}";
string test = "#135#" + radioID.ToString() + "#" + speed4send + "#"; string test = "#135#" + radioID.ToString() + "#" + speed4send + "#";
MainForm.udp.Send(SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test), SafeMobileLib.Utils.Convert_text_For_multicast("#0.0" + test).Length); MainForm.udp.Send(Utils.Convert_text_For_multicast("#0.0" + test), Utils.Convert_text_For_multicast("#0.0" + test).Length);
} }
} }

View File

@ -96,6 +96,9 @@ namespace AppServer
public static String dbAccess; public static String dbAccess;
private WebsocketThread websocket = null; private WebsocketThread websocket = null;
public static Dictionary<string, int> blackListAddress = new Dictionary<string, int>();
public const int MAX_ATTEMPTS = 100;
public delegate void UpdateLicensesUIInvokeCallBack(); public delegate void UpdateLicensesUIInvokeCallBack();
public MainForm() public MainForm()
@ -338,6 +341,37 @@ namespace AppServer
} }
public static void HandleTimeoutError(string mailAdr)
{
// add address to backlist
if (!blackListAddress.ContainsKey(mailAdr))
blackListAddress.Add(mailAdr, MAX_ATTEMPTS);
}
public static bool IsBlacklistedAddress(string mailAdr)
{
if (!blackListAddress.ContainsKey(mailAdr))
return false;
// avoid to send the email MAX_ATTEMPTS times => give another chance to try to send email when count = 0
int count = blackListAddress[mailAdr];
if (count == 0)
{
blackListAddress.Remove(mailAdr);
return false;
}
blackListAddress[mailAdr] = count - 1;
return true;
}
private void ConfigureWebSocket() private void ConfigureWebSocket()
{ {
if (!checkWebsocketServerStatus.Enabled) if (!checkWebsocketServerStatus.Enabled)

View File

@ -28,7 +28,6 @@ namespace AppServer
private DBvehiclesManager dbvehs; private DBvehiclesManager dbvehs;
internal DBsubsOperationManager dbsubsoperManage; internal DBsubsOperationManager dbsubsoperManage;
private DBcallPatchManager dbCallPatch; private DBcallPatchManager dbCallPatch;
private List<string> blackListAddress = new List<string>();
#region code for zone #region code for zone
private volatile static ArrayList ZoneList = new ArrayList(); private volatile static ArrayList ZoneList = new ArrayList();
@ -2152,35 +2151,48 @@ namespace AppServer
private void sendAlarmMail(string mes, string mailAdr) private void sendAlarmMail(string mes, string mailAdr)
{ {
if (Program.cfg.enableEmailService)
if (blackListAddress.Contains(mailAdr))
{ {
Utils.WriteLine($" sendAlarmMail : The email was not sent. Email address '{mailAdr}' is in blacklist ");
return; if (!String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
{
if (MainForm.IsBlacklistedAddress(mailAdr))
{
Utils.WriteLine($" sendAlarmMail : The email was not sent. Email address '{mailAdr}' is in blacklist ");
return;
}
try
{
MailAddress from = new MailAddress(Program.cfg.emailAddress);
MailAddress to = new MailAddress(mailAdr);
MailMessage message = new MailMessage(from, to);
message.Subject = "Alarm";
message.Body = mes;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState);
}
catch (Exception ex)
{
if (ex.ToString().Contains("timed out"))
MainForm.HandleTimeoutError(mailAdr);
Utils.WriteLine("Exception in sendMailAlarm: " + ex.ToString(), ConsoleColor.Red);
//Console.WriteLine(e.ToString());
}
}
else
{
Utils.WriteLine($"Missing email address From = {Program.cfg.emailAddress} To = {mailAdr})", ConsoleColor.Red);
}
} }
else
try
{ {
MailAddress from = new MailAddress(Program.cfg.emailAddress); SM.Debug("email disabled");
MailAddress to = new MailAddress(mailAdr);
MailMessage message = new MailMessage(from, to);
message.Subject = "Alarm";
message.Body = mes;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState);
}
catch (Exception ex)
{
if (ex.ToString().Contains("timed out"))
blackListAddress.Add(mailAdr);
Utils.WriteLine("Exception in sendMailAlarm: " + ex.ToString(), ConsoleColor.Red);
//Console.WriteLine(e.ToString());
} }
} }
public void sendDailyReportMail(String PdfFile, string mailAdr) public void sendDailyReportMail(String PdfFile, string mailAdr)
{ {
try try
{ {
@ -2362,24 +2374,42 @@ namespace AppServer
{ {
if (Program.cfg.enableEmailService) if (Program.cfg.enableEmailService)
{ {
SM.Debug("Sending mail to " + mailAdr + " from radioId " + radioID.ToString()); if (!String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
try
{ {
MailMessage message = new MailMessage();
message.From = new MailAddress(Program.cfg.emailAddress);
message.To.Add(mailAdr);
message.Subject = "RadioID: " + radioID.ToString() + " Subject:" + (mailBody.Length < 25 ? mailBody : (mailBody.Remove(25) + "..."));
message.Body = "You received a message from radio id " + radioID.ToString() +
"\n------------------------------\n" +
mailBody +
"\n------------------------------\n ";
message.IsBodyHtml = true;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState); if (MainForm.IsBlacklistedAddress(mailAdr))
{
Utils.WriteLine($"sendMailGeo : The email was not sent. Email address '{mailAdr}' is in blacklist ");
return;
}
SM.Debug("Sending mail to " + mailAdr + " from radioId " + radioID.ToString());
try
{
MailMessage message = new MailMessage();
message.From = new MailAddress(Program.cfg.emailAddress);
message.To.Add(mailAdr);
message.Subject = "RadioID: " + radioID.ToString() + " Subject:" + (mailBody.Length < 25 ? mailBody : (mailBody.Remove(25) + "..."));
message.Body = "You received a message from radio id " + radioID.ToString() +
"\n------------------------------\n" +
mailBody +
"\n------------------------------\n ";
message.IsBodyHtml = true;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState);
}
catch (Exception ex)
{
if (ex.ToString().Contains("timed out"))
MainForm.HandleTimeoutError(mailAdr);
Utils.WriteLine("Exception in sendMail: " + ex.ToString(), ConsoleColor.Red);
}
} }
catch (Exception ex) else
{ {
Utils.WriteLine("Exception in sendMail: " + ex.ToString(), ConsoleColor.Red); Utils.WriteLine($"Missing email address From = {Program.cfg.emailAddress} To = {mailAdr})", ConsoleColor.Red);
} }
} }
else else
@ -2392,20 +2422,45 @@ namespace AppServer
//sms-> email Sierra Wireless //sms-> email Sierra Wireless
private void sendMail_SW(string mailAdr, string mailBody) private void sendMail_SW(string mailAdr, string mailBody)
{ {
SM.Debug("Sending mail to " + mailAdr); if (Program.cfg.enableEmailService)
try
{ {
MailMessage message = new MailMessage(); if (!String.IsNullOrEmpty(Program.cfg.emailAddress) && !String.IsNullOrEmpty(mailAdr))
message.From = new MailAddress(Program.cfg.emailAddress); {
message.To.Add(mailAdr);
message.Body = mailBody;
message.IsBodyHtml = true;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState); if (MainForm.IsBlacklistedAddress(mailAdr))
{
Utils.WriteLine($"sendMailGeo : The email was not sent. Email address '{mailAdr}' is in blacklist ");
return;
}
SM.Debug("Sending mail to " + mailAdr);
try
{
MailMessage message = new MailMessage();
message.From = new MailAddress(Program.cfg.emailAddress);
message.To.Add(mailAdr);
message.Body = mailBody;
message.IsBodyHtml = true;
EmailServerSSL.sendEmail(Program.cfg.smtpServer, Program.cfg.smtpPort, Program.cfg.emailAddress, Program.cfg.emailPassword, message, Program.cfg.smtpSSLState);
}
catch (Exception ex)
{
if (ex.ToString().Contains("timed out"))
MainForm.HandleTimeoutError(mailAdr);
Utils.WriteLine("Exception in sendMail Sierra Wireless Gateway: " + ex.ToString(), ConsoleColor.Red);
}
}
else
{
Utils.WriteLine($"Missing email address From = {Program.cfg.emailAddress} To = {mailAdr})", ConsoleColor.Red);
}
} }
catch (Exception ex) else
{ {
Utils.WriteLine("Exception in sendMail Sierra Wireless Gateway: "+ ex.ToString() ,ConsoleColor.Red); SM.Debug("email disabled");
} }
} }