humanemulator.net — справка. Продукт, демо и покупка — на хуманэмулятор.рф | Демо | Купить | API | Changelog

set_message_readed_by_id_via_imap

set_message_readed_by_id_via_imap($folder,$id,$is_readed=true,$timeout=300); - Установить для сообщения статус прочитано по ID IMAP

Функция на вход принимает параметры:

  • $folder – Имя папки.
  • $id – Идентификатор письма.
  • $is_readed – Задать статус прочитано? Да/Нет
  • $timeout – Таймаут выполнения (по умолчанию 300)

    После выполнения функции возвращаемое значение будет равно одному из двух :
  • true – успешно
  • false – не удалось

    Пример использования
    <?php
    // Scenario: Set message as read by ID using IMAP protocol
    
    $xhe_host = getenv("RPABOT_HOST_URL");
    if (!isset($path)){
        // Path to the init.php file for connecting to the XHE API
        $path = "../../../Templates/init.php";
        // Including init.php grants access to all classes and functionality for working with the XHE API
        require($path);
    }
    
    // Start
    echo("\n<span style=\"color: blue; \">mail->" .basename (__FILE__). "</span>\n");
    
    // Set search depth limit for number of messages
    echo("\nSet search depth limit for number of messages: 100");
    var_export(WEB::$mail->set_limit(100));
    
    echo("\n\nTEST YA");
    
    $imapServer = 'imap.yandex.ru';
    $imapPort = 993;
    $imapLogin =  new EncodedVariable('YandexImapLogin');
    $imapPassword = new EncodedVariable('YandexImapPassword');
    $sslOption = 2; // Connection encryption: 2 (ssl)
    $certType = '';
    $timeout = 3000;
    $logPath = 'imap_log.txt';
    $targetFolder = 'test';
    $fromSearch = $imapLogin;
    $subjectSearch = 'test';
    $textSearch = 'test';
    
    try {
        // Step 1
        echo("\nStep 1. Connect to IMAP server '$imapServer': ");
        $isConnected = WEB::$mail->imap_connect($imapServer, $imapPort, $imapLogin, $imapPassword, $sslOption, $certType, $timeout, $logPath);
        var_export($isConnected);
    
        if ($isConnected) {
    
            // Step 2
            echo("\nStep 2. Get number of messages in folder '$targetFolder': ");
            $messagesCount = WEB::$mail->get_message_count_via_imap($targetFolder);
            echo($messagesCount);
    
            if ($messagesCount == 0) {
                // Step 3
                echo("\nStep 3. Add message to folder '$targetFolder':");
                $from = $imapLogin;
                $to = $imapLogin;
                $subject = $subjectSearch;
                $body = "test";
                $priority = 0;
                echo(WEB::$mail->add_message_via_imap($targetFolder, $from, $to, $subject, $body, $priority));
            }
    
            // Step 4
            echo("\nStep 4. Get message 0 in folder '$targetFolder': ");
            $message = WEB::$mail->get_message_by_number_via_imap($targetFolder, 0);
            echo("\nid: " . $message->message_id);
            echo("\nsubject: " . $message->subject);
            echo("\nfrom: " . $message->from);
            echo("\ndate: " . $message->date);
            echo("\nread: " . $message->is_readed);
            echo("\nbody length: " . strlen($message->body) . "\n");
    
            // Step 5
            echo("\nStep 5. Set message as read in folder '$targetFolder'. Find message by ID = '$message->message_id': ");
            $isReaded = true;
            var_export(WEB::$mail->set_message_readed_by_id_via_imap($targetFolder, $message->message_id, $isReaded));
             
            // Step 6
            echo("\nStep 6. Get message 0 in folder '$targetFolder': ");
            $message = WEB::$mail->get_message_by_number_via_imap($targetFolder, 0);
            echo("\nid: " . $message->message_id);
            echo("\nsubject: " . $message->subject);
            echo("\nfrom: " . $message->from);
            echo("\ndate: " . $message->date);
            echo("\nread: " . $message->is_readed);
            echo("\nbody length: " . strlen($message->body) . "\n");
    
        }
    }
    finally {
        echo("\nDisconnect: ");
        echo(WEB::$mail->imap_disconnect());
    }
    
    
    // Quit the application
    WINDOW::$app->quit();
    ?>
    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
    
    xhe_host = "127.0.0.1:7040"
    from xweb_human_emulator import *
    
    # начало
    echo("<hr><font color=blue>mail.xxxxxxxxx</font><hr>")
    
    # 1
    echo("1. Соединимся с IMAP сервером : ");
    echo(mail.imap_connect("imap.mail.ru",993,"@mail.ru","xxx"),"\n")
    
    # 2
    echo("2. Получим 0 письмо : ")
    message = mail.get_message_by_number_via_imap("", 0)
    echo("&nbsp;&nbsp;id: "+message.message_id+"\n")
    echo("&nbsp;&nbsp;from: "+message.from_+"\n")
    
    # 3
    echo("3. Зададим что письмо прочитано : ");
    echo(mail.set_message_readed_by_id_via_imap("", message.message_id,true));
    
    # 4
    echo("\n4. Отсоединиться : ");
    echo(mail.imap_disconnect(),"\n");
    
    # конец
    echo("<hr><br>")
    
    # Quit
    app.quit()
    #region using
    
    using System;
    using System.Diagnostics;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    using System.Text;
    using System.Threading;
    
    using XHE;
    using XHE.XHE_DOM;
    using XHE.XHE_System;
    using XHE.XHE_Window;
    using XHE.XHE_Web;
    
    #endregion
    
     class Program:XHEScript
     {
    	  static void Main(string[] args)
    	  {
    			// init XHE
    			server = Environment.GetEnvironmentVariable("RPABOT_HOST_URL");
    			InitXHE();
    
                // начало
                echo("<hr><font color=blue>mail->get_message_by_from_via_imap</font><hr>");
    
    			// 1
    			echo("1. Соединимся с IMAP сервером : ");
    			echo(mail.imap_connect("imap.mail.ru",993,"@mail.ru","xxx")+"\n");
    
    			// 2
    			echo("2. Получим 0 письмо : ");
    			var message = mail.get_message_by_number_via_imap("", 0);
    			echo("&nbsp;&nbsp;id: "+message.message_id+"\n");
    			echo("&nbsp;&nbsp;from: "+message.from+"\n");
    
    			// 3
    			echo("3. Зададим что письмо прочитано : ");
    			echo(mail.set_message_readed_by_id_via_imap("", message.message_id,true));
    
    			// 4
    			echo("\n4. Отсоединиться : ");
    			echo(mail.imap_disconnect());
    
                // конец
                echo("\n\n");
    
                // Quit
                app.quit();
          }
    }
    xhe_host = "127.0.0.1:7040";
    echo=require("../../../Templates JS/init.js");
    
    // начало
    echo("<hr><font color=blue>mail.get_message_by_from_via_imap</font><hr>");
    
    // 1
    echo("1. Соединимся с IMAP сервером : ");
    echo(mail.imap_connect("imap.mail.ru",993,"@mail.ru","xxx")+"\n");
    
    // 2
    echo("2. Получим 0 письмо : ");
    var message = mail.get_message_by_number_via_imap("", 0);
    echo("&nbsp;&nbsp;id: "+message.message_id+"\n");
    echo("&nbsp;&nbsp;from: "+message.from+"\n");
    
    // 3
    echo("3. Зададим что письмо прочитано : ");
    echo(mail.set_message_readed_by_id_via_imap("", message.message_id,true));
    
    // 4
    echo("\n4. Отсоединиться : ");
    echo(mail.imap_disconnect());
    
    // конец
    echo("\n");
    
    // Quit
    app.quit();

    =============================================
    Mail    Объекты    DOM  System  Vision  Web  Window        
    =============================================
    если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
    .