Difference between revisions of "TSmtpCli.Auth"
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | [[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TSmtpCli]].Auth | + | [[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TSmtpCli]] ->[[TSmtpCli.Auth | Auth]] |
== Definition == | == Definition == | ||
Line 9: | Line 9: | ||
== Description == | == Description == | ||
− | Sends SMTP command '''AUTH''' to the mail server to start SMTP authentication according property [[TSmtpCli.AuthType | AuthType]]. | + | Sends SMTP command '''AUTH''' to the mail server to start SMTP authentication according property [[TSmtpCli.AuthType | '''AuthType''']]. |
− | + | ||
+ | Note that if property [[TSmtpCli.AuthType | AuthType]] has been set to [[TSmtpCli.AuthType |'''smtpAuthAutoSelect''']] the component won't silently fall back to [[TSmtpCli.AuthType | smtpAuthNone]] if no matching authentication method could be detected, instead method Auth would return with error > 0 in event [[TSmtpCli.OnRequestDone | OnRequestDone]]. | ||
+ | |||
+ | Also note that any kind of SMTP authentication requires that method [[TSmtpCli.Ehlo | Ehlo]] instead of [[TSmtpCli.Helo | Helo]] has been called previously. | ||
== Example == | == Example == | ||
Line 17: | Line 20: | ||
== Best practices == | == Best practices == | ||
+ | |||
+ | ==== Using open to handle all in one request ==== | ||
+ | |||
+ | The easiest way to use authentication is to use Open instead of Connect. Open handles the Connect, EHLO and AUTH in one so that you don't need to consider it. This is a typical call to open. | ||
+ | |||
+ | Smtp.Username := 'bob'; | ||
+ | Smtp.Password := 'test'; | ||
+ | Smtp.authtype := smtpAuthAutoSelect; | ||
+ | Smtp.open | ||
+ | |||
+ | In your requestdone event you handle open and trigger the mailfrom-metohd. | ||
+ | |||
+ | if RqType = smtpOpen then | ||
+ | begin | ||
+ | Smtp.MailFrom; | ||
+ | end; | ||
+ | |||
+ | From there you use the ordinary methods you would use without authentication. | ||
+ | |||
== How to == | == How to == |
Latest revision as of 13:46, 23 September 2007
Main page -> ICS component reference -> TSmtpCli -> Auth
Contents
Definition
procedure Auth;
Inherited from TCustomSmtpCli.Auth
Description
Sends SMTP command AUTH to the mail server to start SMTP authentication according property AuthType.
Note that if property AuthType has been set to smtpAuthAutoSelect the component won't silently fall back to smtpAuthNone if no matching authentication method could be detected, instead method Auth would return with error > 0 in event OnRequestDone.
Also note that any kind of SMTP authentication requires that method Ehlo instead of Helo has been called previously.
Example
....
Best practices
Using open to handle all in one request
The easiest way to use authentication is to use Open instead of Connect. Open handles the Connect, EHLO and AUTH in one so that you don't need to consider it. This is a typical call to open.
Smtp.Username := 'bob'; Smtp.Password := 'test'; Smtp.authtype := smtpAuthAutoSelect; Smtp.open
In your requestdone event you handle open and trigger the mailfrom-metohd.
if RqType = smtpOpen then begin Smtp.MailFrom; end;
From there you use the ordinary methods you would use without authentication.