SMTP/POP3 email client using SocketWrench 
Author Message
 SMTP/POP3 email client using SocketWrench

Hello guys/ladies,

      I'm writing a email client (SMTP/POP3 protocol) using SocketWrench.
It's not working as I would expect ... below are the sample handshaking
session with the SMTP server obtained from the debug window:

Server: 220 relay2.jaring.my ESMTP Sendmail ....
Client:  HELO j14.iph3.jaring.my
Server: 250 relay2.jaring.my Hello j14.iph3.jaring.my, please to meet you



Server: 250 Recipient OK
Client: DATA
Server: 354 Enter Mail, end with "." on a line by itself
Client:  .... the text from MailText variable

.

It's seems as if the server is still waiting for  some input from the client
b'cos it does not acknowledge OK after the CRLF + ". " + CRLF sequence.
Anyone got any idea where I went wrong ? Enclosed below are snippets of the
code I've written, using SocketWrench. Any help/suggestions is much
appreciated.

      Thanks a million in advance :)

Cordially,
Adrian Ling

ps: If you have a sample source code you don't mind sharing with me, I would
      appreciate that very much.
pps: If possible and if it's not too much trouble, could you reply via email ?
        Thanks.

------------------------------------------------------------------------------
Global:
Global LocalSys As String
Global SMTPCommand As String
Global MailText  As String
Global CRLF As String

Sub Form_Load()
    SMTP_State = 1000                  'define smtp state machine
    CRLF = Chr$(10) & Chr$(13)
    Socket1.AddressFamily = AF_INET
    Socket1.Protocol = IPPROTO_IP
    Socket1.Type = SOCK_STREAM
    Socket1.Binary = False
    Socket1.BufferSize = 1024
    Socket1.Blocking = False


    MailText = MailText & "Subject: SocketWrench VBX" & CRLF
    MailText = MailText & CRLF
    MailText = MailText & "Dear Goon," & CRLF & "My simple program"
    MailText = MailText & CRLF & "." & CRLF
End Sub

Sub Socket1_Read (DataLength As Integer, IsUrgent As Integer)    
    Socket1.RecvLen = DataLength
    txtReplyFromHost.Text = Socket1.RecvData & CRLF & CRLF
    SMTP_State = SMTP_State + 1
    Debug.Print "Reply: " & txtReplyFromHost.Text & CRLF
    Call SMTP_Process

End Sub

Sub SMTP_Process ()
    Select Case SMTP_State
        Case 1001
            SMTPCommand = "HELO " & LocalSys & CRLF
            If Socket1.IsWritable Then
                Socket1.SendLen = Len(SMTPCommand)
                Socket1.SendData = SMTPCommand
                Debug.Print "Sent: "; SMTPCommand
             End If
        Case 1002

            If Socket1.IsWritable Then
                Socket1.SendLen = Len(SMTPCommand)
                Socket1.SendData = SMTPCommand
                Debug.Print "Sent: "; SMTPCommand
             End If
        Case 1003

             If Socket1.IsWritable Then
                Socket1.SendLen = Len(SMTPCommand)
                Socket1.SendData = SMTPCommand
                Debug.Print "Sent: "; SMTPCommand
            End If
        Case 1004
            SMTPCommand = "DATA" & CRLF
            If Socket1.IsWritable Then
                Socket1.SendLen = Len(SMTPCommand)
                Socket1.SendData = SMTPCommand
                Debug.Print "Sent: "; SMTPCommand
            End If
        Case 1005
            SMTPCommand = MailText ' & CRLF & "." & CRLF
            If Socket1.IsWritable Then
                Socket1.SendLen = Len(SMTPCommand)
                Socket1.SendData = SMTPCommand
                txtSendToHost.Text = SMTPCommand
                 Debug.Print "Sent: "; SMTPCommand
            End If
        Case 1006
            SMTPCommand = "QUIT" & CRLF
            If Socket1.IsWritable Then
                Socket1.SendLen = Len(SMTPCommand)
                Socket1.SendData = SMTPCommand
                Debug.Print "Sent: "; SMTPCommand
            End If
    End Select

End Sub



Sat, 15 Aug 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. How do i send a email in vb using pop3 and smtp

2. Get Email Address and pop3 account and smtp server Defaults

3. send and receive emails (SMTP, POP3)

4. Internet Email SMTP/POP3

5. Need a control to provide POP3 client capabilities and SMTP outbound

6. send and receive emails (SMTP, POP3)

7. Receiving emails through POP3 Sending with SMTP in VB5

8. WANTED: Looking for SMTP/POP3 and other controls for custom email

9. Email Control ( SMTP and POP3)

10. WANTED: Looking for SMTP/POP3 and other controls for custom email

11. Receiving emails through POP3 Sending with SMTP in VB5

12. send and receive emails (SMTP, POP3)

 

 
Powered by phpBB® Forum Software