added TSMTPSend AUTH PLAIN support

git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@106 7c85be65-684b-0410-a082-b2ed4fbef004
This commit is contained in:
geby 2009-10-26 09:26:37 +00:00
parent b3133aee36
commit 512bd392ee

View File

@ -1,9 +1,9 @@
{==============================================================================|
| Project : Ararat Synapse | 003.004.004 |
| Project : Ararat Synapse | 003.005.000 |
|==============================================================================|
| Content: SMTP client |
|==============================================================================|
| Copyright (c)1999-2007, Lukas Gebauer |
| Copyright (c)1999-2009, Lukas Gebauer |
| All rights reserved. |
| |
| Redistribution and use in source and binary forms, with or without |
@ -33,7 +33,7 @@
| DAMAGE. |
|==============================================================================|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
| Portions created by Lukas Gebauer are Copyright (c) 1999-2007. |
| Portions created by Lukas Gebauer are Copyright (c) 1999-2009. |
| All Rights Reserved. |
|==============================================================================|
| Contributor(s): |
@ -94,6 +94,7 @@ type
function ReadResult: Integer;
function AuthLogin: Boolean;
function AuthCram: Boolean;
function AuthPlain: Boolean;
function Helo: Boolean;
function Ehlo: Boolean;
function Connect: Boolean;
@ -347,7 +348,7 @@ end;
function TSMTPSend.AuthCram: Boolean;
var
s: string;
s: ansistring;
begin
Result := False;
FSock.SendString('AUTH CRAM-MD5' + CRLF);
@ -361,6 +362,16 @@ begin
Result := ReadResult = 235;
end;
function TSMTPSend.AuthPlain: Boolean;
var
s: ansistring;
begin
Result := False;
s := ansichar(0) + FUsername + ansichar(0) + FPassword;
FSock.SendString('AUTH PLAIN ' + EncodeBase64(s) + CRLF);
Result := ReadResult = 235;
end;
function TSMTPSend.Connect: Boolean;
begin
FSock.CloseSocket;
@ -441,7 +452,9 @@ begin
begin
if Pos('CRAM-MD5', auths) > 0 then
FAuthDone := AuthCram;
if (Pos('LOGIN', auths) > 0) and (not FauthDone) then
if (not FauthDone) and (Pos('PLAIN', auths) > 0) then
FAuthDone := AuthPlain;
if (not FauthDone) and (Pos('LOGIN', auths) > 0) then
FAuthDone := AuthLogin;
end;
end;