AUTH:login
USER:username
PASS:password
其中username和password要用Base64编码后发送

解决方案 »

  1.   

    依次发送以下信息,其中username和password要用base64编码
    "Helo"                如果成功返回250
    "Auth Login"          如果成功返回334
    username              如果成功返回334
    password              如果成功返回235
    "Mail From:" + 发信人             250
    "Rcpt To:" + 收信人               250
    "Data" & vbcrlf                   354
    发信件内容 + vbcrlf + "." + vbcrlf  250
    "Quit"刚才写错了
      

  2.   

    很简单的
    Base64Encode就是所谓的Base64编码字符串的函数,InputStr为输入的字符串,OutputStr为输出的字符串Public Sub Base64Encode(ByVal InputStr As String, OutputStr As String)
       
       Dim length As Integer
       Dim i As Integer
       Dim remain As Integer
       
       length = Len(InputStr)
       remain = length Mod 3
       If remain <> 0 Then length = length + 3 - remain
       
       ReDim InByte(length) As Byte
       ReDim OutByte(length * 4 \ 3) As Byte
        
       CopyMemory InByte(0), ByVal InputStr, length
       
       For i = 0 To length \ 3 - 1
            EncodeBytes InByte, OutByte, i * 3, i * 4
       Next i
        
       OutputStr = String(length * 4 / 3, Chr(0))
       
       CopyMemory ByVal OutputStr, OutByte(0), length * 4 / 3
        
    End Sub
    Public Sub EncodeBytes(InByte() As Byte, OutByte() As Byte, ScrStart As Integer, DestStart As Integer)
        Dim tByte As Byte
        Dim i As Integer
        
        tByte = InByte(ScrStart) And &HFC
        OutByte(DestStart) = tByte / 4
        tByte = (InByte(ScrStart) And &H3) * 16 + (InByte(ScrStart + 1) And &HF0) / 16
        OutByte(DestStart + 1) = tByte
        tByte = (InByte(ScrStart + 1) And &HF) * 4 + (InByte(ScrStart + 2) And &HC0) / 64
        OutByte(DestStart + 2) = tByte
        tByte = InByte(ScrStart + 2) And &H3F
        OutByte(DestStart + 3) = tByte
        
        For i = DestStart To DestStart + 3
            If OutByte(i) >= 0 And OutByte(i) <= 25 Then
                OutByte(i) = OutByte(i) + Asc("A")
            ElseIf OutByte(i) >= 26 And OutByte(i) <= 51 Then
                OutByte(i) = OutByte(i) - 26 + Asc("a")
            ElseIf OutByte(i) >= 52 And OutByte(i) <= 61 Then
                OutByte(i) = OutByte(i) - 52 + Asc("0")
            ElseIf OutByte(i) = 62 Then
                OutByte(i) = Asc("+")
            Else
                OutByte(i) = Asc("/")
            End If
        Next
            If InByte(ScrStart + 2) = 0 And InByte(ScrStart + 1) = 0 Then
                OutByte(DestStart + 2) = Asc("=")
                OutByte(DestStart + 3) = Asc("=")
            ElseIf InByte(ScrStart + 2) = 0 Then
                OutByte(DestStart + 3) = Asc("=")
            End If
    End Sub
      

  3.   

    编码算法主要就是把3个字节变为4个字节,编码后每字节有6位(3 * 8 / 4) 有效,最高两位为0。 6位二进制表示能表示64种情况,然后把这64个数字用某种方法根可见字符对应起来就可以了
     EncodeBytes是把3个字节变为4个字节的函数.
      

  4.   

    忘了,里面还用了个API函数,定义如下
    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal length As Long)
      

  5.   

    完美..
    我之前也找到过一些,但由于,unicode和ansi字符串的关系..
    总不能得到理想的结果..
    多谢龙哥..
    接分.