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

add_message_via_imap

add_message_via_imap($folder,$from,$to,$subject,$message,$type,$cc="",$bcc="",$attachments=null,$timeout=300,$replyTo=""); - Добавить сообщение в папку IMAP

Поле $type примеры значений:
0 - тело письма это HTML;
1 - тело письма это RTF;
2 - тело письма это текст.
/

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

  • $folder – Имя папки.
  • $from – Адрес отправителя.
  • $to – Строка адреса получателей с разделителем точка с запятой или запятая
  • $subject – Тема письма.
  • $message – Текст письма.
  • $type – Тип письма
  • $cc – Строка адреса получателей копии с разделителем точка с запятой
  • $bcc – Строка адреса получателей скрытой копии с разделителем точка с запятой
  • $attachments – Вложения (опционально).
  • $timeout – Таймаут исполнение операции, сек
  • $replyTo – Адрес для ответа (опционально).

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

    Пример использования
    <?php
    // Scenario: Add a message to IMAP folder 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; \">webpage->" .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;
    
    try {
        // Step 1
        echo("\nStep 1. Connect to IMAP server: ");
        $isConnected = WEB::$mail->imap_connect($imapServer, $imapPort, $imapLogin, $imapPassword, $sslOption, $certType, $timeout, $logPath);
        var_export($isConnected);
    
        if ($isConnected) {
            // Example 1
            echo("\n\nExample 1. Add message to folder '$targetFolder':");
            $from = $imapLogin;
            $to = $imapLogin;
            $subject = "test";
            $body = "test";
            $priority = 0;
            echo(WEB::$mail->add_message_via_imap($targetFolder, $from, $to, $subject, $body, $priority));
        }
    
    }
    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:7021"
    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,"arna.pervak@mail.ru","msnijwdx"),"\n");
    
    # 2
    echo("2. Добавим письмо :");
    echo(mail.add_message_via_imap("Входящие","loginovskiyy-guriyy@rambler.ru","loginovskiyy-guriyy@mail.com","test","test message rambler","0"),"\n");
    
    # 3
    echo("3. Отсоединиться : ");
    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->send_mail_via_smtp</font><hr>");
    
    			// 1
    			echo("1. Соединимся с IMAP сервером : ");
    			echo(mail.imap_connect("imap.mail.ru",993,"arna.pervak@mail.ru","msnijwdx")+"\n");
    
    			// 2
    			echo("2. Добавим письмо :");
    			echo(mail.add_message_via_imap("Входящие","loginovskiyy-guriyy@rambler.ru","loginovskiyy-guriyy@mail.com","test","test message rambler","0")+"\n");
    
    			// 3
    			echo("3. Отсоединиться : ");
    			echo(mail.imap_disconnect()+"\n");
    
                // конец
                echo("\n\n");
    
                // Quit
                app.quit();
          }
    }
    xhe_host = "127.0.0.1:7021";
    echo=require("../../../Templates JS/init.js");
    
    // начало
    echo("<hr><font color=blue>mail->send_mail_via_smtp</font><hr>");
    
    // 1
    echo("1. Соединимся с IMAP сервером : ");
    echo(mail.imap_connect("imap.mail.ru",993,"arna.pervak@mail.ru","msnijwdx")+"\n");
    
    // 2
    echo("2. Добавим письмо :");
    echo(mail.add_message_via_imap("Входящие","loginovskiyy-guriyy@rambler.ru","loginovskiyy-guriyy@mail.com","test","test message rambler",0)+"\n");
    
    // 3
    echo("3. Отсоединиться : ");
    echo(mail.imap_disconnect()+"\n");
    
    // конец
    echo("\n");
    
    // Quit
    app.quit();

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