следующий код - это то, что я изменил (для работы с 10.5.8) из образца, чтобы отправлять электронную почту независимо с помощью клиента smtp, описанного в Почтовый сервер Indy
следующее из примера INDY smtpserver
procedure TForm1.btnServerOnClick(Sender: TObject);
begin
IdSMTPServer1.active := true;
end;
procedure TForm1.btnServerOffClick(Sender: TObject);
begin
IdSMTPServer1.active := false;
end;
procedure TForm1.IdSMTPServer1MailFrom(ASender: TIdSMTPServerContext;
const AAddress: string; AParams: TStrings; var VAction: TIdMailFromReply);
begin
// Here we are testing the MAIL FROM line sent to the server.
// MAIL FROM address comes in via AAddress. VAction sets the return action to the server.
// The following actions can be returned to the server:
{ mAccept, mReject }
// For now, we will just always allow the mail from address.
VAction := mAccept;
end;
procedure TForm1.IdSMTPServer1MsgReceive(ASender: TIdSMTPServerContext;
AMsg: TStream; var LAction: TIdDataReply);
var
LMsg : TIdMessage;
LStream : TFileStream;
begin
// When a message is received by the server, this event fires.
// The message data is made available in the AMsg : TStream.
// In this example, we will save it to a temporary file, and the load it using
// IdMessage and parse some header elements.
LStream := TFileStream.Create(ExtractFilePath(Application.exename) + 'test.eml', fmCreate);
Try
LStream.CopyFrom(AMsg, 0);
Finally
FreeAndNil(LStream);
End;
LMsg := TIdMessage.Create;
Try
LMsg.LoadFromFile(ExtractFilePath(Application.exename) + 'test.eml', False);
ToLabel.Caption := LMsg.Recipients.EMailAddresses;
FromLabel.Caption := LMsg.From.Text;
SubjectLabel.Caption := LMsg.Subject;
Memo1.Lines := LMsg.Body;
Finally
FreeAndNil(LMsg);
End;
end;
procedure TForm1.IdSMTPServer1UserLogin(ASender: TIdSMTPServerContext;
const AUsername, APassword: String; var VAuthenticated: Boolean);
begin
// This event is fired if a user attempts to login to the server
// Normally used to grant relay access to specific users etc.
VAuthenticated := True;
end;
procedure TForm1.IdSMTPServer1RcptTo(ASender: TIdSMTPServerContext;
const AAddress: string; AParams: TStrings; var VAction: TIdRCPToReply;
var VForward: string);
begin
VAction := rAddressOk;
end;
procedure TForm1.IdSMTPServer1Received(ASender: TIdSMTPServerContext;
var AReceived: string);
begin
//
end;
что мне нужно добавить в этот проект для работы в качестве сервера отправки электронной почты.
Я не внес много изменений в исходный образец (только для совместимости), так как я не могу понять большинство концепций отправки и получения электронной почты. пожалуйста, объясните мне, как заставить этот код отправлять электронную почту по адресу назначения (например, кто-то@gmail.com), указанный в этом вопросе Почтовый сервер Indy (smtpclient),