-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathsmtp-http-example.sh
More file actions
executable file
·22 lines (20 loc) · 1.04 KB
/
smtp-http-example.sh
File metadata and controls
executable file
·22 lines (20 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash
# get an inbox with smtp/imap capabilties
INBOX_TYPE="HTTP_INBOX"
INBOX=$(curl -sXPOST "https://api.mailslurp.com/inboxes?inboxType=$INBOX_TYPE&expiresIn=300000" -H"x-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 '.emailAddress')
INBOX_ID=$(echo $INBOX | jq -j '.id')
export USERNAME=$(echo "$ACCESS" | jq -j '.smtpUsername')
export PASSWORD=$(echo "$ACCESS" | jq -j '.smtpPassword')
export PORT=$(echo "$ACCESS" | jq -j '.smtpServerPort')
export HOST=$(echo "$ACCESS" | jq -j '.smtpServerHost')
auth_string="\0$USERNAME\0$PASSWORD"
base64_auth=$(echo -ne "$auth_string" | base64)
auth_plain_command="AUTH PLAIN $base64_auth"
export USERNAME_PASSWORD_BASE64=$base64_auth
# execute the expect test to connect to the server using the set variables
./smtp-example.exp
curl -v -XGET "https://api.mailslurp.com/waitForLatestEmail?inboxId=$INBOX_ID&unreadOnly=true&apiKey=$API_KEY"