From 272a319a3e3dd1a3e9e3ad4c79eed22e5eff4109 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 15 Feb 2009 13:54:34 +0000 Subject: [PATCH] Thank you, Vytek, for a patch that streamlines the delay in the email module and changes SMTP authentication (applied with changes) Fixes Mantis #3168 --- .../Scripting/EMailModules/EmailModule.cs | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs index 9e2abf2b36..43eccf3054 100644 --- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs @@ -178,17 +178,15 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules } /// - /// + /// Delay function using thread in seconds /// /// - private void DelayInSeconds(int seconds) + private void DelayInSeconds(int delay) { - TimeSpan DiffDelay = new TimeSpan(0, 0, seconds); - DateTime EndDelay = DateTime.Now.Add(DiffDelay); - while (DateTime.Now < EndDelay) - { - ;//Do nothing!! - } + delay = (int)((float)delay * 1000); + if (delay == 0) + return; + System.Threading.Thread.Sleep(delay); } private bool IsLocal(UUID objectID) @@ -293,12 +291,19 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules "\nRegion: " + LastObjectRegionName + "\nLocal-Position: " + LastObjectPosition + "\n\n" + body; + //Config SMTP Server //Set SMTP SERVER config - SmtpServer smtpServer = new SmtpServer(SMTP_SERVER_HOSTNAME, SMTP_SERVER_PORT); - //Authentication - smtpServer.SmtpAuthToken = new SmtpAuthToken(SMTP_SERVER_LOGIN, SMTP_SERVER_PASSWORD); + SmtpServer smtpServer=new SmtpServer(SMTP_SERVER_HOSTNAME,SMTP_SERVER_PORT); + // Add authentication only when requested + // + if (SMTP_SERVER_LOGIN != String.Empty && SMTP_SERVER_PASSWORD != String.Empty) + { + //Authentication + smtpServer.SmtpAuthToken=new SmtpAuthToken(SMTP_SERVER_LOGIN, SMTP_SERVER_PASSWORD); + } //Send Email Message emailMessage.Send(smtpServer); + //Log m_log.Info("[EMAIL] EMail sent to: " + address + " from object: " + objectID.ToString()); }