Einzelnen Beitrag anzeigen

Benutzerbild von SnuffMaster23
SnuffMaster23

Registriert seit: 13. Feb 2006
Ort: Kempten
253 Beiträge
 
#5

Re: Probleme mit Indy SMTP Komponenten

  Alt 13. Apr 2006, 14:23
Nagut, das hier ist mein "Senden"-Knopf:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  Adresses: string;
begin
  with IdMessage1 do
  begin
    Clear;
    From.Address := Edit1.Text;

    Adresses := Edit2.Text;
    repeat
      Recipients.Add.Address := copy(Adresses, 0, IfThen(Pos(';', Adresses) > 0, Pos(';', Adresses), Length(Adresses)));
      Adresses := copy(Adresses, Pos(';', Adresses) + 1, Length(Adresses));
    until Pos(';', Adresses) = 0;

    Adresses := Edit3.Text;
    repeat
      BccList.Add.Address := copy(Adresses, 0, IfThen(Pos(';', Adresses) > 0, Pos(';', Adresses), Length(Adresses)));
      Adresses := copy(Adresses, Pos(';', Adresses) + 1, Length(Adresses));
    until Pos(';', Adresses) = 0;

    ContentType := 'text/' + IfThen(RadioButton1.Checked, 'plain', 'html');
    Body := Memo1.Lines;
    Sender := From;
    Subject := Edit4.Text;

    case ComboBox1.ItemIndex of
      0: Priority := mpHighest;
      1: Priority := mpHigh;
      2: Priority := mpNormal;
      3: Priority := mpLow;
      4: Priority := mpLowest;
    end;

    GenerateHeader;
  end;

  IdSMTP1.MailAgent := IfThen(Edit5.Text = '', 'mySMTP', Edit5.Text);
  IdSMTP1.Connect;
  IdSMTP1.Authenticate;
  IdSMTP1.Send(IdMessage1);
  IdSMTP1.Disconnect;
end;
Und das hier ist der Server:
Delphi-Quellcode:
procedure TForm1.IdSMTPServer1UserLogin(ASender: TIdSMTPServerContext;
  const AUsername, APassword: string; var VAuthenticated: Boolean);
begin
  if (AUsername = 'mySMTP') and (APassword = 'mySMTP') then
    VAuthenticated := true;
end;

procedure TForm1.IdSMTPServer1Connect(AContext: TIdContext);
begin
  Context := AContext;
end;

procedure TForm1.IdSMTPServer1MsgReceive(ASender: TIdSMTPServerContext;
  AMsg: TStream; var LAction: TIdDataReply);
begin
  LAction := dOk;
end;

procedure TForm1.IdSMTPServer1MailFrom(ASender: TIdSMTPServerContext;
  const AAddress: string; var VAction: TIdMailFromReply);
begin
  VAction := mAccept;
end;

procedure TForm1.IdSMTPServer1Execute(AContext: TIdContext);
begin
//
end;

procedure TForm1.IdSMTPServer1RcptTo(ASender: TIdSMTPServerContext;
  const AAddress: string; var VAction: TIdRCPToReply; var VForward: string);
begin
  VForward := 'Is ja gut...';
  VAction := rAddressOk;
end;

<EDIT>: Mit Telnet kann ich von Hand Mails an den Server schicken.
"Conspiracy is the poor man's mapping of the world" - Fredric Jameson
  Mit Zitat antworten Zitat