Jump to content
Cartman.

send emails using Telnet

Recommended Posts

Posted

20121109085356.jpg

var
Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
begin
Edit2.Text:='email';
Edit3.Text:='tara';

Memo1.Clear;
Application.ProcessMessages;

if IdTelnet1.Connected then
IdTelnet1.Disconnect;

//-----------------------------------
IdTelnet1.Host:='mail.rambler.ru';
IdTelnet1.Port:=587;
//-----------------------------------
try
IdTelnet1.Connect;
IdTelnet1.WriteLn('HELO '+edit1.Text);
IdTelnet1.WriteLn('AUTH LOGIN');
Sleep(200);
IdTelnet1.WriteLn(IdEncoderMIME1.EncodeString(Edit2.Text)); //username
Sleep(200);
IdTelnet1.WriteLn(IdEncoderMIME1.EncodeString(Edit3.Text)); //password
Sleep(100);
IdTelnet1.WriteLn('MAIL FROM:'+edit1.Text);
Sleep(50);
IdTelnet1.WriteLn('RCPT TO:'+edit1.Text);
Sleep(50);
IdTelnet1.WriteLn('DATA');
Sleep(50);
IdTelnet1.WriteLn('Subject:'+edit4.Text);
Sleep(50);
// IdTelnet1.WriteLn('DATA');
// Sleep(100);
IdTelnet1.WriteLn('');
Sleep(50);
IdTelnet1.Writeln(mmo1.Text);
Sleep(50);
IdTelnet1.WriteLn('.');
Sleep(50);
IdTelnet1.Writeln('quit');
except
IdTelnet1.Disconnect;
end;

end;

procedure TForm2.IdTelnet1Status(ASender: TObject;
const AStatus: TIdStatus; const AStatusText: String);
begin
stat1.Panels[0].Text:=AStatusText;
end;

procedure TForm2.IdTelnet1DataAvailable(Sender: TIdTelnet;
const Buffer: String);
begin
Application.ProcessMessages;
if Length(Trim(Buffer)) >0 then
Memo1.Lines.Add(Buffer)
end;

procedure TForm2.FormDestroy(Sender: TObject);
begin
try
if IdTelnet1.Connected then
IdTelnet1.Disconnect;
finally
Application.Terminate;
end;
end;

 private
{ Private declarations } {shift+ctrl+c}
procedure sendmail(UserNme, password, host,from,_to,Subject,body: string; port: integer);

public
{ Public declarations }
end;

var
Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.IdTelnet1Status(ASender: TObject;
const AStatus: TIdStatus; const AStatusText: String);
begin
stat1.Panels[0].Text:=AStatusText;
end;

procedure TForm2.IdTelnet1DataAvailable(Sender: TIdTelnet;
const Buffer: String);
begin
Application.ProcessMessages;
if Length(Trim(Buffer)) >0 then
Memo1.Lines.Add(Buffer)
end;

procedure TForm2.FormDestroy(Sender: TObject);
begin
try
if IdTelnet1.Connected then
IdTelnet1.Disconnect;
finally
Application.Terminate;
end;
end;

procedure TForm2.sendmail(UserNme, password, host,from,_to,Subject,body: string; port: integer);
begin
Edit2.Text:=UserNme;
Edit3.Text:=password;

Memo1.Clear;
Application.ProcessMessages;
if IdTelnet1.Connected then
IdTelnet1.Disconnect;
IdTelnet1.Host:=host;
IdTelnet1.Port:=port;
try
IdTelnet1.Connect;
IdTelnet1.WriteLn('HELO '+edit1.Text);
IdTelnet1.WriteLn('AUTH LOGIN');
Sleep(500);
IdTelnet1.WriteLn(IdEncoderMIME1.EncodeString(UserNme)); //username
IdTelnet1.WriteLn(IdEncoderMIME1.EncodeString(password)); //password
Sleep(500);
IdTelnet1.WriteLn('MAIL FROM:'+from);
IdTelnet1.WriteLn('RCPT TO:'+_to);
IdTelnet1.WriteLn('DATA');
IdTelnet1.WriteLn('Subject:'+Subject);
IdTelnet1.WriteLn('');
IdTelnet1.Writeln(body);
IdTelnet1.WriteLn('.');
IdTelnet1.Writeln('quit');
except
IdTelnet1.Disconnect;
end;
end;

procedure TForm2.Button1Click(Sender: TObject);
begin
sendmail('email', 'tara', 'mail.rambler.ru',Edit1.Text,Edit1.Text,Edit4.Text,Mmo1.Text ,587);
end;

end.

And update

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...