diff --git a/curl/.gitignore b/curl/.gitignore
new file mode 100644
index 00000000..4c49bd78
--- /dev/null
+++ b/curl/.gitignore
@@ -0,0 +1 @@
+.env
diff --git a/curl/smtp-imap.sh b/curl/smtp-imap.sh
index 5abe5ce7..dce3e9fc 100755
--- a/curl/smtp-imap.sh
+++ b/curl/smtp-imap.sh
@@ -1,10 +1,55 @@
#!/usr/bin/env bash
+set -e
+error_handling() {
+ echo "ERROR occurred"
+ exit 1
+}
+
+trap 'error_handling' ERR
+inboxId=$(curl -sXPOST "https://api.mailslurp.com/inboxes?inboxType=SMTP_INBOX" -H"x-api-key:$API_KEY" | jq -r '.id')
+#curl_get_imap_inbox_access_env
+# download access details for an inbox as .env file and source
+curl -o .env -sXGET "https://api.mailslurp.com/inboxes/imap-smtp-access/env?inboxId=$inboxId" -H"x-api-key:$API_KEY"
+# source the .env and connect using variables
+source .env && curl -u "$IMAP_USERNAME:$IMAP_PASSWORD" \
+ "imap://$IMAP_SERVER_HOST:$IMAP_SERVER_PORT/$IMAP_MAILBOX" -X "SEARCH UNSEEN"
+#
+# assert .env contains IMAP_USERNAME=...
+grep IMAP_USERNAME .env
#curl_get_imap_smtp
# get imap and smtp access details for your account
-curl -XGET "https://api.mailslurp.com/inboxes/imap-smtp-access" -Hx-api-key:$API_KEY
+curl -sXGET "https://api.mailslurp.com/inboxes/imap-smtp-access" -H"x-api-key:$API_KEY"
#
#curl_get_imap_username
# get username etc
-curl -XGET "https://api.mailslurp.com/inboxes/imap-smtp-access" \
- -Hx-api-key:$API_KEY | jq -j '.imapUsername'
+curl -sXGET "https://api.mailslurp.com/inboxes/imap-smtp-access" \
+ -H"x-api-key:$API_KEY" | jq -j '.imapUsername'
+#
+#curl_get_smtp
+# get imap and smtp access details for your account
+curl -sXGET "https://api.mailslurp.com/inboxes/smtp-access" -H"x-api-key:$API_KEY"
+#
+#curl_get_smtp_username
+curl -sXGET "https://api.mailslurp.com/inboxes/smtp-access" \
+ -H"x-api-key:$API_KEY" | jq -j '.smtpUsername'
+#
+#curl_get_smtp_password
+curl -sXGET "https://api.mailslurp.com/inboxes/smtp-access" \
+ -H"x-api-key:$API_KEY" | jq -j '.smtpPassword'
+#
+#curl_get_imap
+# get imap access details for your account
+curl -sXGET "https://api.mailslurp.com/inboxes/imap-access" -H"x-api-key:$API_KEY"
+#
+#curl_get_imap_inbox_access
+# get imap access for specific inbox
+curl -sXGET "https://api.mailslurp.com/inboxes/imap-access?inboxId=$inboxId" -H"x-api-key:$API_KEY"
+#
+#curl_get_imap_username
+curl -sXGET "https://api.mailslurp.com/inboxes/imap-access" \
+ -H"x-api-key:$API_KEY" | jq -j '.imapUsername'
+#
+#curl_get_imap_password
+curl -sXGET "https://api.mailslurp.com/inboxes/imap-access" \
+ -H"x-api-key:$API_KEY" | jq -j '.imapPassword'
#