如何让SAKEMAIL支持SMTP认证?(100分)

  • 主题发起人 主题发起人 wphmoon
  • 开始时间 开始时间
W

wphmoon

Unregistered / Unconfirmed
GUEST, unregistred user!
请问诸位大侠知道那个版本的SAKEMAIL支持smtp认证吗,或者贴出代码片断,谢谢!
 
我也很想知道!!! 有答案请通知我,谢谢。
 
自己加一段不就行了?
看看ICS的source ,
ESMTP的connet后,发个ehlo
一般esmtp会返回是否需要认证的 AUTH LOGIN 信息.
检索到这个返回信息后.
然后依次发送auth LOGIN
USERNAME 用mime方式编码
PASSWORD 用mime方式编码

就行了.
 
SAKEMAIL最新版3。4。3不知是否支持。
 
我曾经在大富翁上看到有人贴过一个帖子,但不知其Tbase为何物,贴出来大家讨论讨论
function TSakSMTP.Authenticate: boolean;

function AuthLogin: Boolean;
var
Base64: TBase64;
stemp: string;
begin
FSendTextToSocket('auth LOGIN' + crlf);
FReceiveTextFromSocket;
if FReplyCode <> '334' then
begin
Result := false;
exit;
end;

Base64 := TBase64.Create;

Base64.EncodeData(UserID, stemp);
FSendTextToSocket(stemp + crlf);
FReceiveTextFromSocket;
if (FReplyCode <> '235') and (FReplyCode <> '334') then
begin
Result := false;
Base64.Free;
exit;
end;
stemp:='';
Base64.EncodeData(Password, stemp);
FSendTextToSocket(stemp + crlf);
FReceiveTextFromSocket;
if FReplyCode <> '235' then
begin
Result := false;
Base64.Free;
exit;
end;
Base64.Free;
Result := True;
end;

begin
Result := False;
case FAUthenticationType of
atLogin: Result := AuthLogin;
end;
FDidAuthenticate := True;
end;

 
看看indy的辕马就知道了.indy也是delphi6将要使用的internet控件.

Tbase64其实就是个按base64 方式编码的类而已.
>>Base64.EncodeData(UserID, stemp); //把userID按base64编码付给stemp
>>FSendTextToSocket(stemp + crlf); //发送stemp就是编码后的userid


这里有个例子:
可以编码成encUUEncode 和base64格式.
THttpEncoding = (encUUEncode, encBase64, encMime);

{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function EncodeStr(Encoding : THttpEncoding; const Value : String) : String;
begin
Result := EncodeLine(Encoding, @Value[1], Length(Value));
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
function EncodeLine(
Encoding : THttpEncoding;
SrcData : PChar;
Size : Integer) : String;
var
Offset : Integer;
Pos1 : Integer;
Pos2 : Integer;
I : Integer;
begin
SetLength(Result, Size * 4 div 3 + 4);
FillChar(Result[1], Size * 4 div 3 + 2, #0);

if Encoding = encUUEncode then begin
Result[1] := Char(((Size - 1) and $3f) + $21);
Size := ((Size + 2) div 3) * 3;
end;
Offset := 2;
Pos1 := 0;
Pos2 := 0;
case Encoding of
encUUEncode: Pos2 := 2;
encBase64, encMime: Pos2 := 1;
end;
Result[Pos2] := #0;

while Pos1 < Size do begin
if Offset > 0 then begin
Result[Pos2] := Char(ord(Result[Pos2]) or
((ord(SrcData[Pos1]) and
($3f shl Offset)) shr Offset));
Offset := Offset - 6;
Inc(Pos2);
Result[Pos2] := #0;
end
else if Offset < 0 then begin
Offset := Abs(Offset);
Result[Pos2] := Char(ord(Result[Pos2]) or
((ord(SrcData[Pos1]) and
($3f shr Offset)) shl Offset));
Offset := 8 - Offset;
Inc(Pos1);
end
else begin
Result[Pos2] := Char(ord(Result[Pos2]) or
((ord(SrcData[Pos1]) and $3f)));
Inc(Pos2);
Inc(Pos1);
Result[Pos2] := #0;
Offset := 2;
end;
end;

case Encoding of
encUUEncode:
begin
if Offset = 2 then
Dec(Pos2);
for i := 2 to Pos2 do
Result := bin2uue[ord(Result)+1];
end;
encBase64, encMime:
begin
if Offset = 2 then
Dec(Pos2);
for i := 1 to Pos2 do
Result := bin2b64[ord(Result)+1];
while (Pos2 and 3) <> 0 do begin
Inc(Pos2);
Result[Pos2] := '=';
end;
end;
end;
SetLength(Result, Pos2);
end;
 
接受答案了.
 
后退
顶部