邮件发送遇到问题,最后这个“.”发送失败

 BOOL CSmtp::SendEnd() /*发送结尾信息*/
{

    CString sendBuff;
    sendBuff = ".\r\n";
    return Send(sendBuff);

}


BOOL CSmtp::Send(CString &message)
{
    int n = message.GetLength();
    string msg = message.GetBuffer(n);
    char msg_buff[10240] = { 0 };
    strcpy(msg_buff, msg.c_str());
    int err = send(sockClient, msg_buff, n, 0);
    if (err == SOCKET_ERROR)
    {
        return FALSE;
    }
    cout << message << endl;
    return TRUE;
}

图片说明

你不用字符串,用BYTE数组等来发送数据

你不用字符串,用BYTE数组等来发送数据


BOOL CSmtp::SendEnd() /*发送结尾信息*/
{

    BYTE point={'.'};
    CString sendBuff;
    memcpy((void*)sendBuff.GetBuffer(sendBuff.GetLength()),(const void *)point,sizeof(point));
    return Send(sendBuff);

}

改成这样,程序直接停止运行