Skip to content

Wait Command

The wait command blocks until an email matching your criteria arrives. It’s designed for CI/CD pipelines and automated testing scenarios where you need to verify email delivery.

Wait for an email matching specified criteria.

Terminal window
vsb email wait [flags]
FlagDescriptionDefault
--inboxInbox to watch (uses active inbox if omitted)-
--timeoutMaximum time to wait60s
--subjectMatch exact subject-
--subject-regexMatch subject with regex-
--fromMatch exact sender-
--from-regexMatch sender with regex-
--countNumber of emails to wait for1
-q, --quietSuppress output, only set exit code-
--extract-linkOutput matching link from email-
-o, --outputOutput format: pretty or jsonpretty
CodeMeaning
0Email(s) found successfully
1Timeout or error (connection, auth, etc.)
Terminal window
# Wait for any email (60s timeout)
vsb email wait
# Wait with longer timeout
vsb email wait --timeout 120s
# Wait for specific subject
vsb email wait --subject "Password Reset"
# Wait for subject matching pattern
vsb email wait --subject-regex "Reset|Verify"
Terminal window
# Exact sender match
vsb email wait --from "[email protected]"
# Sender pattern match
vsb email wait --from-regex "@myapp\\.com$"
Terminal window
# Combine subject and sender filters
vsb email wait --subject-regex "Password" --from "[email protected]"
# Wait for multiple emails
vsb email wait --count 2 --subject "Order Confirmation"
Terminal window
# Get email details as JSON
vsb email wait --subject "Verify" -o json

Output:

{
"id": "e1a2b3",
"subject": "Verify your email",
"from": "[email protected]",
"to": ["[email protected]"],
"text": "Click here to verify...",
"html": "<html>...",
"links": ["https://myapp.com/verify?token=abc123"],
"headers": {
"Content-Type": "text/html; charset=utf-8",
"X-Mailer": "MyApp/1.0"
},
"receivedAt": "2024-01-15T14:35:00Z"
}
Terminal window
# Extract first link from matching email
LINK=$(vsb email wait --subject-regex "Reset" --extract-link)
echo "Reset link: $LINK"
name: Email Tests
on: [push]
jobs:
test-password-reset:
runs-on: ubuntu-latest
steps:
- name: Install vsb-cli
run: |
curl -LO https://github.com/vaultsandbox/vsb-cli/releases/latest/download/vsb_linux_amd64.tar.gz
tar -xzf vsb_linux_amd64.tar.gz
sudo mv vsb /usr/local/bin/
- name: Configure CLI
run: |
vsb config set api_key "${{ secrets.VSB_API_KEY }}"
vsb config set url "${{ secrets.VSB_URL }}"
- name: Test password reset flow
run: |
# Create inbox and capture email address
EMAIL=$(vsb inbox create --json | jq -r '.email')
# Trigger password reset in your app
curl -X POST https://myapp.com/api/reset-password \
-H "Content-Type: application/json" \
-d "{\"email\": \"$EMAIL\"}"
# Wait for reset email and extract link
RESET_LINK=$(vsb email wait \
--subject-regex "Reset" \
--timeout 30s \
-o json | jq -r '.links[0]')
# Verify the link works
curl -I "$RESET_LINK" | grep "200 OK"
test-email-verification:
image: golang:1.24
script:
- go install github.com/vaultsandbox/vsb-cli/cmd/vsb@latest
- vsb config set api_key "$VSB_API_KEY"
- vsb config set url "$VSB_URL"
- |
EMAIL=$(vsb inbox create --json | jq -r '.email')
# Trigger your application to send verification email
./run-signup-flow.sh "$EMAIL"
# Wait and verify
vsb email wait --subject "Verify" --timeout 60s
echo "Verification email received!"
#!/bin/bash
set -e
# Create test inbox
INBOX=$(vsb inbox create --json)
EMAIL=$(echo "$INBOX" | jq -r '.email')
echo "Testing with inbox: $EMAIL"
# Trigger your application
curl -X POST "https://myapp.com/api/invite" \
-d "email=$EMAIL"
# Wait for invitation email
if vsb email wait --subject "Invitation" --timeout 30s --quiet; then
echo "✓ Invitation email received"
else
echo "✗ Invitation email not received"
exit 1
fi
# Get the invitation link
INVITE_LINK=$(vsb email url --json | jq -r '.[0]')
echo "Invitation link: $INVITE_LINK"
# Cleanup
vsb inbox delete "$EMAIL" --force
  • Use --quiet in scripts when you only care about the exit code
  • Use --json output with jq to extract specific fields
  • Set reasonable timeouts based on your email delivery expectations
  • Use regex patterns for flexible matching when subject lines vary
  • Combine wait with email url --open to manually verify links