根据亚马逊发布的说明:
Connect to your IMAP Client Application
You can connect any IMAP-compatible client software to Amazon WorkMail by providing the following information:
Type of account IMAP
Protocol IMAPS
Port 993
Secure connection Required;SSL
Incoming username Email address associated with your Amazon WorkMail account
Incoming password Your password
Incoming server The endpoint matching the region where your mailbox is located: ⢠us-east-1 imap.mail.us-east-1.awsapps.com
我唯一编码的操作是
IMAPClient.Connect();
TIdIMAP4.GetResponse: string;
德尔福10.2
Indy 10.6.2.5366
var
IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;
with IMAPClient do
begin
Name := 'IMAPClient';
OnStatus := IMAPClientStatus;
IOHandler := IdSSLIOHandlerSocketOpenSSL1;
OnDisconnected := IMAPClientDisconnected;
OnConnected := IMAPClientConnected;
Password := 'EmailTest1236';
Port := 993;
Username := 'emailTest.1236@foo.bar.com';
Host := 'imap.mail.us-east-1.awsapps.com';
UseTLS := utUseRequireTLS;
SASLMechanisms := <>;
MilliSecsToWaitToClearBuffer := 10;
end;
IdSSLIOHandlerSocketOpenSSL1 := TIdSSLIOHandlerSocketOpenSSL.Create(Self);
with IdSSLIOHandlerSocketOpenSSL1 do
begin
Name := 'IdSSLIOHandlerSocketOpenSSL1';
OnStatus := IdSSLIOHandlerSocketOpenSSL1Status;
Destination := 'imap.mail.us-east-1.awsapps.com:993';
Host := 'imap.mail.us-east-1.awsapps.com';
MaxLineAction := maException;
Port := 993;
BoundPort := 993;
DefaultPort := 0;
end;
unit uMain;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, IdIOHandler, IdIOHandlerSocket,
IdIOHandlerStack, IdSSL, IdSSLOpenSSL, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, IdMessageClient,
IdIMAP4, Vcl.StdCtrls;
type
TForm4 = class(TForm)
IMAPClient: TIdIMAP4;
IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure IMAPClientStatus(ASender: TObject; const AStatus: TIdStatus;
const AStatusText: string);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
{$R *.dfm}
procedure TForm4.Button1Click(Sender: TObject);
begin
IMAPClient.Connect();
end;
procedure TForm4.IMAPClientStatus(ASender: TObject; const AStatus: TIdStatus;
const AStatusText: string);
begin
memo1.Lines.Add(AStatusText);
end;
end.