Tech Off Thread

3 posts

Does anyone know how to use SSL with Indy Sockets POP3?

Back to Forum: Tech Off
  • User profile image
    DavidDilley

    I have been working with SMTP and POP3 in a Visual Developer for Web 2012 project using Indy Sockets. The standard server protocols work great but I have run into a snag attempting to implement SSL. There are a number of SMTP & POP servers out there that require SSL, including Gmail and I would like to make it available in the project. However, I cannot seem to find any good documentation on SSL for Indy Sockets SMTP & POP3 objects. The only place I could find anything about SSL for Indy Sockets was listed on a reference from an Indy Sockets knowledge base article pointing to an item posted on Intellicom (http://www.intelicom.si/en/forum/list.php?f=3) but the link gives a Not Found error when followed.

    I am looking for some documentation that could help with using SSL with Indy Sockets. If anyone knows where I can find documentation or some code examples I would greatly appreciate being pointed in the right direction. I have posted some code below that I am using to implement SSL for POP3, bit it does not seem to work when 'UseSSL' is set to true.

    Thanks

    David

     Dim xHost As String = Session.Item("POPServer")
    Dim xUsername As String = Session.Item("POPUser")
    Dim xPassword As String = Session.Item("POPPassword")
    Dim xPort As String = Session.Item("POPPort")
    Dim xSSL As Boolean = Session.Item("POPUseSSL")
    Dim xPOP3 As POP3 = New POP3
    Dim xMsg As Message = New Message()
    xPOP3.Username = xUsername
    xPOP3.Password = xPassword
    xPOP3.Port = CType(xPort, Integer)
    If xSSL Then xPOP3.AuthType = POP3AuthenticationType.atSASL
    Try
    xPOP3.Connect(xHost)
    Dim xCount As Integer = xPOP3.CheckMessages()
    ReDim TheEmailMessages(xCount, msgCount)
    If xCount = 0 Then
    Exit Function
    Else
    For ACounter = 1 To xCount
    xPOP3.Retrieve(ACounter, xMsg)
    TheEmailMessages(ACounter, msgSubject) = xMsg.Subject.ToString
    TheEmailMessages(ACounter, msgFrom) = xMsg.From.Text
    TheEmailMessages(ACounter, msgTo) = xMsg.Recipients(0).Text
    TheEmailMessages(ACounter, msgBody) = xMsg.Body.Text
    TheEmailMessages(ACounter, msgMsgID) = xMsg.MsgId.ToString 
    TheEmailMessages(ACounter, msgAddress) = xMsg.From.Address.ToString
    TheEmailMessages(ACounter, msgNumber) = Str(ACounter).Trim
    TheEmailMessages(ACounter, msgDate) = Indy.Sockets.Units.IdGlobalProtocols.DateTimeToInternetStr(xMsg.Date, False) 
    Next
    End If
    Catch ex As Exception
    Debug.Print ex.Message
    End Try
    xPOP3.Disconnect()
    

  • User profile image
    DavidDilley

    PS. I am assuming that the problem comes in at line 11 when xPOP3.AuthType is set to POP2AuthenticationType.atSASL if  the session variable POPUseSSL is true. I am guess that atSASL is not the same as the actual SSL protocol. When the POP3 authentication type is set to atSASL in line 11 the code on line 13 where it connects to the host after timing out it produces the exception 'Connection Closed Gracefully'

  • User profile image
    figuerres

    have you tried using the pop / smtp from lumi soft ? I have used the mail server they wrote and had good luck with it and they have a very good set of  pop / smtp / imap code you can read if you want.

    http://www.lumisoft.ee/lsWWW/ENG/Products/Mail_Server/mail_index_eng.aspx?type=info

     

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.