https://github.com/mailslurp/examples
if [ -z "$API_KEY" ]
then
echo "Please set the API_KEY environment variable."
exit 1
fi
curl -sLo .env "https://api.mailslurp.com/inboxes/imap-smtp-access/env?apiKey=$API_KEY"
if ([string]::IsNullOrEmpty($env:API_KEY)) {
Write-Host "Please set the API_KEY environment variable."
exit 1
}
Invoke-WebRequest -Uri "https://api.mailslurp.com/inboxes/imap-smtp-access/env?apiKey=$env:API_KEY" -OutFile ".env"
#!/bin/bash
# Load the .env file
echo "Loading the .env file..."
source .env
# Connect to the mail server and list unread emails
echo "Connecting to the mail server and listing unread emails..."
curl -v --insecure -u $IMAP_USERNAME:$IMAP_PASSWORD --url "imap://$IMAP_SERVER_HOST:$IMAP_SERVER_PORT/INBOX" -X 'SEARCH UNSEEN'
# Fetch the first email and print its subject
echo "Fetching the first email and printing its subject..."
curl -v --insecure -u $IMAP_USERNAME:$IMAP_PASSWORD --url "imap://$IMAP_SERVER_HOST:$IMAP_SERVER_PORT/INBOX;UID=1" -X 'FETCH 1 BODY[HEADER.FIELDS (SUBJECT)]'
# IMAP & SMTP Examples
Examples that demonstrate usage of IMAP and SMTP endpoints in MailSlurp using common tools and languages.
## Credentials
Examples require a MailSlurp API key. Set this in your environment as API_KEY or create a `.env` file containing `API_KEY=YOUR_MAILSLURP_API_KEY`.
Some examples also need to load IMAP and SMTP access credentials. Run the setup scripts to add these credentials to your `.env` file or see the `.env.sample` file and copy those into your `.env` with correct values.
See https://docs.mailslurp.com/api/#getImapSmtpAccess
IMAP_MAILBOX=""
IMAP_PASSWORD=""
IMAP_SERVER_HOST=""
IMAP_SERVER_PORT=""
IMAP_USERNAME=""
MAIL_FROM_DOMAIN=""
SECURE_SMTP_PASSWORD=""
SECURE_SMTP_SERVER_HOST=""
SECURE_SMTP_SERVER_PORT=""
SECURE_SMTP_USERNAME=""
SMTP_PASSWORD=""
SMTP_SERVER_HOST=""
SMTP_SERVER_PORT=""
SMTP_USERNAME=""