From 512bd392eef41fd28cff62ddf42275cb6109447e Mon Sep 17 00:00:00 2001 From: geby Date: Mon, 26 Oct 2009 09:26:37 +0000 Subject: [PATCH] added TSMTPSend AUTH PLAIN support git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@106 7c85be65-684b-0410-a082-b2ed4fbef004 --- smtpsend.pas | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/smtpsend.pas b/smtpsend.pas index b91c2ff..f597ef9 100644 --- a/smtpsend.pas +++ b/smtpsend.pas @@ -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;