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.
vsb email wait
Section titled “vsb email wait”Wait for an email matching specified criteria.
vsb email wait [flags]| Flag | Description | Default |
|---|---|---|
--inbox | Inbox to watch (uses active inbox if omitted) | - |
--timeout | Maximum time to wait | 60s |
--subject | Match exact subject | - |
--subject-regex | Match subject with regex | - |
--from | Match exact sender | - |
--from-regex | Match sender with regex | - |
--count | Number of emails to wait for | 1 |
-q, --quiet | Suppress output, only set exit code | - |
--extract-link | Output matching link from email | - |
-o, --output | Output format: pretty or json | pretty |
Exit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
0 | Email(s) found successfully |
1 | Timeout or error (connection, auth, etc.) |
Examples
Section titled “Examples”Basic Usage
Section titled “Basic Usage”# Wait for any email (60s timeout)vsb email wait
# Wait with longer timeoutvsb email wait --timeout 120s
# Wait for specific subjectvsb email wait --subject "Password Reset"
# Wait for subject matching patternvsb email wait --subject-regex "Reset|Verify"Filtering by Sender
Section titled “Filtering by Sender”# Exact sender match
# Sender pattern matchvsb email wait --from-regex "@myapp\\.com$"Multiple Conditions
Section titled “Multiple Conditions”# Combine subject and sender filters
# Wait for multiple emailsvsb email wait --count 2 --subject "Order Confirmation"JSON Output
Section titled “JSON Output”# Get email details as JSONvsb email wait --subject "Verify" -o jsonOutput:
{ "id": "e1a2b3", "subject": "Verify your email", "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"}Extract Links
Section titled “Extract Links”# Extract first link from matching emailLINK=$(vsb email wait --subject-regex "Reset" --extract-link)echo "Reset link: $LINK"CI/CD Integration
Section titled “CI/CD Integration”GitHub Actions
Section titled “GitHub Actions”name: Email Testson: [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"GitLab CI
Section titled “GitLab CI”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!"Shell Script
Section titled “Shell Script”#!/bin/bashset -e
# Create test inboxINBOX=$(vsb inbox create --json)EMAIL=$(echo "$INBOX" | jq -r '.email')
echo "Testing with inbox: $EMAIL"
# Trigger your applicationcurl -X POST "https://myapp.com/api/invite" \ -d "email=$EMAIL"
# Wait for invitation emailif vsb email wait --subject "Invitation" --timeout 30s --quiet; then echo "✓ Invitation email received"else echo "✗ Invitation email not received" exit 1fi
# Get the invitation linkINVITE_LINK=$(vsb email url --json | jq -r '.[0]')echo "Invitation link: $INVITE_LINK"
# Cleanupvsb inbox delete "$EMAIL" --force- Use
--quietin scripts when you only care about the exit code - Use
--jsonoutput withjqto extract specific fields - Set reasonable timeouts based on your email delivery expectations
- Use regex patterns for flexible matching when subject lines vary
- Combine
waitwithemail url --opento manually verify links
Next Steps
Section titled “Next Steps”- Export/Import - Save and restore inboxes
- Email Commands - Inspect emails after they arrive
- Inbox Commands - Manage test inboxes