Fun with Web Bugs
While playing around with web bugs and email the other day I wrote up a quick email program that lets you interact with remote servers. Its none too refined but I thought I would post it in the downloads section. It allows you to write up HTML email by actually writing the HTML yourself. Basically its just a glorified port 25 telnet program. In the top window you can type commands to be issued directly to the server and view the response. I've compiled the VB6 code into a working exe that you can download here. The basic commands you will need are:
HELO yourcomputername
-this command introduces you to the remote server
MAIL FROM: youremail@yourdomain.com
-specifies where the mail is coming from
RCPT TO: recipient@theirdomain.com
-specifies the recipient
DATA
-This tells the server you're ready to write up your email, to finish hit return, then type a period (.) and the message will be ready to go
The Visual Basic code is really straightforward. If you're going to copy it make sure to include the WinSock control in your project. Let me know if you have any questions.
Private Sub btnClearInput_Click() txtInput.Text = "" End Sub Private Sub cmdGo_Click() Winsock1.RemoteHost = txtServer.Text Winsock1.RemotePort = 25 Winsock1.Connect If Winsock1.State = 0 Then txtOutput = "Closed" ElseIf Winsock1.State = 4 Then txtOutput = "Resolving Host" ElseIf Winsock1.State = 6 Then txtOutput = "Connecting" ElseIf Winsock1.State = 7 Then txtOutput = "Connected" ElseIf Winsock1.State = 7 Then txtOutput = "Peer is Closing Conn" ElseIf Winsock1.State = 9 Then txtOutput = "Error" Else txtOutput = Winsock1.State End If End Sub Private Sub cmdMail_Click() Dim theMail As String If Winsock1.State <> 7 Then MsgBox ("You must connect first"), vbCritical Exit Sub End If If txtFrom.Text = "" Then MsgBox ("You need a From:"), vbCritical Exit Sub ElseIf txtTo.Text = "" Then MsgBox ("You need a To:"), vbCritical Exit Sub End If theMail = "mail from: " & txtFrom.Text & vbCrLf theMail = theMail & "rcpt to: " & txtTo.Text & vbCrLf theMail = theMail & "data" & vbCrLf theMail = theMail & "Subject: " & txtSubject & vbCrLf theMail = theMail & "Content-Type: text/HTML; charset='US-Ascii'" & vbCrLf & vbCrLf theMail = theMail & txtBody & vbCrLf theMail = theMail & "." If Winsock1.State = sckConnected Then Winsock1.SendData theMail & vbCrLf Else MsgBox ("Unable to Send") End If End Sub Private Sub cmdQuit_Click() Winsock1.Close Unload Me End Sub Private Sub cmdSend_Click() If Winsock1.State = sckConnected Then Winsock1.SendData txtInput.Text & vbCrLf Else MsgBox ("Unable to Send") End If Dim sData As String Winsock1.GetData sData, vbString txtResponse.Text = txtResponse.Text & sData End Sub Private Sub Command1_Click() txtResponse.Text = "" End Sub Private Sub Text1_Change() End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Dim sData As String Winsock1.GetData sData, vbString txtResponse.Text = txtResponse.Text & sData End Sub Private Sub cmdUpdate_Click() If Winsock1.State = 0 Then txtOutput = "Closed" ElseIf Winsock1.State = 6 Then txtOutput = "Resolving Host" ElseIf Winsock1.State = 6 Then txtOutput = "Connecting" ElseIf Winsock1.State = 7 Then txtOutput = "Connected" ElseIf Winsock1.State = 7 Then txtOutput = "Peer is Closing Conn" ElseIf Winsock1.State = 9 Then txtOutput = "Error" Else txtOutput = Winsock1.State End If End Sub