Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. [gelöst]Script per Schedule neustarten

    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]Script per Schedule neustarten

    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      marsmännchen last edited by marsmännchen

      Hallo zusammen,
      ich habe das Script für eine Emailabfrage gefunden.
      Dadurch lasse ich mir die neuste Email anzeigen.
      Eigentlich recht simpel.
      Leider passiert es immer das er nach kurzer Zeit (2Std. oder so) "imapDisconnected" schreibt.
      Könnte mir vielleicht jemand einen Weg erläutern, oder einen Befehl/Funktion sagen welcher bei "imapDisconnected" das Skript neu Startet?

      // Quelle Original: https://github.com/chirag04/mail-listener2
      // Quelle Forum: https://forum.iobroker.net/topic/18501/emails-empfangen
       
      createState("IMAP.EmailSubject");
      createState("IMAP.Email_Eingang"); 	//dieser Datenpunkt wird erzeugt
      createState("IMAP.EmailText");		//dieser Datenpunkt enthält den email-Text
       
          var MailListener = require("mail-listener2-updated");
          var mailListener = new MailListener({
            username: "xxxxxxx@gmail.com",    // HIER Email Adresse eintragen
            password: "12345",	      // HIER Passwort eintragen	
            host: "imap.gmail.com",
            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(err);});
          mailListener.on("mail", function(mail, seqno, attributes){
              //log(mail.from[0].address);
              //log(mail.from[0].name);
              log(mail.subject);
              //log( mail.text);
           setState("IMAP.Email_Eingang",mail.from[0].address);  	//setze Datenpunkt mit Email-Absender (als Trigger nutzbar)
           setState("IMAP.EmailText",mail.text);                   //setze Datenpunkt mit kompletten Email-Inhalt
           setState("IMAP.EmailSubject",mail.subject);			//Betreff
          });
          // mailListener.on("attachment", function(attachment){console.log(attachment.path);}); //wenn Anhänge verarbeitet werden sollen einkommentieren
      
      

      Oder vielleicht hat jemand einen Eintrag im Forum entdeckt der das selbe Problem beschreibt. Ich bis jetzt noch nicht.
      MfG
      Patrick

      liv-in-sky 1 Reply Last reply Reply Quote 0
      • liv-in-sky
        liv-in-sky @marsmännchen last edited by

        @marsmännchen

        ich habe das mail holen als function, die alle x-minuten aufgeruft wird - nachdem die function die mails geholt hat, wird ein mailListener.stop(); ausgeführt

        in diesem script kannst du das sehen https://forum.iobroker.net/post/484416

        M 1 Reply Last reply Reply Quote 0
        • M
          marsmännchen @liv-in-sky last edited by

          @liv-in-sky danke, ist das diese "async function getMail()" Funktion?

          liv-in-sky 1 Reply Last reply Reply Quote 0
          • liv-in-sky
            liv-in-sky @marsmännchen last edited by

            @marsmännchen ja genau - ganz unten im script

            M 1 Reply Last reply Reply Quote 1
            • M
              marsmännchen @liv-in-sky last edited by

              @liv-in-sky Ohje, na vielen Dank für den Tipp.👍

              1 Reply Last reply Reply Quote 0
              • First post
                Last post

              Support us

              ioBroker
              Community Adapters
              Donate

              815
              Online

              31.8k
              Users

              80.0k
              Topics

              1.3m
              Posts

              2
              5
              138
              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