Einzelnen Beitrag anzeigen

padavan

Registriert seit: 12. Jan 2005
271 Beiträge
 
Delphi 7 Enterprise
 
#1

E-Mail mit TIdSMTP funzt nur über Mailserver ohne Authenti

  Alt 15. Dez 2009, 14:53
Hallo DP User,

mit dieser Funktion (hier in DP gefunden und meinen Bedürfnissen angepasst), möchte bzw. muss ich E-Mails von meinem Programm heraus versenden, ohne einen lokales Outlook oder ähnliches zu nutzen:

Delphi-Quellcode:
uses
  IdSMTP, IdMessage, idPop3; // Indy 9.14

//......

procedure SendMail(aSmtpServerName: string;
                  aSmtpAuthType: integer;
                  aSmtpServerPort: integer;
                  aPopServerName: string;
                  aPopServerPort: integer;
                  aRecipient: string;
                  aFrom: string;
                  aSmtpServerUser: string;
                  aSmtpServerPassword: string;
                  aSubject: string;
                  aContent: string
                  );
var
  IdSMTP1: TIdSMTP;
  IdMessage1: TIdMessage;
  POP: TidPop3;

begin

  try

    IdSMTP1 := TIdSMTP.Create(nil);
    IdMessage1 := TIdMessage.Create(nil);
    IdMessage1.Clear;
    POP := TidPop3.create(nil);

    try

      case aSmtpAuthType of
        0: IdSMTP1.AuthenticationType := atNone; //Normal
        1: IdSMTP1.AuthenticationType := atLogin; //SMTPAuth Simple Login
        2: begin //AfterPop
             IdSMTP1.AuthenticationType := atNone;
             POP.Host := aPopServerName;
             POP.Username := aSmtpServerUser;
             POP.Password := aSmtpServerPassword;
             POP.Port := aPopServerPort;
             POP.Connect(5);
             POP.Disconnect;
           end;
        3: begin //afterPop+SMTPAuth
             IdSMTP1.AuthenticationType := atLogin;
             POP.Host := aPopServerName;
             POP.Username := aSmtpServerUser;
             POP.Password := aSmtpServerPassword;
             POP.Port := aPopServerPort;
             POP.Connect(5);
             POP.Disconnect;
           end;
      end;

      with IdMessage1 do
      begin
         Body.Text := aContent; // Body.Assign(stringlist);
         From.Text := aFrom; //Sender
         Recipients.EMailAddresses := aRecipient; //Empfänger
         Subject := aSubject; //Betreff?
      end;

      IdSMTP1.Username := aSmtpServerUser; //Welcher Benutzer?
      IdSMTP1.Password := aSmtpServerPassword; //Welches Passwort??

      // Generelles Setup
      IdSMTP1.Host := aSmtpServerName; //Provider
      IdSMTP1.Port := aSmtpServerPort; //Port

      IdSMTP1.Connect;
      try
        IdSMTP1.Send(IdMessage1);
      finally
        IdSMTP1.Disconnect;
      end;

    finally
      freeandnil(IdSMTP1);
      freeandnil(IdMessage1);
    end;

  except
    showmessage('unknown error');
  end;

end;
Leider funktioniert das nur, wenn ich einen hier in unserer Firma verfügbaren SMPT-Server ohne jegliche Authentifizierung nutze.

Wenn ich allerdings einen Provider (z.B. Yahoo oder GMX) nutzen möchte, dann bekomme ich immer die Fehlermeldung:
Zitat:
EIDProtocolReplyError with message '5.1.7 Complete adress with domain....' (siehe Anhang)
Nebenbei:
1. Port 25 und 110 sind für mich offen.
2. Ich habe die vom Provider erforderlichen Einstellungen gemacht. Ob dies grundsätzlich funktioniert, habe ich dann mit Outlook Express getestet.

Ich frage mich allerdings während ich das tippe, ob wohl die Indy Komponente alle möglichen Typen unterstützt? ('aSmtpAuthType')


Kann mir evtl. jemand sagen, woran das liegt?

Danke
Padavan
Miniaturansicht angehängter Grafiken
indy_exception_855.jpg  
  Mit Zitat antworten Zitat