• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

How to relay external email when going through a CName record.

I have an application that is trying to send external emails through our Exchange 2007 server.  When I enter the IP of the Exchange server in the application it works.  However, when I enter in the CName record (alias record) of emailrelay.domain.local it does not work.  If I use the cname to only send internal email it will work.  I am using a domain user to authenticate.  Any ideas?
  • 4
  • 3
1 Solution
1. From your application server are you able to ping emailrelay.domain.local?
2. What is emailrelay.domain.local? Edge Server and other smart host - Please give more details
3. As you said have in your application you give the IP it works, did you try with hostname of exchange server(HUB Server) or the relay server?

If you want your application to directly send mails from relay server then you need to allow the application server IP for anonymous access. Give more details on points 1,2,3
jdouthitAuthor Commented:

1.  Yes I can ping emailrelay.domain.local
2.  emailrelay.domain.local is a CNAME record for my Exchange server.  I created this on my DNS server as an alias for my email server.  This way if we change to a server with a new name, IP, etc. I can simply redirect the CNAME record instead of having to change settings on multiple printers, programs, etc.
3.  I did try the hostname of the Exchange server and that does not work.

One thing to note is I have the IP of my application server added to the receive connector on my Hub Transport server under the network tab and the "receive mail from remote servers that have these IP addresses".  If I don't have this it doesn't work at all.  I'd like to have it authenticate off a specific username so that I don't have to enter in the IP of the server as this application will eventually be deployed to over 100 machines.
Yes you can create a service account for this application in AD and send mails using the credentials.

There is not special configuration required.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

jdouthitAuthor Commented:
I have a service account I am using for credentials already, but I still require to enter the IP of the application server in to allow it to pass through the receive connector.  I also still can't use the hostname of the email server.  I must use the IP of the email server.
Then check the DNS settings of your application server or check if you giving the CName correctly.
You can also add host entry in the application server and give a try.

The authentication works on certain parameters and these parameters are different for different applications and they need to entered correctly.
jdouthitAuthor Commented:
The DNS settings are correct.  I can ping the actual hostname or CName of the email server from the application server.  Attached is my test code.  We are having this issue in other programs as well, though.
'Dim Message Variables
Dim objMsg, strFrom, strTo, strSubject,lngImportance, strFile
'Get the values to use with the message from the post.
strFrom = "fromaddress@domain.com"
'Response.Write "strFrom: " & strFrom & "<br>"
strTo = "touser@gmail.com"
'Write "strTo: " & strTo & "<br>"
strSubject = "Received Items"
'Response.Write "strSubject: " & strSubject & "<br>"
'strFile = "porxnew.xls"
'Response.Write "strFile: " & strFile & "<br>"
'Create the Message Object
Set objMsg = CreateObject("CDO.Message")
If objMsg Is Nothing Then
	MsgBox "Could not create CDO NTS mail object"
	Set objMsg = Nothing
End If
'Set the properties of the Message
objMsg.From = strFrom
objMsg.To = strTo
objMsg.Subject = strSubject
'Use the actual Request Object so that you do not over load the string Data type.
objMsg.Textbody = "This is a Test!  Testing 1, 2, 3..."

'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.

objMsg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMsg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "exchangeserver.domain.local"
'("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.myserver.com"

'Server port (typically 25)
objMsg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMsg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

'Your UserID on the SMTP server
objMsg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "domain\\serviceaccount"

'Your password on the SMTP server
objMsg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password1234"

'Use SSL for the connection (False or True)
objMsg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMsg.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60



'Destroy the object
Set objMsg = Nothing
'Determine if there is a file on the server to delete.
If bolAttachmentPosted Then 
	Dim FSO
	'Create a File System Object
	Set FSO = server.CreateObject ("Scripting.FileSystemObject")
	'Delete the file from the server
	FSO.DeleteFile FilePath_Name
	'Destroy the object
	Set FSO = Nothing
End If

Open in new window

jdouthitAuthor Commented:
We ended up having to call in a consultant.  I'd like to still award points to this person because they were the only ones to help me and they stuck with it.

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now