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

imap_disconnect

imap_disconnect(); - отсоединится от IMAP сервера

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

    Пример использования
    <?php
    // Scenario: Disconnect from IMAP server
    
    $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");
    
    echo("\n\nTEST YA");
    
    $imapServer = 'imap.yandex.ru';
    $imapPort = 993;
    $imapLogin =  new EncodedVariable('YandexImapLogin'); // Create variable 'YandexImapLogin' in "Security Manager"
    $imapPassword = new EncodedVariable('YandexImapPassword'); // Create variable 'YandexImapPassword' in "Security Manager"
    $sslOption = 2; // Connection encryption: 2 (ssl)
    $certType = '';
    $timeout = 3000;
    $logPath = 'imap_log.txt';
    $targetFolder = 'test';
    $fromSearch = $imapLogin;
    
    /*
    echo("\n\nTEST MAIL.RU");
    
    $imapServer = 'imap.mail.ru';
    $imapPort = 993;
    $imapLogin =  new EncodedVariable('MailRUImapLogin');
    $imapPassword = new EncodedVariable('MailRUImapPassword');
    $sslOption = 2; // Connection encryption: 2 (ssl)
    $certType = '';
    $timeout = 3000;
    $logPath = 'imap_log.txt';
    $targetFolder = 'test';
    $fromSearch = $imapLogin;
    */
    
    try
    {
        // Step 1 - Without proxy
        WEB::$mail->set_proxy("");
    
        // Step 2
        echo("\nStep 2. Connect to IMAP server '$imapServer': ");
        $isConnected = WEB::$mail->imap_connect($imapServer, $imapPort, $imapLogin, $imapPassword, $sslOption, $certType, $timeout, $logPath);
        var_export($isConnected);
    
        if ($isConnected) {
    
            // Step 3
            echo("\nStep 3. Get number of messages in folder '$targetFolder': ");
            $messagesCount = WEB::$mail->get_message_count_via_imap($targetFolder);
            echo($messagesCount);
        }
    }
    finally {
        echo("\nDisconnect: ");
        var_export(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:7057"
    from xweb_human_emulator import *
    
    # начало
    echo("<hr><font color=blue>mail.xxxxxxxxx</font><hr>")
    
    # 1
    echo("1. Соединимся с IMAP яндекса : ")
    echo(mail.imap_connect("imap.rambler.ru",143,"loginovskiyy-guriyy@rambler.ru","rieqoo"),"\n")
    
    # 2
    echo("2. Получим число писем : ")
    echo(mail.get_message_count_via_imap(),"\n")
    
    # 3
    echo("3. Соединимся с IMAP mail.ru : ")
    echo(mail.imap_connect("imap.mail.ru",993,"arna.pervak@mail.ru","msnijwdx"),"\n")
    
    # 4
    echo("4. Получим число писем : ")
    echo(mail.get_message_count_via_imap()+"\n")
    
    # 5
    echo("5. Отсоединимся от IMAP : ")
    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_text_via_imap</font><hr>");
    
                // 1
                echo("1. Соединимся с IMAP яндекса : ");
                echo(mail.imap_connect("imap.rambler.ru",143,"loginovskiyy-guriyy@rambler.ru","rieqoo")+"\n");
    
                // 2
                echo("2. Получим число писем : ");
                echo(mail.get_message_count_via_imap()+"\n");
    
                // 3
                echo("3. Соединимся с IMAP mail.ru : ");
                echo(mail.imap_connect("imap.mail.ru",993,"arna.pervak@mail.ru","msnijwdx")+"\n");
    
                // 4
                echo("4. Получим число писем : ");
                echo(mail.get_message_count_via_imap()+"\n");
    
                // 5
                echo("5. Отсоединимся от IMAP : ");
                echo(mail.imap_disconnect()+"\n");
    
                // конец
                echo("\n\n");
    
                // Quit
                app.quit();
          }
    }
    xhe_host = "127.0.0.1:7057";
    echo=require("../../../Templates JS/init.js");
    
    // начало
    echo("<hr><font color=blue>mail->get_message_by_text_via_imap</font><hr>");
    
    // 1
    echo("1. Соединимся с IMAP яндекса : ");
    echo(mail.imap_connect("imap.rambler.ru",143,"loginovskiyy-guriyy@rambler.ru","rieqoo")+"\n");
    
    // 2
    echo("2. Получим число писем : ");
    echo(mail.get_message_count_via_imap()+"\n");
    
    // 3
    echo("3. Соединимся с IMAP mail.ru : ");
    echo(mail.imap_connect("imap.mail.ru",993,"arna.pervak@mail.ru","msnijwdx")+"\n");
    
    // 4
    echo("4. Получим число писем : ");
    echo(mail.get_message_count_via_imap()+"\n");
    
    // 5
    echo("5. Отсоединимся от IMAP : ");
    echo(mail.imap_disconnect()+"\n");
    
    // конец
    echo("\n");
    
    // Quit
    app.quit();

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