有关邮件服务器类的帮助 [英] Help about a mail server class
本文介绍了有关邮件服务器类的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨;
i正在编写一个代表电子邮件服务器的简单类,以及测试所提供的邮件服务器信息的测试方法,但是,当我尝试连接smtp.live.com时:启用ssl我得到一个异常意外的数据包格式,我正在使用MailSystem.Net API并使用SMTPClient类进行测试。
欢迎任何帮助,谢谢。
这是我的班级:
Hi;
i am writing a simple class representing an email server, and a Test Method to test the provided Mail Server informations, however, when i try to connect with smtp.live.com:25 with ssl enabled i got an exception "unexpected packet format" , i''m using MailSystem.Net API and testing with SMTPClient Class.
Any help is welcome , thank you.
Here is my Class :
Public Class MailServer
'Ctors :
Public Sub New()
Me.Host = "smtp.host.ext"
Me.Port = 25
Me.Secured = False
End Sub
Public Sub New(ByVal host As String, ByVal port As Integer, ByVal secured As Boolean)
Me.Host = host
Me.Port = port
Me.Secured = secured
End Sub
'Properties :
Private _Host As String
Public Property Host As String
Get
Return _Host
End Get
Set(value As String)
_Host = value
End Set
End Property
Private _Port As Integer
Public Property Port As Integer
Get
Return _Port
End Get
Set(value As Integer)
If value >= Net.IPEndPoint.MinPort OrElse value <= Net.IPEndPoint.MaxPort Then
_Port = value
End If
End Set
End Property
Private _Secured As Boolean
Public Property Secured As Boolean
Get
Return _Secured
End Get
Set(value As Boolean)
_Secured = value
End Set
End Property
End class
这是测试方法:
And Here is the Test method :
Public Sub Test(ByVal ms As MailServer)
Try
If ms.Secured = True Then
_TestSmtp.ConnectSsl(ms.Host, ms.Port)
Else
_TestSmtp.Connect(ms.Host, ms.Port)
End If
Catch ex As Exception
'Message Box Here...
End Try
End Sub
推荐答案
端口25通常不与SSL一起使用。检查live.com的规格你必须使用哪个端口(587,997或类似的东西)。
Port 25 is normally not used with SSL. Check the specs from live.com which port you have to use (587, 997, or something like that).
这篇关于有关邮件服务器类的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文