Sending email in ASP.NET to Exchange server on same network

* .NET 2.0 site setup on the same network/domain (different box) as the Exchange server
* Sending mail using System.Net.Mail.SmtpClient using a different remote mail server (tried the same as well)
* Mail is being delivered to all addresses EXCEPT those on the domain
   (delivered to me@yahoo.com but not me@mydomain.com)

I can't find anything on people having this issue.

What do I need to do? Site is in VB but C# is fine, too.

Thanks
LVL 1
m_soltisAsked:
Who is Participating?
 
zadeveloperConnect With a Mentor Commented:
You could also check out your mx records:

On the net your mx records will be setup up to a public ip address (ie: mx.yourdomain.com). When trying to send mail, the mail client trys to deliver to that address. Internally there should be a dns record that mimics the external one pointing to the local server address.

Try this:
Find out what your mx records are for your domain.
Then on the "other" SMTP Server that you are using to send mail ensure that the dns name points to the local ip address of your exchange server (either by adding a dns record to your dns server or if you are using a microsoft box add the record to the hosts file (%System32%\drivers\etc\hosts)


0
 
DCMBSCommented:
Sounds like your exchange server is configured not to accept email from other computers.  What version of Exchange do you have?
0
 
m_soltisAuthor Commented:
Thanks guys.
I don't have control over or access to anything in the domain except the webserver box. I would be willing to bet the MX servers point to the external IP for the domain, but I don't have a way of checking ths (or the Exchange version).
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
m_soltisAuthor Commented:
And I'm sure the EX server accepts email from other computers - it will take mail from the account I'm using to bounce off of using the mail.smtpclient and anywhere else...
0
 
zadeveloperCommented:
Then add the mx host name into the hosts file, pointing it to the local ip of the exchange box.
0
 
DCMBSCommented:
I don't really see this.  On my network I can send email to the MX record of my domain which is pointing to my external IP and the email is delivered OK.  It just goes out via the internet and back in via the external IP which you may say is an unneccessary out and in trip but it does get there. If this fixes your issue then good I am pleased but if not please post back and we can try some more investigations to pin down the problem.

How is you email configured in the site? What mailserver are you specifying and how is it specified?

Try telnetting to both your internal and external IP addresses on port 25 and sending test emails via telnet and see if any get through or if you get a rejection. see the following link for using Telnet to test a mail server.
http://support.microsoft.com/kb/323350.

I
0
 
zadeveloperCommented:
DCMBS:
Hi, I am only investigating this issue as I know it was the problem out our site. I am simply waiting for a "I get replys pinging the mx record from the smtp server" or not.
0
 
DCMBSCommented:
you can use nslookup to find your mx records
type the following in a command window

nslookup
set type=MX
www.yourdomain.com

this should list your mx records.
0
 
DCMBSCommented:
zadeveloper:

I agree it's a possible cause and worth investigting.
0
 
m_soltisAuthor Commented:
This all worked fine until they moved the Exchange server onto their local domain if that's a hint. They're still receiving email fine, just not from the site. Still not sure where the MX issue would be if other mail is being received, but am checking on that now...

DCMBS, here's the code I'm using (and use often without ever having an issue):

Dim oMsg As New System.Net.Mail.MailMessage
oMsg.From = New System.Net.Mail.MailAddress("sender@localDomain.com")

oMsg.To.Add(New System.Net.Mail.MailAddress("recipient@localDomain.com)) ' does not get delivered
oMsg.To.Add(New System.Net.Mail.MailAddress("recipient@otherDomaincom")) 'gets delivered

oMsg.Bcc.Add(New System.Net.Mail.MailAddress("recipient@localDomain.com")) ' does not get delivered
oMsg.Bcc.Add(New System.Net.Mail.MailAddress("bcc@otherDomain.com")) 'gets delivered

oMsg.Subject = "subject"
Dim b As New String("HTML email message goes here")
       
        oMsg.Body = b
        oMsg.IsBodyHtml = True

        Dim oSmtp As New System.Net.Mail.SmtpClient("smtp.everyone.net")
        oSmtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network

        Dim oCredential As New System.Net.NetworkCredential("user@unrelatedDomain.com", "password")
        oSmtp.UseDefaultCredentials = False
        oSmtp.Credentials = oCredential

        oSmtp.Send(oMsg)

0
 
zadeveloperCommented:
What is the domain name?
0
 
m_soltisAuthor Commented:
ctech-ind.com
0
 
zadeveloperCommented:
The fact that you say it was working while hosted externally confirms that this is most proberly the issue.
From your SMTP server that you are sending from - ping mail.ctech-ind.com. You must get the internal address.
If not go to c:\Windows\System32\drivers\etc\ and in the hosts file add the following line (replacing 0.0.0.0 with the internal IP address): (On the smtp server)
0.0.0.0 intranet.unitrade.co.za
0
 
m_soltisAuthor Commented:
The SMTP account that's being used is an outsourced box @ everyone.net.
This has something to do with the Exchange server rejecting the incoming emails - I can send to the addresses fine using the same everyone.net email account that I'm impersonating in the code.
0
 
zadeveloperCommented:
If exchange is not accepting mail it should give you an error code. Does .send() complete successfully?
0
 
m_soltisAuthor Commented:
Yes, the code completes without throwing any errors.
Bounced back mail just shows undeliverable/recipient could not be reached with no error code, then I forward the emails (I get a copy at a non-related email address) and they deliver.
0
 
zadeveloperCommented:
try changing:
oMsg.From = New System.Net.Mail.MailAddress("sender@localDomain.com")
to
oMsg.From = New System.Net.Mail.MailAddress("sender@someOtherDomain.com")

- This could be activating a "anti-impersonation" rule
0
 
DCMBSCommented:
I would like to see the results of testing with telnet as I suggested .  This should let you see if the server is being reached and the error code it is returning.
0
 
DCMBSCommented:
your MX record is mail.ctech-ind.com with IP address of 92.11.234.2.

Telneting to this gives the following output

telnet mail.ctech-ind.com 25
220 ctech-ind.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.211 ready at
Thu, 31 Dec 2009 18:33:46 -0500
Thu, 31 Dec 2009 18:33:46 -0500
ehlo everyone.net
250-ctech-ind.com Hello [82.12.1.165]
250-TURN
250-SIZE
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250-X-EXPS GSSAPI NTLM LOGIN
250-X-EXPS=LOGIN
250-AUTH GSSAPI NTLM LOGIN
250-AUTH=LOGIN
250-X-LINK2STATE
250-XEXCH50
250 OK
mailfrom
500 5.3.3 Unrecognized command
mail from: sender@everyone.net
250 2.1.0 sender@everyone.net....Sender OK
rcpt to:recipient@ctech-ind.com
550 5.1.1 User unknown

Can you try the same from your machine and post the output.
Incidently this appears to be Exchange server 2000.  I don't recognise the serial number in the banner  as Exchaneg 2000 RTM was 6.0.4417.
0
 
DCMBSCommented:
Incidently Happy New Year
0
 
m_soltisAuthor Commented:
Happy New Year to you as well. Will dive into this on Saturday & thanks for the help.
0
 
m_soltisAuthor Commented:
"This could be activating a "anti-impersonation" rule - "
Already tried that to no avail...
0
 
zadeveloperCommented:
Have you had a solution to this issue yet?
0
 
m_soltisAuthor Commented:
Hey - Sorry I left this hanging.
Think it was a caching issue at everyone.net - I changed the SMTP server to a box outside of everyone.net & it worked.

Thanks for the help.
0
All Courses

From novice to tech pro — start learning today.