Link to home
Start Free TrialLog in
Avatar of jdouthit
jdouthitFlag for United States of America

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of ckeshav
ckeshav

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jdouthit

ASKER

ckeshav,

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.
Avatar of ckeshav
ckeshav

Yes you can create a service account for this application in AD and send mails using the credentials.

There is not special configuration required.
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.
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


objMsg.Configuration.Fields.Update

objMsg.Send


'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

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.