following code is what i modified(to work with 10.5.8) form the sample in order to send email independently using the smtp client described in Indy Mail server
following is from INDY smtpserver sample
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;
what do i have to add to this project to work as email sending server.
I haven't done many changes to the original sample(only for compatibility) as i can't understand most of the concepts behind how email is sent and received. please explain me how to make this code to send email to the destination(eg: [email protected]) given in this question Indy Mail server (smtpclient),