我用163的smtp服务器在验证是提示错误535: authentication failed是怎么回事啊我注册的是163的帐号啊。 Base64_Code((unsigned char *)usersrc,(unsigned char *)userdes);
Base64_Code((unsigned char *)passsrc,(unsigned char *)passdes); send_data = "EHLO Localhost\r\n";

rt = send(s,send_data,strlen(send_data),0);
if(rt == SOCKET_ERROR)
{
return FALSE;
} if(!GetResponse())
return FALSE;
    
    send_data = "AUTH LOGIN\r\n";
rt = send(s,send_data,strlen(send_data),0);
if(rt == SOCKET_ERROR)
{
return FALSE;
}
if(!GetResponse())
return FALSE;

    wsprintf(ch,"%s\r\n",userdes);
rt = send(s,(char *)ch,strlen(ch),0);
if(rt == SOCKET_ERROR)
{
shutdown(s,SD_BOTH);
closesocket(s);
return FALSE;
} if(!GetResponse())
return FALSE;

wsprintf(ch,"%s\r\n",passdes);
//TRACE("ch = %s\n",ch);
rt = send(s,(char *)ch,strlen(ch),0);
if(rt == SOCKET_ERROR)
{
return FALSE;
} if(!GetResponse())
return FALSE;这是登陆时候的源码,错误就是在
wsprintf(ch,"%s\r\n",passdes);
//TRACE("ch = %s\n",ch);
rt = send(s,(char *)ch,strlen(ch),0);
if(rt == SOCKET_ERROR)
{
return FALSE;
}
if(!GetResponse())
return FALSE;
这个地方的应答是返回的,大家帮忙看一下到底有什么问题啊

解决方案 »

  1.   

    对了,我是个邮件发送系统在建立sock和连接服务器是都是正确的,到了验证这里就不对了。
      

  2.   

    wsprintf(ch,"%s\r\n",userdes);能编译通过吗?
      

  3.   

    应该采用什么编码方式啊,这个字符加密方法我不懂,大家帮忙看看有没有错误啊
    void CSmtp::Base64_Code( unsigned char *chsrc, unsigned char *chdes)
    {
    char chadd[3];
    unsigned char temp[4],t;

    int len,i;
    len = strlen((char *)chsrc);

        while(len>=3)
    {
    temp[0] = (*chsrc)>>2;
    t       = (*chsrc & 0x03)<<4;
    temp[1] = (*(chsrc+1)>>4)|t;
    t       = ((*(chsrc+1)<<2) & 0x3f);
    temp[2] = (*(chsrc+2)>>6)|t;
    temp[3] = (*(chsrc+2) & 0x3f); for(i=0;i<4;i++)
    {
    if(temp[i]>=0 && temp[i]<=25) 
    *(chdes+i) = temp[i]+65;
    if(temp[i]>=26 && temp[i]<=51) 
    *(chdes+i) = temp[i]+71;
    if(temp[i]>=52 && temp[i]<=61) 
    *(chdes+i) = temp[i]-4;
    if(temp[i]==62) 
    *(chdes+i) = 43;
    if(temp[i]==63) 
    *(chdes+i) = 47;
    }
            
    len -= 3;
    chsrc += 3;
    chdes += 4;
    }
        if(len!=0)
    {
    for(i=0;i<3;i++)
    chadd[i] = 0;
            memcpy(chadd,chsrc,len); temp[0] = chadd[0]>>2;
    t       = (chadd[0] & 0x03)<<4;
    temp[1] = (chadd[1]>>4)|t;
    t       = ((chadd[1]<<2) & 0x3f);
    temp[2] = (chadd[2]>>6)|t;
    temp[3] = chadd[2] & 0x3f; for(i=0;i<4;i++)
    {
    if(temp[i]>=0 && temp[i]<=25 && (i==0 || i==1)) *(chdes+i) = temp[i]+65;
    else  *(chdes+i) = 61;
    if(temp[i]>=26 && temp[i]<=51) *(chdes+i) = temp[i]+71;
    else if(temp[i]>=52 && temp[i]<=61) *(chdes+i) = temp[i]-4;
    else if(temp[i]==62) *(chdes+i) = 43;
    else if(temp[i]==63) *(chdes+i) = 47;
    }
    chdes += 4;
    *chdes = '\0';
    return;
    }
    *chdes = '\0';
    }void CSmtp::Base64_Decode( unsigned char *chsrc, unsigned char *chdes)
    {
    unsigned char temp[4],t;
    int len,i;
    len = strlen((char *)chdes);
    while(len>=4)
    {
    for(i=0;i<4;i++)
    {
    if(*(chdes+i)>=65 && *(chdes+i)<=90) 
     temp[i] = *(chdes+i)-65;
    if(*(chdes+i)>=97 && *(chdes+i)<=122) 
    temp[i] = *(chdes+i)-71;
    if(*(chdes+i)>=48 && *(chdes+i)<=57) 
    temp[i] = *(chdes+i)+4;
    if(*(chdes+i)==43) 
    temp[i] = 62;
    if(*(chdes+i)==47) 
    temp[i] = 63;
    if(*(chdes+i)==61)
    temp[i] = 0;
    }
    t = (temp[1]>>4)&0x03;
            *chsrc = (temp[0]<<2)|t;
    t = (temp[2]>>2)&0x0f;
    *(chsrc+1) = (temp[1]<<4)|t;
    t = temp[3];
    *(chsrc+2) = (temp[2]<<6)|t; chsrc += 3;
    chdes += 4;
    len   -= 4;
    }
    chsrc -= 3;
    for(i=0;i<3;i++)
    {
    if(*(chsrc+i) == 0)
    {
    *(chsrc+i) = '\0';
    break;
    }
    }
    if(i>=2)
    *(chsrc+3) = '\0';
    }
      

  4.   

    需要这样麻烦吗,给163.com的域用户 ,发信是不用登陆的,不用管它,给其它域发信,发多就封号,也没用,总之,smtp的登陆没意义