add send query
parent
b7a69bda80
commit
8a89d5968e
|
@ -33,9 +33,11 @@ namespace OpenSim.Modules.EMail
|
|||
|
||||
private Scene m_scene = null;
|
||||
|
||||
private Timer m_timer = null;
|
||||
private Timer m_timer_recive = null;
|
||||
private Timer m_timer_send = null;
|
||||
|
||||
private List<InternalMail> m_messages = new List<InternalMail>();
|
||||
private List<MimeMessage> m_sendMessages = new List<MimeMessage>();
|
||||
|
||||
private bool m_debug = false;
|
||||
|
||||
|
@ -75,19 +77,26 @@ namespace OpenSim.Modules.EMail
|
|||
scene.RegisterModuleInterface<IEmailModule>(this);
|
||||
m_scene = scene;
|
||||
|
||||
if(IMAP_SERVER_HOSTNAME != String.Empty)
|
||||
m_timer_send = new Timer();
|
||||
m_timer_send.Interval = 1000 * 10;
|
||||
m_timer_send.Elapsed += sendAllMails;
|
||||
m_timer_send.Enabled = true;
|
||||
m_timer_send.Start();
|
||||
|
||||
if (IMAP_SERVER_HOSTNAME != String.Empty)
|
||||
{
|
||||
m_timer = new Timer();
|
||||
m_timer.Interval = 1000 * 15;
|
||||
m_timer.Elapsed += checkForMails;
|
||||
m_timer.Enabled = true;
|
||||
m_timer.Start();
|
||||
m_timer_recive = new Timer();
|
||||
m_timer_recive.Interval = 1000 * 15;
|
||||
m_timer_recive.Elapsed += checkForMails;
|
||||
m_timer_recive.Enabled = true;
|
||||
m_timer_recive.Start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Close()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
|
@ -239,22 +248,13 @@ namespace OpenSim.Modules.EMail
|
|||
}
|
||||
}
|
||||
|
||||
public void SendEmail(UUID objectID, string address, string subject, string body)
|
||||
private void sendAllMails(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
if (m_sendMessages.Count == 0)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
SceneObjectPart sceneObject = m_scene.GetSceneObjectPart(objectID);
|
||||
|
||||
MimeMessage message = new MimeMessage();
|
||||
message.From.Add(new MailboxAddress(sceneObject.Name, sceneObject.UUID + "@" + SMTP_SERVER_SENDER));
|
||||
message.To.Add(new MailboxAddress("", address));
|
||||
message.Subject = subject;
|
||||
message.Body = new TextPart("plain") { Text = body };
|
||||
|
||||
message.Headers.Add(new Header(Encoding.UTF8, "ObjectID", sceneObject.UUID.ToString()));
|
||||
message.Headers.Add(new Header(Encoding.UTF8, "AvatarID", sceneObject.OwnerID.ToString()));
|
||||
message.Headers.Add(new Header(Encoding.UTF8, "Location", m_scene.Name + "@" + sceneObject.GetWorldPosition().ToString()));
|
||||
|
||||
using (var client = new SmtpClient())
|
||||
{
|
||||
client.CheckCertificateRevocation = false;
|
||||
|
@ -276,9 +276,49 @@ namespace OpenSim.Modules.EMail
|
|||
if (SMTP_SERVER_LOGIN != String.Empty && SMTP_SERVER_PASSWORD != String.Empty)
|
||||
client.Authenticate(SMTP_SERVER_LOGIN, SMTP_SERVER_PASSWORD);
|
||||
|
||||
client.Send(message);
|
||||
lock(m_sendMessages)
|
||||
{
|
||||
foreach (MimeMessage message in m_sendMessages)
|
||||
{
|
||||
try
|
||||
{
|
||||
client.Send(message);
|
||||
}
|
||||
catch (Exception _innerError)
|
||||
{
|
||||
m_log.Error("[" + Name + "] " + _innerError.Message);
|
||||
}
|
||||
}
|
||||
|
||||
m_sendMessages = new List<MimeMessage>();
|
||||
}
|
||||
|
||||
client.Disconnect(true);
|
||||
}
|
||||
}
|
||||
catch(Exception _error)
|
||||
{
|
||||
m_log.Error("[" + Name + "] " + _error.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void SendEmail(UUID objectID, string address, string subject, string body)
|
||||
{
|
||||
try
|
||||
{
|
||||
SceneObjectPart sceneObject = m_scene.GetSceneObjectPart(objectID);
|
||||
|
||||
MimeMessage message = new MimeMessage();
|
||||
message.From.Add(new MailboxAddress(sceneObject.Name, sceneObject.UUID + "@" + SMTP_SERVER_SENDER));
|
||||
message.To.Add(new MailboxAddress("", address));
|
||||
message.Subject = subject;
|
||||
message.Body = new TextPart("plain") { Text = body };
|
||||
|
||||
message.Headers.Add(new Header(Encoding.UTF8, "ObjectID", sceneObject.UUID.ToString()));
|
||||
message.Headers.Add(new Header(Encoding.UTF8, "AvatarID", sceneObject.OwnerID.ToString()));
|
||||
message.Headers.Add(new Header(Encoding.UTF8, "Location", m_scene.Name + "@" + sceneObject.GetWorldPosition().ToString()));
|
||||
|
||||
m_sendMessages.Add(message);
|
||||
}catch(Exception _error)
|
||||
{
|
||||
m_log.Error("[" + Name + "] " + _error.Message);
|
||||
|
|
Loading…
Reference in New Issue