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

Posted on 2011-05-12
Last Modified: 2012-05-11
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?
Question by:jdouthit
    LVL 8

    Accepted 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

    Author Comment


    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.
    LVL 8

    Expert Comment

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

    There is not special configuration required.

    Author Comment

    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.
    LVL 8

    Expert Comment

    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.

    Author Comment

    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 = ""
    'Response.Write "strFrom: " & strFrom & "<br>"
    strTo = ""
    '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 _
    ("") = 2
    'Name or IP of Remote SMTP Server
    objMsg.Configuration.Fields.Item _
    ("") = "exchangeserver.domain.local"
    '("") = ""
    'Server port (typically 25)
    objMsg.Configuration.Fields.Item _
    ("") = 25
    'Type of authentication, NONE, Basic (Base64 encoded), NTLM
    objMsg.Configuration.Fields.Item _
    ("") = 1
    'Your UserID on the SMTP server
    objMsg.Configuration.Fields.Item _
    ("") = "domain\\serviceaccount"
    'Your password on the SMTP server
    objMsg.Configuration.Fields.Item _
    ("") = "password1234"
    'Use SSL for the connection (False or True)
    objMsg.Configuration.Fields.Item _
    ("") = False
    'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
    objMsg.Configuration.Fields.Item _
    ("") = 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


    Author Closing Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Set OWA language and time zone in Exchange for individuals, all users or per database.
    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
    To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now