AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Delphi Indy: Googlemail smtp Einstellungen
Thema durchsuchen
Ansicht
Themen-Optionen

Indy: Googlemail smtp Einstellungen

Ein Thema von MrSpock · begonnen am 11. Okt 2015 · letzter Beitrag vom 15. Okt 2015
Antwort Antwort
Seite 1 von 2  1 2      
Gerd01

Registriert seit: 18. Mär 2005
Ort: NRW
117 Beiträge
 
Delphi XE2 Professional
 
#1

AW: Indy: Googlemail smtp Einstellungen

  Alt 11. Okt 2015, 16:45
Google Mail geht nur verschlüsselt auf Port 587
Siehe auch hier:
https://www.rebex.net/kb/tls-ssl-explicit-implicit/
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#2

AW: Indy: Googlemail smtp Einstellungen

  Alt 11. Okt 2015, 18:00
Google Mail geht nur verschlüsselt auf Port 587
Siehe auch hier:
https://www.rebex.net/kb/tls-ssl-explicit-implicit/
Da steht:
Auf Port 25/587 kann - muss aber nicht - verschlüsselt gesendet werden.
Auf Port 465 muss verschlüsselt gesendet werden.

Irgendwie passt dazu jetzt deine Aussage nicht ...
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat
Aviator

Registriert seit: 3. Jun 2010
1.611 Beiträge
 
Delphi 10.3 Rio
 
#3

AW: Indy: Googlemail smtp Einstellungen

  Alt 11. Okt 2015, 19:13
Um ein Google Mail Konto von außen anzusprechen, müssen in den Einstellungen deines Kontos diverse Dinge angepasst werden. Du musst im Prinzip auch noch den Zugriff von außen zulassen. Der folgende Link müsste bei dir auch funktionieren, da der allgemein gehalten ist: https://mail.google.com/mail/u/0/?ta...ings/fwdandpop
  Mit Zitat antworten Zitat
Benutzerbild von MrSpock
MrSpock
(Co-Admin)

Registriert seit: 7. Jun 2002
Ort: Owingen
5.865 Beiträge
 
Delphi 2010 Professional
 
#4

AW: Indy: Googlemail smtp Einstellungen

  Alt 11. Okt 2015, 19:44
Um ein Google Mail Konto von außen anzusprechen, müssen in den Einstellungen deines Kontos diverse Dinge angepasst werden. Du musst im Prinzip auch noch den Zugriff von außen zulassen. Der folgende Link müsste bei dir auch funktionieren, da der allgemein gehalten ist: https://mail.google.com/mail/u/0/?ta...ings/fwdandpop
Habe imap freigeschaltet und kann auch seit Jahren über Thunderbird zugreifen.

Google Mail geht nur verschlüsselt auf Port 587
Siehe auch hier:
https://www.rebex.net/kb/tls-ssl-explicit-implicit/
Da steht:
Auf Port 25/587 kann - muss aber nicht - verschlüsselt gesendet werden.
Auf Port 465 muss verschlüsselt gesendet werden.

Irgendwie passt dazu jetzt deine Aussage nicht ...
Wenn ich mit 25 oder 587 connecte und useNoTLS eingestellt habe, kommt die Meldung, das das TSL command geschickt werden muss. Habe implicit, explicit und requireTLS versucht, aber ohne Erfolg.
Albert
Live long and prosper


MrSpock

Geändert von MrSpock (11. Okt 2015 um 21:34 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von MrSpock
MrSpock
(Co-Admin)

Registriert seit: 7. Jun 2002
Ort: Owingen
5.865 Beiträge
 
Delphi 2010 Professional
 
#5

AW: Indy: Googlemail smtp Einstellungen

  Alt 12. Okt 2015, 06:52
Habe mir mal den Status ausgeben lassen.

Es ist fast immer gleich:

Zitat:
smtp: Connected.
ssl : SSL status: "before/connect initialization"
ssl : SSL status: "before/connect initialization"
ssl : SSL status: "SSLv3 write client hello A"
ssl : SSL status: "SSLv3 read server hello A"
... dann ist Schluss: Gracefully closed
Albert
Live long and prosper


MrSpock
  Mit Zitat antworten Zitat
Gerd01

Registriert seit: 18. Mär 2005
Ort: NRW
117 Beiträge
 
Delphi XE2 Professional
 
#6

AW: Indy: Googlemail smtp Einstellungen

  Alt 12. Okt 2015, 07:57
Google Mail geht nur verschlüsselt auf Port 587
Siehe auch hier:
https://www.rebex.net/kb/tls-ssl-explicit-implicit/
Upps Rufus hat Recht. Der Port muss 465 sein und die Verbindung verschlüsselt.

AuthType := satDefault;
IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
UseTLS := utUseImplicitTLS
  Mit Zitat antworten Zitat
Benutzerbild von MrSpock
MrSpock
(Co-Admin)

Registriert seit: 7. Jun 2002
Ort: Owingen
5.865 Beiträge
 
Delphi 2010 Professional
 
#7

AW: Indy: Googlemail smtp Einstellungen

  Alt 12. Okt 2015, 08:03
Habe genau diese Einstellungen probiert. Außerdem noch alle Kombinationen von SSLv1, SSLv2, SSLv23, SSLv3 mit unaasigned, both, server, client. Dann auch noch die Ports 465 und 587. Ich komme nicht einmal zur "Anmeldung", also der Prüfung des usernames und passwords.

Hat irgendjemand es mit Delphi2010 und Indy 10.5.5 geschafft, eine Email über smtp.googlemail.com zu verschicken? Falls ja, wie?

Könnte es an der Authentisierungsmethode liegen?
Albert
Live long and prosper


MrSpock

Geändert von MrSpock (12. Okt 2015 um 08:10 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von Back2Code
Back2Code

Registriert seit: 6. Feb 2012
Ort: Deutschland
272 Beiträge
 
Delphi XE7 Professional
 
#8

AW: Indy: Googlemail smtp Einstellungen

  Alt 12. Okt 2015, 14:30
Habe genau diese Einstellungen probiert. Außerdem noch alle Kombinationen von SSLv1, SSLv2, SSLv23, SSLv3 mit unaasigned, both, server, client. Dann auch noch die Ports 465 und 587. Ich komme nicht einmal zur "Anmeldung", also der Prüfung des usernames und passwords.

Hat irgendjemand es mit Delphi2010 und Indy 10.5.5 geschafft, eine Email über smtp.googlemail.com zu verschicken? Falls ja, wie?

Könnte es an der Authentisierungsmethode liegen?
yoyo hatte das Gleiche Problem wie du.

Lösung:

https://support.google.com/accounts/.../6010255?hl=de

https://www.google.com/settings/security/lesssecureapps

Zugriff für weniger sichere Apps -> AKTIVIEREN

Fertig.


Auszug aus meiner Ini

[SMTP]
Host=smtp.gmail.com
Port=25
User=username@gmail.com
Password=deingmailpw

ssl.Host:=smtpHost;
ssl.Port:=smtpPort;
ssl.SSLOptions.Method:=sslvTLSv1;
00111100001100110010000001000100011001010110110001 1100000110100001101001

Geändert von Back2Code (12. Okt 2015 um 14:35 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von MrSpock
MrSpock
(Co-Admin)

Registriert seit: 7. Jun 2002
Ort: Owingen
5.865 Beiträge
 
Delphi 2010 Professional
 
#9

AW: Indy: Googlemail smtp Einstellungen

  Alt 12. Okt 2015, 15:54
Hab ich bereits aktiviert, weil es einmal nicht mehr mit Thunderbird funktioni hatte.
Albert
Live long and prosper


MrSpock
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#10

AW: Indy: Googlemail smtp Einstellungen

  Alt 12. Okt 2015, 17:24
Da ich ja - bekanntermassen faul bin - sieht so ein Mailversand bei mir so aus:
Delphi-Quellcode:
unit Forms.MainForm;

interface

uses
  SendMail,

  System.Generics.Collections,
  Winapi.Windows, Winapi.Messages,
  System.SysUtils, System.Variants, System.Classes,
  Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TMainForm = class( TForm )
    Button1: TButton;
    procedure Button1Click( Sender: TObject );
  private
    FMailer : ISendMail;
    FConfigurations: TObjectList<TSendMailConfiguration>;
  public
    procedure AfterConstruction; override;
    procedure BeforeDestruction; override;
  end;

var
  MainForm: TMainForm;

implementation

{$R *.dfm}

uses
  SendMail.Impl.IndySendMail;

procedure TMainForm.AfterConstruction;
begin
  inherited;
  FMailer := TIndySendMail.Create;
  FConfigurations := TObjectList<TSendMailConfiguration>.Create( True );
  FConfigurations.Add( TSendMailConfiguration.Create );

  FConfigurations[ 0 ].name := 'gmail';
  FConfigurations[ 0 ].Host := 'smtp.gmail.com';
  FConfigurations[ 0 ].UseSSL := True;
  FConfigurations[ 0 ].UseStartTLS := True;
  FConfigurations[ 0 ].AuthType := TSmtpAuthType.Password;
  FConfigurations[ 0 ].Username := 'username';
  FConfigurations[ 0 ].Password := 'password';
end;

procedure TMainForm.BeforeDestruction;
begin
  FConfigurations.Free;
  inherited;
end;

procedure TMainForm.Button1Click( Sender: TObject );
var
  LMail: TMailContainer;
begin
  LMail := TMailContainer.Create;
  try
    LMail.Receiver := 'receiver@example.de';
    LMail.Subject := 'Test Mail';
    LMail.Body := 'moin moin';

    LMail.Sender := 'sender@gmail.com';
    FMailer.Send( FConfigurations[ 0 ], LMail );
  finally
    LMail.Free;
  end;
end;

end.
Und den Rest kann man immer ganz hübsch wieder verwenden und/oder bei Bedarf erweitern:
  • Basis
    Delphi-Quellcode:
    unit SendMail;

    interface

    {$SCOPEDENUMS ON}

    type
      TSmtpAuthType = ( None, Extern, KerberosV5, NTLM, MD5CR, SHA1CR, Password );
      TSmtpAuthTypes = set of TSmtpAuthType;

      TSendMailConfiguration = class
      private const
        DefaultPort = 25;
        DefaultImplicitTLSPort = 465;
        DefaultExplicitTLSPort = 587;
      private
        FName : string;
        FHost : string;
        FPort : Word;
        FUseSSL : Boolean;
        FAuthType : TSmtpAuthType;
        FUsername : string;
        FPassword : string;
        FTLSCertifcateId: string;
        FDomain : string;
        FUseStartTLS : Boolean;
        procedure SetUseSSL( const Value: Boolean );
        procedure SetDefaultPort;
        procedure SetUseStartTLS( const Value: Boolean );
      public
        constructor Create;
        property name: string read FName write FName;
        property TLSCertifcateId: string read FTLSCertifcateId write FTLSCertifcateId;
        property Host: string read FHost write FHost;
        property Port: Word read FPort write FPort;
        property UseSSL: Boolean read FUseSSL write SetUseSSL;
        property UseStartTLS: Boolean read FUseStartTLS write SetUseStartTLS;
        property AuthType: TSmtpAuthType read FAuthType write FAuthType;
        property Domain: string read FDomain write FDomain;
        property Username: string read FUsername write FUsername;
        property Password: string read FPassword write FPassword;
      end;

      TMailContainer = class
      private
        FSender : string;
        FReceiver: string;
        FSubject : string;
        FBody : string;
      public
        property Sender : string read FSender write FSender;
        property Receiver: string read FReceiver write FReceiver;
        property Subject : string read FSubject write FSubject;
        property Body : string read FBody write FBody;
      end;

    type
      ISendMail = interface
        [ '{9F6A6EC3-86B5-4E9C-A7B1-42FE1DC35B24}' ]
        procedure Send( Configuration: TSendMailConfiguration; Mail: TMailContainer );

        function GetSupportedAuthTypes: TSmtpAuthTypes;
        property SupportedAuthTypes: TSmtpAuthTypes read GetSupportedAuthTypes;
      end;

    implementation

    { TSendMailConfiguration }

    constructor TSendMailConfiguration.Create;
    begin
      inherited Create;
      SetDefaultPort;
    end;

    procedure TSendMailConfiguration.SetDefaultPort;
    begin
      if FUseSSL
      then
        begin
          if FUseStartTLS
          then
            FPort := DefaultExplicitTLSPort
          else
            FPort := DefaultImplicitTLSPort
        end
      else
        FPort := DefaultPort;
    end;

    procedure TSendMailConfiguration.SetUseSSL( const Value: Boolean );
    begin
      if FUseSSL <> Value
      then
        begin
          FUseSSL := Value;
          SetDefaultPort;
        end;
    end;

    procedure TSendMailConfiguration.SetUseStartTLS( const Value: Boolean );
    begin
      if FUseStartTLS <> Value
      then
        begin
          FUseStartTLS := Value;
          SetDefaultPort;
        end;
    end;

    end.
  • Indy-Implementierung
    Delphi-Quellcode:
    unit SendMail.Impl.IndySendMail;

    interface

    uses
      SendMail,

      System.Classes,
      System.Generics.Collections,
      System.SysUtils,

      IdBaseComponent,
      IdComponent,

      IdIOHandler,
      IdIOHandlerSocket,
      IdIOHandlerStack,

      IdSSL,
      IdSSLOpenSSL,
      IdExplicitTLSClientServerBase,

      IdUserPassProvider,

      IdSASL,
      IdSASL_CRAMBase,
      IdSASL_CRAM_MD5,
      IdSASL_CRAM_SHA1,
      IdSASLAnonymous,
      IdSASLDigest,
      IdSASLExternal,
      IdSASLLogin,
      IdSASLOTP,
      IdSASLPlain,
      IdSASLSKey,
      IdSASLUserPass,

      IdSMTP,
      IdSMTPBase,

      IdTCPConnection,
      IdTCPClient,
      IdMessageClient,
      IdMessage;

    type
      TIndySendMail = class( TInterfacedObject, ISendMail )
      private
        FSMTP : TIdSMTP;
        FSASLAnonymous : TIdSASLAnonymous;
        FSASLCRAMMD5 : TIdSASLCRAMMD5;
        FSASLCRAMSHA1 : TIdSASLCRAMSHA1;
        FSASLDigest : TIdSASLDigest;
        FSASLExternal : TIdSASLExternal;
        FSASLLogin : TIdSASLLogin;
        FSASLOTP : TIdSASLOTP;
        FSASLPlain : TIdSASLPlain;
        FSASLSKey : TIdSASLSKey;
        FUserPassProvider : TIdUserPassProvider;
        FSSLIOHandlerSocketOpenSSL: TIdSSLIOHandlerSocketOpenSSL;
        FMessage : TIdMessage;
      private
        FSync: TObject;
        procedure Configure( Configuration: TSendMailConfiguration );
      private { ISendMail }
        function GetSupportedAuthTypes: TSmtpAuthTypes;
        procedure Send( Configuration: TSendMailConfiguration; Mail: TMailContainer );
      public
        constructor Create;
        destructor Destroy; override;
      end;

    implementation

    uses
      netAlike.Utils;

    { TIndySendMail }

    procedure TIndySendMail.Configure( Configuration: TSendMailConfiguration );
    begin
      if not( Configuration.AuthType in GetSupportedAuthTypes )
      then
        raise ENotSupportedException.Create( 'AuthType not supported' );

      FSMTP.SASLMechanisms.Clear;

      FSMTP.AuthType := satSASL;
      FSMTP.UseEhlo := True;

      FUserPassProvider.Username := Configuration.Username;
      FUserPassProvider.Password := Configuration.Password;

      FSASLExternal.AuthorizationIdentity := Configuration.TLSCertifcateId;

      case Configuration.AuthType of
        TSmtpAuthType.None:
          FSMTP.SASLMechanisms.Add.SASL := FSASLAnonymous;
        TSmtpAuthType.Extern:
          FSMTP.SASLMechanisms.Add.SASL := FSASLExternal;
        TSmtpAuthType.MD5CR:
          FSMTP.SASLMechanisms.Add.SASL := FSASLCRAMMD5;
        TSmtpAuthType.SHA1CR:
          FSMTP.SASLMechanisms.Add.SASL := FSASLCRAMSHA1;
        TSmtpAuthType.Password:
          FSMTP.SASLMechanisms.Add.SASL := FSASLLogin;
      else
        if Configuration.AuthType in GetSupportedAuthTypes
        then
          raise ENotImplemented.Create( 'AuthType not implemented' );
      end;

      if Configuration.UseSSL
      then
        begin
          FSMTP.IOHandler := FSSLIOHandlerSocketOpenSSL;
          if Configuration.UseStartTLS
          then
            begin
              FSMTP.UseTLS := utUseExplicitTLS;
            end
          else
            begin
              FSMTP.UseTLS := utUseImplicitTLS;
            end;
        end
      else
        begin
          FSMTP.IOHandler := nil;
          FSMTP.UseTLS := utNoTLSSupport;
        end;

      FSMTP.Host := Configuration.Host;
      FSMTP.Port := Configuration.Port;
    end;

    constructor TIndySendMail.Create;
    begin
      FSync := TObject.Create;
      inherited;

      FSMTP := TIdSMTP.Create( nil );
      FSSLIOHandlerSocketOpenSSL := TIdSSLIOHandlerSocketOpenSSL.Create( FSMTP );
      FUserPassProvider := TIdUserPassProvider.Create( FSMTP );
      FSASLExternal := TIdSASLExternal.Create( FSMTP );
      FSASLCRAMMD5 := TIdSASLCRAMMD5.Create( FSMTP );
      FSASLCRAMSHA1 := TIdSASLCRAMSHA1.Create( FSMTP );
      FSASLDigest := TIdSASLDigest.Create( FSMTP );
      FSASLOTP := TIdSASLOTP.Create( FSMTP );
      FSASLSKey := TIdSASLSKey.Create( FSMTP );
      FSASLLogin := TIdSASLLogin.Create( FSMTP );
      FSASLPlain := TIdSASLPlain.Create( FSMTP );
      FSASLAnonymous := TIdSASLAnonymous.Create( FSMTP );
      FMessage := TIdMessage.Create( FSMTP );

      TEnumeratorUtil.ForEach<TIdSASLUserPass>( FSMTP,
        procedure( const c: TIdSASLUserPass )
        begin
          c.UserPassProvider := FUserPassProvider;
        end,
        function( const c: TIdSASLUserPass ): Boolean
        begin
          Result := ( c.UserPassProvider = nil );
        end );
    end;

    destructor TIndySendMail.Destroy;
    begin
      FreeAndNil( FSMTP );
      inherited;
      FreeAndNil( FSync );
    end;

    function TIndySendMail.GetSupportedAuthTypes: TSmtpAuthTypes;
    begin
      Result := [
      {} TSmtpAuthType.None,
      {} TSmtpAuthType.Extern,
      {} TSmtpAuthType.MD5CR,
      {} TSmtpAuthType.SHA1CR,
      {} TSmtpAuthType.Password ];
    end;

    procedure TIndySendMail.Send( Configuration: TSendMailConfiguration; Mail: TMailContainer );
    begin
      TMonitor.Enter( FSync );
      try

        Configure( Configuration );

        FMessage.Clear;

        FMessage.From.Text := Mail.Sender;
        FMessage.Recipients.Add.Text := Mail.Receiver;
        FMessage.Subject := Mail.Subject;
        FMessage.Body.Text := Mail.Body;

        FSMTP.Connect;
        try
          FSMTP.Send( FMessage );
        finally
          FSMTP.Disconnect( True );
        end;

      finally
        TMonitor.Exit( FSync );
      end;
    end;

    end.
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)

Geändert von Sir Rufo (13. Okt 2015 um 09:47 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:15 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz