-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathimap-example.sh
More file actions
executable file
·21 lines (17 loc) · 957 Bytes
/
imap-example.sh
File metadata and controls
executable file
·21 lines (17 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash
# get an inbox with smtp/imap capabilties
INBOX=$(curl -sXGET "https://api.mailslurp.com/inboxes/paginated?size=1&inboxType=SMTP_INBOX" -Hx-api-key:$API_KEY)
# get inbox imap access details
ACCESS=$(curl -sXGET "https://api.mailslurp.com/inboxes/imap-smtp-access" -Hx-api-key:$API_KEY)
# set vars for imap expect
export ADDRESS=$(echo $INBOX | jq -j '.content[0].emailAddress')
export USERNAME=$(echo "$ACCESS" | jq -j '.imapUsername')
export PASSWORD=$(echo "$ACCESS" | jq -j '.imapPassword')
export PORT=$(echo "$ACCESS" | jq -j '.imapServerPort')
export HOST=$(echo "$ACCESS" | jq -j '.imapServerHost')
auth_string="\0$USERNAME\0$PASSWORD"
export AUTH_PLAIN=$(echo -ne "$auth_string" | base64)
# send a message to the inbox
curl -XPOST "https://api.mailslurp.com/sendEmailQuery?to=$ADDRESS&body=Hello&subject=Test" -Hx-api-key:$API_KEY
# execute the expect test to connect to the server using the set variables
./imap-example.exp