Import multiple mailboxes

This request is used for importing messages from multiple mailboxes to Yandex.Mail for Domain. For the import, you must include:
  • Connection settings for the server source that Yandex.Mail for Domain should use. You can check the validity of the settings using a separate request.

    If the connection cannot be made using the settings you pass, Yandex.Mail for Domain will keep repeating the connection attempt for a long time without returning errors.

  • A file with a list of usernames and passwords of the mailboxes to import.
During the import, new mailboxes are created on Yandex.Mail for the domain. This means their usernames and passwords must meet the Yandex requirements:
  • The username must:
    • must contain only Latin letters, numbers, dashes, or dots.

    • start with a letter, end with a letter or number, and be no longer than 30 characters.

  • The password must:
    • contain from 6 to 20 characters — Latin letters, numbers, and the symbols “!”, “@”, “#”, “$”, “%”, “^”, “&”, “*”, “(”, “)”, “_”, “-”, “+”, “:”, “;”, “,”, “.”

    • be different from the username.

If the username or password on the server source does not meet the Yandex requirements, you should specify a new one.

  1. Request syntax
  2. Request example
  3. Response structure

Request syntax

The request should be sent over the HTTPS protocol using the POST method with the content type multipart/form-data.

POST /api2/admin/import/start_import_file?
domain=<mail domain name>
&method=<server protocol>
&server=<server name>
&port=<server port>
&ssl=<SSL usage>

Host: pddimp.yandex.ru
Accept: */*
PddToken: <PDD token>
Content-Type: multipart/form-data; boundary=---------------some-boundary-string-of-your-choice
---------------some-boundary-string-of-your-choice
Content-Disposition: form-data; name="file"; filename="import_list_file"

<file contents — list of mailbox usernames and passwords>
---------------some-boundary-string-of-your-choice

Headers:

NameDescription
PddToken

PDD token.

Content-Type

Specify the type multipart/form-data in this header.

Content-Disposition

Specify the filename parameter with the value import_list_file and the file content (the list of mailbox usernames and passwords).

Each line of the file must contain the username and password of a single mailbox, separated by a space. A password on the server source that contains spaces must be enclosed in quotation marks ("):

login1 "pas sword1"
...
login10 password10

If the username or password on the server source does not meet the Yandex requirements, you should specify a new one in the line in the file, in the following format:

existing_login1 "existing password1" existing_login1 new_password1
...
existing_login10 "existing password10" new_login10 new_password10

Parameters:

ParameterTypeValue
Mandatory
domainString

Name of the domain.

serverString

Server's domain name or IP address.

portInteger

Server port.

methodString

Server protocol.

Possible values:
  • imap

  • imap4

  • pop

  • pop3

sslString

Use of SSL.

Possible values:
  • yes — SSL connection required.
  • no — SSL should not be used.

Request example

POST /api2/admin/import/start_import_file?domain=domain.com&method=pop&server=pop.yandex.ru&port=110&ssl=no HTTP/1.1

Host: pddimp.yandex.ru
Accept: */*
PddToken: 123456789ABCDEF0000000000000000000000000000000000000
Content-Type: multipart/form-data; boundary=----------------------------60f093b65ad7
----------------------------60f093b65ad7
Content-Disposition: form-data; name="file"; filename="import_list_file"
Content-Type: text/plain

external_login1 external_password1
external_login2 external_password2
external_login3
external_login4 external_password4 internal_login4 internal_password4
----------------------------60f093b65ad7
cURL
curl -H 'PddToken: 123456789ABCDEF0000000000000000000000000000000000000' -F 'import_list_file=@importfilename' 'https://pddimp.yandex.ru/api2/admin/import/start_import_file?domain=domain.name&method=pop&server=pop.yandex.ru&port=110&ssl=no'

Response structure

{
  "domain": "{mail domain name}",
  "settings":
    {
      "method": "{server protocol}",
      "server": "{server name}",
      "port": "{server port}",
      "ssl": "{SSL usage}"
    },
  "import_list":
  [
    {
      "external_login": "{username on source server}",
      "external_password": "{password on source server}",
      "internal_login": "{username on Yandex.Mail for Domain}",
      "internal_password": "{password on Yandex.Mail for Domain}",
      "started": "{ready to start import}"
    },
    ...
  ]
  "success": "{status of request execution}"
}
NameType of valueDescription
domainString

Name of the domain.

settingsObject

Server source settings.

import_ listArray

Mailbox authentication data. Each object in the array corresponds to a single mailbox.

successString

Status of request execution.

Possible values:
  • ok — Request executed successfully.
  • error — Request executed with error.
errorString

Error code.

Included in the response if the request resulted in an error.

Possible values:
  • unknown — A temporary failure or API error occurred (repeat the request again later).
  • no_token (no_domain, no_ip ) — A mandatory parameter was omitted.
  • bad_domain — The domain name was not specified or does not conform to the RFC.
  • prohibited — A forbidden domain name.
  • bad_token (bad_login, bad_passwd) — An invalid PDD token (or username/password) was passed.
  • no_auth — The PddToken header was omitted.
  • not_allowed — This operation is not allowed for this user (the user is not the domain administrator).
  • blocked — Blocked domain (for example, due to spam and so on).
  • occupied — The domain name is in use by another user.
  • domain_limit_reached — Exceeded the acceptable number of connected domains (50).
  • no_reply — Yandex.Mail for Domain cannot connect to the server source for the import.
Keys for the settings object
methodString

Server protocol.

Possible values:
  • imap

  • imap4

  • pop

  • pop3

serverString

Server's domain name or IP address.

portInteger

Server port.

sslString

Use of SSL.

Possible values:
  • yes — SSL connection required.
  • no — SSL should not be used.
Keys for objects in the import_list array
external_loginString

Username on the server source.

external_passwordString

Password on the server source.

internal_loginString

Username for authenticating on Yandex.Mail for Domain.

internal_passwordString

Password for authenticating on Yandex.Mail for Domain.

startedString

Ready to start importing.

Possible values:
  • yes — Import will be launched (all parameters are valid).
  • no — Import will not be launched (an error was detected and its code is indicated in the value of the error key).