Contact PrimarySMTP...
 
Notifications
Clear all

Contact PrimarySMTPAddress can cause mail routing issues

9 Posts
2 Users
0 Reactions
1,712 Views
Posts: 49
Topic starter
(@jmcnab)
Eminent Member
Joined: 9 years ago

This was an issue back with WSP 2.1, where the contact was <GUID>@domain.com. And a lot of people complained about it so it was changed so that the username of the username@domain.com was used and then added as a local domain primarySMTPAddress. We ran into a several cases where this caused mail to be forwarded to the contact when the recipient address was the contact. In a few cases this was when an employee had left the company but a contact was created for the user. The new mail contact was the recipient of any mail that had come into the old address.

To recreate:

jdoe@domain.com leaves the company

jdoe@personalemaildomain.com is created as a contact.

PrimarySMTPaddress of the contact is created as jdoe@domain.com with external address of jdoe@personalemaildomain.com

Mail received for jdoe@domain.com now is delivered to the previous employees external address.

 

Would it be possible to have that primarySMTPAddress be created as something identifiable that should not cause mail routing issues? It appears that if that address already exists that it increments it as a jdoe1@domain.com

8 Replies
Posts: 1967
Admin
(@m-tiggelaar)
Noble Member
Joined: 9 years ago

Hello,

Sorry for my late reply.

In your situation does the problem occur that the contact can't be created due to duplicate mail?

(i did notice yesterday during my tests that the@domain .com of a contact depends on default domain in accepted domains).

Regards,

Marco

Reply
Posts: 49
Topic starter
(@jmcnab)
Eminent Member
Joined: 9 years ago

No, because it looks like if the address already exists that the primarySMTPAddress of the contact is automatically incremented so at least in my testing there are no collisions. So if jdoe@domain.com already existed the contact for jdoe@personalemaildomain.com would have a primarySMTPAddress of jdoe1@domain.com. This is sort of a workaround to the problem in that if the contact address would cause a problem creating two contacts and deleting the first would solve the mail routing issue.

But where the issue really lay is that it can cause inadvertent forwarding of messages to contacts, because they are effectively recipient domain members. Even having the forest domain as the primarySMTPAddress should, at least in theory, be a valid solution.

i.e.

jdoe@personalemaildomain.com is created as a contact. If his primarySMTPaddress were created as the forest domain (in this example hosting.local). So his primarySMTPAddress were created as jdoe@forest.local. Would solve the problem because we are only trying to resolve this primarySMTPaddress from the local forest.

Reply
Posts: 49
Topic starter
(@jmcnab)
Eminent Member
Joined: 9 years ago

Well the last suggestion doesn't quite work as advertised. I downloaded the source and tried it out. And writing the contact primarySMTPaddress as a domain.local. While in theory works. The recipient of the message gets the user@domain.local as the mailto.

 

15.00.1178.000; Mon, 8 Aug 2016 17:07:47 -0500
From: Jeremy McNab <jmcnab@domain.com>
To: Jeremy McNab <jmcnab@uathosting.local>
Subject: test
Thread-Topic: test

 

back to the drawing board....

Reply
Posts: 49
Topic starter
(@jmcnab)
Eminent Member
Joined: 9 years ago

Ok back at it again. So I made the following change. I'm curious of pitfalls and possible issues.

So I made a minor modification of SolidCP.Providers.HostedSolution.Exchange2013 CreateContactInternal method.

In short if the contact doesn't already exist it will create it as a normal contact. If the contact DOES exist already, then there would be no change to how it currently functions.

Its may not be a perfect solution. But may solve a few issues.

Thoughts?

 

private void CreateContactInternal(
string organizationId,
string organizationDistinguishedName,
string contactDisplayName,
string contactAccountName,
string contactEmail,
string defaultOrganizationDomain)
{
ExchangeLog.LogStart("CreateContactInternal");
ExchangeLog.DebugInfo("Organization Id: {0}", organizationId);
ExchangeLog.DebugInfo("Name: {0}", contactDisplayName);
ExchangeLog.DebugInfo("Account: {0}", contactAccountName);
ExchangeLog.DebugInfo("Email: {0}", contactEmail);

ExchangeTransaction transaction = StartTransaction();

Runspace runSpace = null;
try
{
runSpace = OpenRunspace();

string ouName = ConvertADPathToCanonicalName(organizationDistinguishedName);
// Generate a new GUID
string tempEmailUser = Guid.NewGuid().ToString("N");
string tempEmail = null;

if (CheckEmailExist(runSpace, contactEmail))
{
//if the contact exists then lets create the custom guid address
string[] parts = contactEmail.Split('@');

//Check if the contact exists. If it doesn't then we can use it else we need to recreate a new contact
if (parts.Length == 2)
{
if (CheckEmailExist(runSpace, parts[0] + "@" + defaultOrganizationDomain))
{
for (int num = 1; num < 100; num++)
{
string testEmailUser = parts[0] + num.ToString();
if (!CheckEmailExist(runSpace, testEmailUser + "@" + defaultOrganizationDomain))
{
tempEmailUser = testEmailUser;
break;
}
}
}
else

tempEmailUser = parts[0];
tempEmail = string.Format("{0}@{1}", tempEmailUser, defaultOrganizationDomain);
}

}
else
{
tempEmail = contactEmail;
}
//create contact
Command cmd = new Command("New-MailContact");
cmd.Parameters.Add("Name", contactAccountName);
cmd.Parameters.Add("DisplayName", contactDisplayName);
cmd.Parameters.Add("OrganizationalUnit", ouName);
cmd.Parameters.Add("Alias", contactAccountName);
cmd.Parameters.Add("ExternalEmailAddress", tempEmail);
Collection<PSObject> result = ExecuteShellCommand(runSpace, cmd);
string id = GetResultObjectDN(result);
transaction.RegisterNewContact(id);

//update contact
cmd = new Command("Set-MailContact");
cmd.Parameters.Add("Identity", contactAccountName);
cmd.Parameters.Add("EmailAddressPolicyEnabled", false);
cmd.Parameters.Add("CustomAttribute1", organizationId);
cmd.Parameters.Add("WindowsEmailAddress", tempEmail);

ExecuteShellCommand(runSpace, cmd);

SetContactEmail(id, contactEmail);

}
catch (Exception ex)
{
ExchangeLog.LogError("CreateContactInternal", ex);
RollbackTransaction(transaction);
throw;
}
finally
{

CloseRunspace(runSpace);
}

ExchangeLog.LogEnd("CreateContactInternal");
}

Reply
Page 1 / 2
Share: