Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. Javascript Instanz wird von MailListener getötet

    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

    Javascript Instanz wird von MailListener getötet

    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      WolfgangFB @fastfoot last edited by

      @fastfoot

      Das Problem taucht immer noch auf

      TypeError: mime.extension is not a function at MailParser._generateFileName (/opt/iobroker/node_modules/iobroker.javascript/node_modules/mailparser/lib/mailparser.js:1407:27) at MailParser._processStateHeader (/opt/iobroker/node_modules/iobroker.javascript/node_modules/mailparser/lib/mailparser.js:309:61) at MailParser._process (/opt/iobroker/node_modules/iobroker.javascript/node_modules/mailparser/lib/mailparser.js:227:22) at processImmediate (internal/timers.js:464:21)
      

      Kann es sein,. dass es sich um Anhänge handelt, die das Problem auslösen?
      Ich habe aber den Part mit

      mailListener.on("attachment"
      

      schon rausgenommen. Kann man dem Maillistener irgendwie beibringen, Anhänge zu ignorieren?

      F 1 Reply Last reply Reply Quote 0
      • F
        fastfoot @WolfgangFB last edited by

        @wolfgangfb

          mailParserOptions: {streamAttachments: true}, // options to be passed to mailParser lib.
          attachments: true, // download attachments as they are encountered to the project directory
          attachmentOptions: { directory: "attachments/" } // specify a download directory for attachments
        
        1 Reply Last reply Reply Quote 0
        • W
          WolfgangFB last edited by

          @fastfoot
          Ich konnte jetzt zu 100% nachvollziehen, dass die gesamte Javascript Instanz abstürzt, sobald die letzte Mail einen Anhang enthält.
          Ich habe inzwischen

          var MailListener = require("mail-listener2-updated");
          

          und

            mailParserOptions: {streamAttachments: false}, // options to be passed to mailParser lib.
            attachments: false, // download attachments as they are encountered to the project directory
            attachmentOptions: { directory: AttachmentsDirectory } // specify a download directory for attachments
          

          gesetzt.
          Der Trigger

          mailListener.on("mail", function(mail, seqno, attributes){
          

          wird bis zum Ende durchlaufen (mit Logdatei kontrolliert). Dann kommt kein weiterer Logeintrag und die Javascript Instanz stürzt ab, Nach ca. 40 Sekunden startet die Javascript Instanz neu, demnach auch das Skript und das ganze geht in eine Endlosschleife.
          Hat noch jemand eine Ahnung, wie ich das abstellen könnte?
          Es wäre ja schon hilfreich, wenn on("mail") wirklich nur aufgerufen werden würde, wenn wirklich eine neue Mail kommt und nicht bei jedem Skriptstart die letzte Mail wieder gelesen werden würde.
          Welche Alternativen gibt es zu mail-listener2? Ich brauche eigentlich nur den Betreff und den Absender. Der Rest ist für diese Aufgabe irrelevant.

          DJMarc75 F 2 Replies Last reply Reply Quote 0
          • DJMarc75
            DJMarc75 @WolfgangFB last edited by

            @wolfgangfb sagte in Javascript Instanz wird von MailListener getötet:

            Welche Alternativen gibt es zu mail-listener2? Ich brauche eigentlich nur den Betreff und den Absender. Der Rest ist für diese Aufgabe irrelevant.

            Da ich ein ähnliches Problem hatte habe ich das per NODE-RED gelöst - läuft und ich schreibe mir alle Werte einzeln in ein JSON damit.

            1 Reply Last reply Reply Quote 0
            • F
              fastfoot @WolfgangFB last edited by

              @wolfgangfb sagte in Javascript Instanz wird von MailListener getötet:

              attachmentOptions: { directory: AttachmentsDirectory }

              hast markSeen auf false gesetzt?
              Stimmt dein attachmentOptions: { directory: AttachmentsDirectory }?

              Ansonsten ist das Programm halt schon recht betagt. Mehr fällt mir dazu nicht ein

              W 1 Reply Last reply Reply Quote 0
              • W
                WolfgangFB @fastfoot last edited by

                @fastfoot
                MarkSeen hat das ganze etwas verbessert.
                Gibt es denn Alternativen um Mails zu empfangen?

                DJMarc75 F 2 Replies Last reply Reply Quote 0
                • DJMarc75
                  DJMarc75 @WolfgangFB last edited by

                  @wolfgangfb sagte in Javascript Instanz wird von MailListener getötet:

                  Gibt es denn Alternativen um Mails zu empfangen?

                  Ähm... ignoriert ?

                  @djmarc75 sagte in Javascript Instanz wird von MailListener getötet:

                  Da ich ein ähnliches Problem hatte habe ich das per NODE-RED gelöst - läuft und ich schreibe mir alle Werte einzeln in ein JSON damit.

                  1 Reply Last reply Reply Quote 0
                  • F
                    fastfoot @WolfgangFB last edited by

                    @wolfgangfb sagte in Javascript Instanz wird von MailListener getötet:

                    Gibt es denn Alternativen um Mails zu empfangen?

                    schau dir mal node-imap an, das ist recht aktuell

                    1 Reply Last reply Reply Quote 0
                    • F
                      fastfoot last edited by

                      Hier mal ein Beispiel mit node-imap:

                      /*
                       * Zweck:     liest emails von Imap Providern
                       * Datum:     07.07.2022
                       * Autor:     @fastfoot
                       *            für iobroker modifizierter Beispielcode von https://github.com/mscdex/node-imap
                      */
                      var Imap = require('imap'),
                          inspect = require('util').inspect;
                      
                      var imap = new Imap({
                          user: 'user@gmail.com',
                          password: 'mypassword',
                          host: 'imap.gmail.com',
                          port: 993,
                          tls: true,
                          tlsOptions: { rejectUnauthorized: false }, //verhindert den Fehler 'self signed certificate'
                          debug: console.log // oder null 
                      });
                      
                      function openInbox(cb) {
                          imap.openBox('INBOX', true, cb);
                      }
                      
                      imap.once('ready', function () {
                          openInbox(function (err, box) {
                              if (err) throw err;
                              var f = imap.seq.fetch('1:5', {
                                  bodies: 'HEADER.FIELDS (FROM TO SUBJECT DATE)',
                                  struct: true
                              });
                              f.on('message', function (msg, seqno) {
                                  console.log('Message #' + seqno);
                                  var prefix = '(#' + seqno + ') ';
                                  msg.on('body', function (stream, info) {
                                      var buffer = '';
                                      stream.on('data', function (chunk) {
                                          buffer += chunk.toString('utf8');
                                      });
                                      stream.once('end', function () {
                                          const headers = Imap.parseHeader(buffer);
                                          log('Datum: ' + headers.date[0]);
                                          log('From: ' + headers.from[0]);
                                          log('To: ' + headers.to[0]);
                                          log('Subject: ' + headers.subject[0]);
                                      });
                                  });
                                  msg.once('attributes', function (attrs) {
                                      console.log(prefix + 'Attributes: ' + inspect(attrs, false, 8));
                                  });
                                  msg.once('end', function () {
                                      console.log(prefix + 'Finished');
                                  });
                              });
                              f.once('error', function (err) {
                                  console.log('Fetch error: ' + err);
                              });
                              f.once('end', function () {
                                  console.log('Done fetching all messages!');
                                  imap.end();
                              });
                          });
                      });
                      
                      imap.once('error', function (err) {
                          console.log(err);
                      });
                      
                      imap.once('end', function () {
                          console.log('Connection ended');
                      });
                      
                      imap.connect();
                      
                      onStop(() => {
                          imap.end();
                      })
                      
                      
                      M 1 Reply Last reply Reply Quote 0
                      • M
                        Masl @fastfoot last edited by

                        @fastfoot Kannst du mir zufällig helfen, wie man einen Datenpunkt mit dieser Vorlage erstellt die man später auslesen kann? Der Mail-Listener bringt mir nur Fehler...

                        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

                        962
                        Online

                        31.8k
                        Users

                        80.0k
                        Topics

                        1.3m
                        Posts

                        5
                        15
                        855
                        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