各位高人:
    小可在用第三方组件SakSMTP和DELPHI自带的组件TNMSMTP时遇到了一个比较困惑的问题,那就是发送邮件时SMTP服务器都要进行身份验证,上述两个组件都没有提供验证的接口,我找了一个星期都都没有找到解决的办法,现在我的邮件程序只能收,发送新邮件总是失败.请各位高人指点迷津,小可先谢谢各位了!

解决方案 »

  1.   

    有的,我就用过带验证的发邮件的程序,
    function EncodeBase64(Source:string):string;
    var
    Times, LenSrc, i: Integer;
    x1, x2, x3, x4: Char;
    xt: Byte;
    begin
    Result := '';
    LenSrc := Length(Source);
    if LenSrc mod 3 = 0 then
    Times := LenSrc div 3
    else
    Times := LenSrc div 3 + 1;
    for i := 0 to Times - 1 do
    begin
    if LenSrc >= (3 + i * 3) then
    begin
    x1 := BaseTable[(ord(Source[1 + i * 3]) shr 2)+1];
    xt := (ord(Source[1 + i * 3]) shl 4) and 48;
    xt := xt or (ord(Source[2 + i * 3]) shr 4);
    x2 := BaseTable[xt + 1];
    xt := (Ord(Source[2 + i * 3]) shl 2) and 60;
    xt := xt or (Ord(Source[3 + i * 3]) shr 6);
    x3 := BaseTable[xt + 1];
    xt := (ord(Source[3 + i * 3]) and 63);
    x4 := BaseTable[xt + 1];
    end
    else if LenSrc >= (2 + i * 3) then
    begin
    x1 := BaseTable[(Ord(Source[1 + i * 3]) shr 2) + 1];
    xt := (Ord(Source[1 + i * 3]) shl 4) and 48;
    xt := xt or (Ord(Source[2 + i * 3]) shr 4);
    x2 := BaseTable[xt + 1];
    xt := (Ord(Source[2 + i * 3]) shl 2) and 60;
    x3 := BaseTable[xt + 1];
    x4 := '=';
    end else
    begin
    x1 := BaseTable[(Ord(Source[1 + i * 3]) shr 2)+1];
    xt := (Ord(Source[1 + i * 3]) shl 4) and 48;
    x2 := BaseTable[xt + 1];
    x3 := '=';
    x4 := '=';
    end;
    Result := Result + x1 + x2 + x3 + x4;
    end;
    end; 这个是个验证程序
    在连接的事件中加入 if nmsmtp_my.ReplyNumber = 250 then
    nmsmtp_my.Transaction('auth login');
    if nmsmtp_my.ReplyNumber = 334 then
    begin
    nmsmtp_my.Transaction(EncodeBase64('//')); 这里输入你的用户名
    nmsmtp_my.Transaction(EncodeBase64('//'));这里输入你的密码
    end;