Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. [Gelöst] Email-Empfang Iobroker

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    [Gelöst] Email-Empfang Iobroker

    This topic has been deleted. Only users with topic management privileges can see it.
    • Gargano
      Gargano last edited by

      Funktioniert das Script auch für pop3, oder nur für imap ?
      Ich habe bei 1und1 ein pop3 Postfach, was muß ich da ändern ?
      Viele Grüße

      liv-in-sky 2 Replies Last reply Reply Quote 0
      • liv-in-sky
        liv-in-sky last edited by liv-in-sky

        nur zur info: man kann auch in der mailbox einen unterordner einrichten (ging bei mir beim provider im mailsetting) - wegen: das mail als read markieren - da will man nicht die ganze mailbox als read setzen lassen

        dann kann in nodered dieser unterordner angegeben werden und man braucht keine eigene mailadresse

        Image 1.png

        Image 3.png

        natürlich muss im mailprogramm eine umleitung (regel) für dieses mail eingerichtet werden !

        1 Reply Last reply Reply Quote 0
        • liv-in-sky
          liv-in-sky @Gargano last edited by

          @Gargano 1und 1 bietet doch imap an

          1 Reply Last reply Reply Quote 0
          • liv-in-sky
            liv-in-sky @Gargano last edited by

            @Gargano

            nutz ich z.b. hier:

            
            var maillistenerSetting = {
                  username: "xxxxxxy@online.de",    // hier Email Adresse eintragen
                  password: "yyyyy",	      // hier Passwort eintragen	
                  host: "imap.1und1.de",
                  port: 993, // imap port
                  tl
            
            Gargano 1 Reply Last reply Reply Quote 0
            • Gargano
              Gargano @liv-in-sky last edited by

              @liv-in-sky Ok , danke. Empfangen funktioniert.
              Gibt es eine Doku über die Struktur vom Objekt mail ?
              Bei mir wird für mail.text 'undefined' ausgegeben.

              Viele Grüße

              liv-in-sky 1 Reply Last reply Reply Quote 0
              • liv-in-sky
                liv-in-sky @Gargano last edited by

                @Gargano kannst du im debug-node in nodered einstellen und ansehen

                Image 4.png

                Gargano 1 Reply Last reply Reply Quote 0
                • Gargano
                  Gargano @liv-in-sky last edited by

                  @liv-in-sky Ich hab kein Nodered sondern es mit dem Javascript gemacht, daß weiter oben steht.

                  liv-in-sky 1 Reply Last reply Reply Quote 0
                  • liv-in-sky
                    liv-in-sky @Gargano last edited by

                    @Gargano dann sollte es stimmen

                    hier ein beispiel von mir

                    Image 5.png

                    Gargano 1 Reply Last reply Reply Quote 0
                    • Gargano
                      Gargano @liv-in-sky last edited by

                      @liv-in-sky Ich habe nur die einfache Version genommen, hier der Code.

                      
                      
                      // Quelle Original: https://github.com/chirag04/mail-listener2
                      // Quelle Forum: https://forum.iobroker.net/topic/18501/emails-empfangen
                       
                      const EmailText = "javascript.0.Email.EmailText";
                      const EmailEingang = "javascript.0.Email.Email_Eingang";
                      
                      createState(EmailEingang, {
                          type: 'string',
                          min: 0,
                          def: 0,
                          role: 'value'
                      });
                      createState(EmailText, {
                          type: 'string',
                          min: 0,
                          def: 0,
                          role: 'value'
                      });
                      
                      
                          var MailListener = require("mail-listener2");
                          var mailListener = new MailListener({
                            username: "xxxxx",    // HIER Email Adresse eintragen
                            password: "yyyy",	      // HIER Passwort eintragen	
                            host: "imap.ionos.de",
                            port: 993, // imap port
                            tls: true,
                            connTimeout: 10000, // Default by node-imap
                            authTimeout: 5000, // Default by node-imap,
                            debug: null, // Or your custom function with only one incoming argument. Default: null
                            tlsOptions: { rejectUnauthorized: false },
                            mailbox: "INBOX", // HIER Postfach eingeben z.B. INBOX 
                            searchFilter: ["UNSEEN"], // the search filter being used after an IDLE notification has been retrieved
                            markSeen: true, // all fetched email willbe marked as seen and not fetched next time
                            fetchUnreadOnStart: true, // use it only if you want to get all unread email on lib start. Default is `false`,
                            mailParserOptions: {streamAttachments: false}, // options to be passed to mailParser lib.
                            attachments: false, // download attachments as they are encountered to the project directory
                            attachmentOptions: { directory: "attachments/" } // specify a download directory for attachments
                          });
                      
                          mailListener.start();
                          mailListener.on("server:connected", function(){console.log("------- imapConnected");});
                          mailListener.on("server:disconnected", function(){console.log("------- imapDisconnected");});
                          mailListener.on("error", function(err){console.log("MailError "+err);});
                          mailListener.on("mail", function(mail, seqno, attributes){
                          
                              log("Mail from: "+mail.from[0].address);
                              log("Name: "+mail.from[0].name);
                              log("Subject: "+mail.subject);
                              log("Text: "+mail.text);
                      
                      //     setState(EmailEingang,mail.from[0].address);  	//setze Datenpunkt mit Email-Absender (als Trigger nutzbar)
                      //     setState(EmailText,mail.text);			//setze Datenpunkt mit kompletten Email-Inhalt
                          });
                      
                          // mailListener.on("attachment", function(attachment){console.log(attachment.path);}); //wenn Anhänge verarbeitet werden sollen einkommentieren
                      
                      
                      

                      mail.from[0].address,mail.from[0].name,mail.subject funktioniert. nur mail.text nicht

                      liv-in-sky 1 Reply Last reply Reply Quote 0
                      • liv-in-sky
                        liv-in-sky @Gargano last edited by liv-in-sky

                        @Gargano

                        das funktioniert bei mir. mail-listener4 aber sollte auch mit mail-listener2 funktionieren:

                        
                        
                        // Quelle Original: https://github.com/chirag04/mail-listener2
                        // Quelle Forum: https://forum.iobroker.net/topic/18501/emails-empfangen
                         
                        const EmailText = "javascript.0.Email.EmailText";
                        const EmailEingang = "javascript.0.Email.Email_Eingang";
                        
                        createState(EmailEingang, {
                            type: 'string',
                            min: 0,
                            def: 0,
                            role: 'value'
                        });
                        createState(EmailText, {
                            type: 'string',
                            min: 0,
                            def: 0,
                            role: 'value'
                        });
                        
                        
                            var MailListener = require("mail-listener4");
                             
                            var maillistenerSetting =  {
                             username: "xxxxx.de",    // hier Email Adresse eintragen
                              password: "xxxxxxxx",	      // hier Passwort eintragen	
                              host: "imap.1und1.de",
                              port: 993, // imap port
                              tls: true,
                              connTimeout: 10000, // Default by node-imap
                              authTimeout: 5000, // Default by node-imap,
                              debug: null, // Or your custom function with only one incoming argument. Default: null
                              tlsOptions: { rejectUnauthorized: false },
                              mailbox: "INBOX", // HIER Postfach eingeben z.B. INBOX 
                              searchFilter: ["UNSEEN"], // the search filter being used after an IDLE notification has been retrieved
                              markSeen: false, // all fetched email willbe marked as seen and not fetched next time
                              fetchUnreadOnStart: true, // use it only if you want to get all unread email on lib start. Default is `false`,
                              mailParserOptions: {streamAttachments: false}, // options to be passed to mailParser lib.
                              attachments: false, // download attachments as they are encountered to the project directory
                              attachmentOptions: { directory: "attachments/" } // specify a download directory for attachments
                            };
                             var MailListener = require("mail-listener4");
                            var mailListener = new MailListener(
                                maillistenerSetting
                            );
                           
                            mailListener.start();
                            mailListener.on("server:connected", function(){/*console.log("imapconconnected")*/;});
                            mailListener.on("server:disconnected", function(){/*console.log("imapDisconnected");*/});
                            mailListener.on("error", function(err){console.log(err);});
                            mailListener.on("mail", function(mail, seqno, attributes){
                            
                             //   log("Mail from: "+mail.from[0].address);
                               // log("Name: "+mail.from[0].name);
                               // log("Subject: "+mail.subject);
                                log("Text: "+mail.text);
                        
                        //     setState(EmailEingang,mail.from[0].address);  	//setze Datenpunkt mit Email-Absender (als Trigger nutzbar)
                        //     setState(EmailText,mail.text);			//setze Datenpunkt mit kompletten Email-Inhalt
                            });
                        
                            // mailListener.on("attachment", function(attachment){console.log(attachment.path);}); //wenn Anhänge verarbeitet werden sollen einkommentieren
                        
                        
                        
                        
                        
                        
                        

                        Image 6.png

                        Gargano 1 Reply Last reply Reply Quote 0
                        • Gargano
                          Gargano @liv-in-sky last edited by

                          @liv-in-sky Seltsam, bei mir geht es auch mit mail-listener4 nicht.
                          Muß ich irgendetwas anderes noch eintragen außer in der Javascript Instanz ?
                          592f4d05-db99-4d6c-b715-6e09db942c27-grafik.png

                          liv-in-sky 2 Replies Last reply Reply Quote 0
                          • liv-in-sky
                            liv-in-sky @Gargano last edited by

                            @Gargano

                            nein nur da- hast du mein script getestet - ist anders als deines

                            1 Reply Last reply Reply Quote 0
                            • liv-in-sky
                              liv-in-sky @Gargano last edited by

                              @Gargano

                              ich hatte bei deinem script einen fehler im log - ich nutze javascript version 4.10.5 - vielleicht macht das was aus

                              Gargano 3 Replies Last reply Reply Quote 0
                              • Gargano
                                Gargano @liv-in-sky last edited by

                                @liv-in-sky Welcher Fehler im Log war das ?

                                1 Reply Last reply Reply Quote 0
                                • Gargano
                                  Gargano @liv-in-sky last edited by

                                  @liv-in-sky Ich hab mal Dein Script versucht, da funktioniert gar nichts. Es kommt keine Email an.

                                  liv-in-sky 1 Reply Last reply Reply Quote 0
                                  • Gargano
                                    Gargano @liv-in-sky last edited by

                                    @liv-in-sky Ich hab die Version 4.10.8

                                    1 Reply Last reply Reply Quote 0
                                    • liv-in-sky
                                      liv-in-sky @Gargano last edited by

                                      @Gargano irgendwas mit "maillistener ist kein constructor"
                                      -log ist leider schon gelöscht

                                      Gargano 1 Reply Last reply Reply Quote 0
                                      • Gargano
                                        Gargano @liv-in-sky last edited by

                                        @liv-in-sky
                                        Mit deinem Script geht das Empfangen auch, dauert etwas bis es in den Objekten ist.
                                        Beim mail_text steht dies drin : FEHLER beim Lesen oder leer

                                        Was equivalent zu meinem Script bei mail.text = undefined ist.
                                        Soweit also gleich.

                                        Kann es sein, daß bei 1und1 etwas anders ist als bei gmail o.a. ?

                                        liv-in-sky 1 Reply Last reply Reply Quote 0
                                        • liv-in-sky
                                          liv-in-sky @Gargano last edited by

                                          @Gargano

                                          diesen fehler hatte ich mit mails, die im html format waren - daher node red, da ist dieses problem nicht

                                          teste mal ein anderes, ohne html inhalt

                                          Gargano 1 Reply Last reply Reply Quote 0
                                          • Gargano
                                            Gargano @liv-in-sky last edited by

                                            @liv-in-sky Heureka, das wars. Email im Raw Format geht.
                                            Danke für die Hilfe

                                            liv-in-sky 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate
                                            FAQ Cloud / IOT
                                            HowTo: Node.js-Update
                                            HowTo: Backup/Restore
                                            Downloads
                                            BLOG

                                            907
                                            Online

                                            31.9k
                                            Users

                                            80.1k
                                            Topics

                                            1.3m
                                            Posts

                                            iobroker javascript mailistener2
                                            7
                                            101
                                            7139
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo