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

send_mail

send_mail($from,$to,$subject,$message,$type,$cc="",$bcc="",$replyTo="",$attachments=array(),$timeout=300); - E-mail

$type:
1 - ;
2 - HTML.

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

  • $from
  • $to
  • $subject
  • $message
  • $type E-mail
  • $cc
  • $bcc
  • $replyTo
  • $attachments -
  • $timeout ,

    :
  • true
  • false

    Пример использования
    <?php
    // Scenario: Send an email with attachments
    $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);
    }
    
    // Beginning
    echo "\n<font color=blue>msexchange->".basename (__FILE__)."</font>\n";
    
    // Access credentials
    require("./in/login.php");
    
    global $ms_api_url, $ms_api_user_name_or_email, $ms_api_user_password, $ms_api_userDomain, $useAutodiscoverEWSUrl;
    
    try{
        // Step 1: Connect to MS Exchange
        echo("Step 1: Connect to MS Exchange: ");
        $isConnected = WEB::$msexchange->connect($ms_api_url, $ms_api_user_name_or_email, $ms_api_user_password, $ms_api_userDomain, $useAutodiscoverEWSUrl);
        var_export($isConnected);
        if ($isConnected) {
    
            // Prepare attachment file path
            $attachment_file_path = __DIR__ . "/test/test.bmp";
    
            // Prepare attachments array
            $attachments = array();
            $attachments[] = $attachment_file_path;
    
            // Example 1: Send email to self with attachment
            echo("Example 1: Send email to self with attachment: ");
            $toAddress = $ms_api_user_name_or_email;
            $fromAddress = $ms_api_user_name_or_email;
            $subject = "test";
            $messageBody = "test test message";
            $importance = 1;
            $ccAddress = $ms_api_user_name_or_email;
            $bccAddress = $ms_api_user_name_or_email;
            var_export(WEB::$msexchange->send_mail(
                $toAddress,
                $fromAddress,
                $subject,
                $messageBody,
                $importance,
                $ccAddress,
                $bccAddress,
                $fromAddress,
                $attachments
            ));
    
        }
    }
    finally
    {
        // Step 2: Disconnect from MS Exchange
        echo("\nStep 2: Disconnect from MS Exchange: ");
        echo(WEB::$msexchange->disconnect());
    }
    
    // Quit the application
    WINDOW::$app->quit();
    ?>
    # Additional paths
    import sys
    # подключим функциональные объекты, если еще не подключен
    sys.path.insert(0, '../../../Templates PY/')
    
    xhe_host = "127.0.0.1:7010"
    from xweb_human_emulator import msexchange, app, echo
    
    # начало
    echo("<hr><font color=blue>msexchange->get_message_categories_by_id</font><hr>")
    
    from login.login import ms_api_url, ms_api_email, ms_api_password, ms_api_userDomain, useAutodiscoverEWSUrl
    
    # 1
    echo("1. Соединится: ")
    echo(msexchange.connect(ms_api_url, ms_api_email, ms_api_password, ms_api_userDomain, useAutodiscoverEWSUrl))
    
    # Путь к файлу для приложения к письму
    attachment_file_path = "./test/test.bmp"
    
    # Массив с файлами приложениями
    attachments = [1]
    attachments[0] = attachment_file_path
    
    # 2
    echo("2. Отправить письмо себе с приложенным файлом: ")
    echo(msexchange.send_mail(
    	ms_api_email,
        ms_api_email,
        "test",
        "test test message",
        1,
        ms_api_email,
        ms_api_email,
        ms_api_email,
        attachments
        ))
    
    # 3
    echo("\n3. Отсоединится: ")
    echo(msexchange.disconnect())
    
    echo("\n")
    
    # 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 = "127.0.0.1:7012";
            InitXHE();
            // начало
            echo("<hr><font color=blue>msexchange->send_mail</font><hr>");
    
    
            /** Адрес API сервиса MS Exchange */
            string ms_api_url = "";
    
            /** Логин учётной записи Пользователя MS Exchange */
            string ms_api_email = "";
    
            /** Пароль учётной записи Пользователя MS Exchange */
            string ms_api_password = "";
    
            /** Домен учётной записи Пользователя */
            string ms_api_userDomain = "test";
    
            /** Запросить URL сервера EWS, если адрес не был указан явно (адрес неправильный).
             * Пример правильного URL EWS: https://outlook.office365.com/EWS/Exchange.asmx
             */
            bool useAutodiscoverEWSUrl = false;
    
            // 1
            echo("1. Соединится: ");
            echo(msexchange.connect(ms_api_url,  ms_api_email, ms_api_password, ms_api_userDomain, useAutodiscoverEWSUrl));
    
    
            // Путь к файлу для приложения к письму
            var attachment_file_path = Path.Combine(Directory.GetCurrentDirectory(), "/test/test.bmp");
    
            // Массив с файлами приложениями
            var attachments = {attachment_file_path};
    
            // 2
            echo("2. Отправить письмо себе с приложенным файлом: ");
            echo(msexchange.send_mail(
                    ms_api_email, 
                    ms_api_email,
                    "test",
                    "test test message",
                    1,
                    ms_api_email,
                    ms_api_email,
                    ms_api_email,
                    attachments
                ));
    
            // 3
            echo("\n3. Отсоединится: ");
            echo(msexchange.disconnect());
    
            // конец
            echo("\n");
    
            // Quit
            app.quit();
        }
    }
    xhe_host = "127.0.0.1:7010";
    
    // подключим функциональные объекты, если еще не подключен
    echo = require("../../../Templates JS/init.js");
    
    // начало
    echo("<hr><font color=blue>msexchange->send_mail</font><hr>");
    
    // доступы
    const {ms_api_url, ms_api_email, ms_api_password, ms_api_userDomain, useAutodiscoverEWSUrl} = require("./in/login.js");
    
    // 1
    echo("1. Соединится: ");
    echo(msexchange.connect(ms_api_url, ms_api_email, ms_api_password, ms_api_userDomain, useAutodiscoverEWSUrl));
    
    // Путь к файлу для приложения к письму
    $attachment_file_path = "test\\test.bmp";
    
    // Массив с файлами приложениями
    $attachments = [1];
    $attachments[0] = $attachment_file_path;
    
    // 2
    echo("2. Отправить письмо себе с приложенным файлом: ");
    echo(msexchange.send_mail(
    	ms_api_email,
        ms_api_email,
        "test",
        "test test message",
        1,
        ms_api_email,
        ms_api_email,
        ms_api_email,
        $attachments
        ));
    
    // 3
    echo("\n3. Отсоединится: ");
    echo(msexchange.disconnect());
    
    echo("\n");
    
    // Quit
    app.quit();

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