我有一个工作正常的 IMAP4 客户端连接到 RackSpace,但客户端正在转移到亚马逊工作邮件。
根据亚马逊发布的说明:
连接到您的 IMAP 客户端应用程序 您可以通过提供以下信息将任何与 IMAP 兼容的客户端软件连接到 Amazon WorkMail: 帐户类型 IMAP 协议 IMAPS 端口 993 需要安全连接;SSL 传入用户名 与您的 Amazon WorkMail 账户关联的电子邮件地址 输入密码 您的密码 传入服务器 与您的邮箱所在区域匹配的端点: • us-east-1 imap.mail.us-east-1.awsapps.com
我编写的唯一操作是IMAPClient.Connect();
它返回“已连接”状态,但此后程序挂起。我已经通过组件源跟踪线程,发现它在函数中等待来自亚马逊的返回TIdIMAP4.GetResponse: string;
它只是挂在那里很长时间,然后抛出“连接正常关闭”异常。
德尔福 10.2
印地 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.