我的问题是:我尝试使用delphi 7发送电子邮件,但是当我尝试发送电子邮件时,出现错误。
也许只是关于TIdSMTP的一个问题,它不能与smtps服务器连接,但是我没有找到另一个用于通过delphi 7发送邮件的组件。
我的代码是这个:
unit Unit1;
interface
uses
inifiles, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdMessageClient, IdSMTP, DB, DBTables, ExtCtrls,
ComCtrls, StdCtrls, Buttons;
type
TForm1 = class(TForm)
Button1: TButton;
MailMessage: TIdMessage;
SMTPS: TIdSMTP;
AttachmentDialog: TOpenDialog;
Body: TMemo;
StatusMemo: TMemo;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
private
public
Host : string;
Port : string;
Username : string;
Password : string;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Host, Username, Password : string;
begin
Host := 'smtps.aruba.it'; //Aruba SMTPS Host
Username := '[email protected]';
Password := 'yyyyyyyy';
//setup SMTP
SMTPS.Host := Host;
SMTPS.Port := 465;//SMTPS Port of Aruba
SMTPS.Username := Username;
SMTPS.Password := Password;
//setup mail message
MailMessage.From.Address := '[email protected]';
MailMessage.Subject := 'Subject';
MailMessage.Body.Text := 'Body Text';
//send mail
try
try
SMTPS.Connect(1000);
SMTPS.Send(MailMessage);
except on E:Exception do
showmessage(E.message);
end;
finally
if SMTPS.Connected then SMTPS.Disconnect;
end;
end;
end.
错误是这样:
连接正常关闭
我遇到了完全相同的问题,所以我编写了一个应用程序,可以为我找到正确的设置。供您查看的源代码是https://github.com/Edijus/Email-Settings-Getter基本上,它遍历所有可能的TIdSMTPAuthenticationType, TIdSSLVersion, TIdUseTLS