2

THE SITUATION:

I am going to use Yandex Mail for Domain API for my app.
I am testing all the http request to the API, using php curl. Everything is working fine except two functions:

  • Import single mailbox
  • Import multiple mailboxes

I don't know if the problem is related to the sintax or to other factors.

THE CODE:

public function yandex_import_mailbox()
{
    $url ='https://pddimp.yandex.ru/api2/admin/import/start_one_import?domain=MY_DOMAIN.com&method=pop3&server=pop.yandex.ru&port=110&ssl=no&ext-login=NAME@MY_DOMAIN.com&ext-passwd=MY_PASSWORD&int-login=LOGIN_YANDEX_API&int-passwd=PASSWORD_YANDEX_API';

    $header = array("PddToken: MY_TOKEN");

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_ENCODING, "gzip");
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');

    $retValue = curl_exec($ch);
    $response = json_decode(curl_exec($ch));
    $ee       = curl_getinfo($ch);
    print_r($ee);

    print_r($retValue);
}

This the json that i get:

{"domain": "MY_DOMAIN.com", "success": "error", "error": "empty_import_list"}



THE DOCUMENTATION:

This is the documentation link, to the section regarding the import of a single mailbox.

https://tech.yandex.com/domain/doc/reference/import-start-one-docpage/



WORKING EXAMPLE:

This is an example of a working http request, which outcome is related to this issue. The function return the status of the import.

public function yandex_get_import_status()
{
    $url = 'https://pddimp.yandex.ru/api2/admin/import/check_imports?domain=MY_DOMAIN.com';

    $header = array("PddToken: MY_TOKEN");

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_ENCODING, "gzip");
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');

    $retValue = curl_exec($ch);
    $response = json_decode(curl_exec($ch));
    $ee       = curl_getinfo($ch);
    print_r($ee);

    print_r($retValue);
}

This is the output, in json format:

{"import": {"on_page": 10, "complete_box_count": 0, "failed_boxes_current_page": 1, "total_box_count": 0, "done_box_count": 0, "state": "no_import", "failed_boxes_count": 0, "total_message_count": 0, "failed_boxes_pages": 0, "page": 1, "failed_boxes": []}, "domain": "MY_DOMAIN.com", "progress_percent": 0, "success": "ok", "settings": {"port": 0, "ssl": "yes", "method": "", "server": ""}}



THE QUESTION:

How can i properly make the http request to import a single mailbox to the Yandex Mail for Domain API?

FrancescoMussi
  • 20,760
  • 39
  • 126
  • 178

0 Answers0