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)
|
||||
{
|
||||
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())
|
||||
try
|
||||
{
|
||||
client.CheckCertificateRevocation = false;
|
||||
client.Timeout = 10000;
|
||||
SceneObjectPart sceneObject = m_scene.GetSceneObjectPart(objectID);
|
||||
|
||||
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);
|
||||
}
|
||||
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 };
|
||||
|
||||
if(SMTP_SERVER_LOGIN != String.Empty && SMTP_SERVER_PASSWORD != String.Empty)
|
||||
client.Authenticate(SMTP_SERVER_LOGIN, SMTP_SERVER_PASSWORD);
|
||||
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()));
|
||||
|
||||
client.Send(message);
|
||||
client.Disconnect(true);
|
||||
using (var client = new SmtpClient())
|
||||
{
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue