Hi I do an dns test before i send mail to ensure i dont get errors. But there is a problem, when i try to send an email to an adress xxxxx@eco-log.se i get an error from the dns function. when i try to delete the "-" in the mail adress it works.
at first i tohught it was because of the "-", but i made an email at zzzzzz@eh-design.se and it works like a charm, what could be the problem then? It is 100% sure that "xxxxx@eco-log.se" is an existing email/dns. The error message im getting is "No such known source"(freely translated)
Heres th开发者_如何学Pythone dns check code:
Public Function testDNS(ByVal dnsstring As String) As Boolean
Dim email As String = dnsstring
Dim host As String() = email.Split("@")
Dim hostName As String = host(1)
Dim socket As Net.Sockets.Socket
Try
Dim entry As IPHostEntry = Dns.GetHostEntry(hostName)
Dim endPoint As New IPEndPoint(entry.AddressList(0), 25)
socket = New Sockets.Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
Return True
socket.Connect(endPoint)
Catch se As SocketException
Try
Return False
Catch ex As Exception
End Try
End Try
End Function
I believe the problem you are facing here are 2 assumptions. These are:
- That there is a DNS record for domain.se. There are many domains that have entries like www.domain.se but not domain.se
- That should this host (entry) exist that there is a mail server listening in on port 25.
Since the mail server may live on a completley different hostname there are DNS records called MX or Mail eXchange. These point to where the mail server actually is. Unfortunatly unless you use a 3rd party control or some more complicated .net calls I am not sure if you can specify which TYPE of dns records to return (please comment this if I am wrong :) ).
There are components that you can get that will check all these sorts of things and more eg. http://www.dart.com/ptmlvnet_overview.aspx. I have not used this particular control but this will try and connect to the mail server and stop just short of sending the email to see if the remote server reports if the email address in not valid or does not exist. I have seen others as will so try either googling or binging "Email Address Validation Component .net".
I hope this helps explain why you are having problems.
Jonathan
It looks like you are only trying to resolve the A(ddress) record for the domain 'eco-log.se'
Dim entry As IPHostEntry = Dns.GetHostEntry(hostName)
But that domain does not have an A record configured, only Google MX are present:
$ host eco-log.se
eco-log.se mail is handled by 10 aspmx.l.google.com.
eco-log.se mail is handled by 20 alt1.aspmx.l.google.com.
eco-log.se mail is handled by 20 alt2.aspmx.l.google.com.
eco-log.se mail is handled by 30 aspmx2.googlemail.com.
eco-log.se mail is handled by 30 aspmx3.googlemail.com.
eco-log.se mail is handled by 30 aspmx4.googlemail.com.
eco-log.se mail is handled by 30 aspmx5.googlemail.com.
The reason why ecolog.se and eh-design.se work is that both domains have A records configued:
$ host ecolog.se
ecolog.se has address 213.188.129.183
$ host eh-design.se
eh-design.se has address 212.97.133.22
eh-design.se mail is handled by 10 mail4.surftown.se.
By standard, you should use the servers listed in the MX records to send mail to and only fall back to A records if no MX records are configured - not the other way round.
精彩评论