Import Emails via IMAP Service
Spider command line tool spider-import supports importing emails via IMAP
service.
Command line arguments:
- 
--api-token: The API token.Please follow our tutorial API Tokens to either generate a new one, or use an existing one. Replace <api-token>by a real one in our sample commands below.
- 
--api-endpoint: [Optional] The endpoint of Spider web server, defaults tohttp://127.0.0.1:8080(it meansspider-importis running on Spider server locally).- 
API Endpoint is the URL of Spider web API interface, spider-importwill query it to verify whether email is duplicate, and submit for enqueue if it does not exist.
- 
If you already request free SSL cert on Spider web UI, Spider will redirect all http traffic to https, hence you must specify endpoint explicitly with https URL. For example, --api-endpoint https://your-server-name.com
 
- 
- 
--debug-imap(Introduced in v2.7.5): Turn on debug mode for IMAP. When enabled, it logs detailed IMAP session and raw email in log file/opt/spider/log/debug-imap.log.
- 
--disable-cert-verify: Disable ssl cert verification.If your IMAP server doesn't use a valid ssl cert, or you use IP address in --hostargument, please specify this argument to disable ssl cert verification.
- 
--dovecot-master-user: Dovecot Master User.
- 
--dovecot-master-password: Dovecot Master User's plain password.
- 
--host: The IMAP server address (IP address or FQDN hostname).Replace mail.example.comin our sample commands by your real IMAP server address.
- 
--imap-folder(Introduced in v2.3.0): Import from specified IMAP folder instead of all folders.- Currently only one folder name is supported.
- To import a sub-folder, please specify the full folder path. For example,
import sub-folder myfolderunderINBOX, use folder name"INBOX/myfolder"instead of"myfolder". Same to deeper folder likeINBOX/myfolder/3rdfolder, etc.
 
- 
--port: The port number IMAP service is listening on. Defaults to993.Do not forget to specify --sslor--tlsargument if secure connection is required.- Port 993usually uses SSL secure connection, use--sslin this case.
- Port 143usually uses TLS / STARTTLS secure connection, use--tlsin this case.
 
- Port 
- 
--ssl(introduced in v2.6.1): Use SSL secure connection.
- 
--tls(introduced in v2.6.1): Use TLS secure connection.
- 
--user-pw-file: Specify a text file which contains users and plain passwords. One username and one password per line, separated by a whitespace.
- 
--user-file: Specify a text file which contains users' login usernames (Note: no passwords). Usually used with an IMAP master user account.
- 
-vor--verbose: Enable verbose logging.
Sample usages.
Import with end users' usernames and (plain) passwords
Save the usernames and plain passwords in a text file named user-passwords.txt
in certain format:
- one username and one password per line
- username and password must be separated by one or multiple whitespaces
For example:
user-1@domain.com plain-password-1
user-2@domain.com plain-password-2
Import emails with the text file:
spider-import imap \
    --api-token <api-token> \
    --host mail.example.com \
    --port 993 \
    --user-pw-file user-passwords.txt
Import with an IMAP master / admin account
Usually IMAP server (like Dovecot) has a master admin account which has privilege to access all users' mailboxes without knowing users' plain password. We use Dovecot Master User for example here.
If you're running an iRedMail server, please check its official document: Dovecot Master User: Access user's mailbox without owner's password..
Save the usernames in a plain text file named users.txt, one login username
per line, then import with argument --user-file:
spider-import imap \
    --api-token <api-token> \
    --host mail.example.com \
    --port 993 \
    --dovecot-master-user 'master-user' \
    --dovecot-master-password 'master-password' \
    --user-file users.txt