add send error handling
parent
c16cd2f9cf
commit
b7a69bda80
|
@ -241,42 +241,49 @@ namespace OpenSim.Modules.EMail
|
||||||
|
|
||||||
public void SendEmail(UUID objectID, string address, string subject, string body)
|
public void SendEmail(UUID objectID, string address, string subject, string body)
|
||||||
{
|
{
|
||||||
SceneObjectPart sceneObject = m_scene.GetSceneObjectPart(objectID);
|
try
|
||||||
|
|
||||||
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;
|
SceneObjectPart sceneObject = m_scene.GetSceneObjectPart(objectID);
|
||||||
client.Timeout = 10000;
|
|
||||||
|
|
||||||
if (SMTP_SERVER_SSL == true)
|
MimeMessage message = new MimeMessage();
|
||||||
{
|
message.From.Add(new MailboxAddress(sceneObject.Name, sceneObject.UUID + "@" + SMTP_SERVER_SENDER));
|
||||||
client.Connect(SMTP_SERVER_HOSTNAME, SMTP_SERVER_PORT, SecureSocketOptions.Auto);
|
message.To.Add(new MailboxAddress("", address));
|
||||||
}
|
message.Subject = subject;
|
||||||
else if(SMTP_SERVER_TLS == true)
|
message.Body = new TextPart("plain") { Text = body };
|
||||||
{
|
|
||||||
client.Connect(SMTP_SERVER_HOSTNAME, SMTP_SERVER_PORT, SecureSocketOptions.StartTlsWhenAvailable);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
client.Connect(SMTP_SERVER_HOSTNAME, SMTP_SERVER_PORT, SecureSocketOptions.None);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(SMTP_SERVER_LOGIN != String.Empty && SMTP_SERVER_PASSWORD != String.Empty)
|
message.Headers.Add(new Header(Encoding.UTF8, "ObjectID", sceneObject.UUID.ToString()));
|
||||||
client.Authenticate(SMTP_SERVER_LOGIN, SMTP_SERVER_PASSWORD);
|
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()));
|
||||||
|
|
||||||
client.Send(message);
|
using (var client = new SmtpClient())
|
||||||
client.Disconnect(true);
|
{
|
||||||
|
client.CheckCertificateRevocation = false;
|
||||||
|
client.Timeout = 10000;
|
||||||
|
|
||||||
|
if (SMTP_SERVER_SSL == true)
|
||||||
|
{
|
||||||
|
client.Connect(SMTP_SERVER_HOSTNAME, SMTP_SERVER_PORT, SecureSocketOptions.Auto);
|
||||||
|
}
|
||||||
|
else if (SMTP_SERVER_TLS == true)
|
||||||
|
{
|
||||||
|
client.Connect(SMTP_SERVER_HOSTNAME, SMTP_SERVER_PORT, SecureSocketOptions.StartTlsWhenAvailable);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
client.Connect(SMTP_SERVER_HOSTNAME, SMTP_SERVER_PORT, SecureSocketOptions.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SMTP_SERVER_LOGIN != String.Empty && SMTP_SERVER_PASSWORD != String.Empty)
|
||||||
|
client.Authenticate(SMTP_SERVER_LOGIN, SMTP_SERVER_PASSWORD);
|
||||||
|
|
||||||
|
client.Send(message);
|
||||||
|
client.Disconnect(true);
|
||||||
|
}
|
||||||
|
}catch(Exception _error)
|
||||||
|
{
|
||||||
|
m_log.Error("[" + Name + "] " + _error.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Email GetNextEmail(UUID objectID, string sender, string subject)
|
public Email GetNextEmail(UUID objectID, string sender, string subject)
|
||||||
|
|
Loading…
Reference in New Issue