Link to home
Start Free TrialLog in
Avatar of m_soltis
m_soltis

asked on

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
Avatar of DCMBS
DCMBS
Flag of United Kingdom of Great Britain and Northern Ireland image

Sounds like your exchange server is configured not to accept email from other computers.  What version of Exchange do you have?
ASKER CERTIFIED SOLUTION
Avatar of Jarrod
Jarrod
Flag of South Africa image

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 m_soltis
m_soltis

ASKER

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).
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...
Then add the mx host name into the hosts file, pointing it to the local ip of the exchange box.
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
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.
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.
zadeveloper:

I agree it's a possible cause and worth investigting.
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)

What is the domain name?
ctech-ind.com
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
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.
If exchange is not accepting mail it should give you an error code. Does .send() complete successfully?
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.
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
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.
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.
Incidently Happy New Year
Happy New Year to you as well. Will dive into this on Saturday & thanks for the help.
"This could be activating a "anti-impersonation" rule - "
Already tried that to no avail...
Have you had a solution to this issue yet?
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.