EmailVerify LogoEmailVerify

OpenCode

Email checker with OpenCode CLI. Verify emails in OpenCode AI assistant.

OpenCode is an open-source AI coding assistant for the terminal. Learn how to use EmailVerify for email verification in your OpenCode workflows.

What is OpenCode?

OpenCode is a community-driven, open-source AI coding assistant that provides:

  • Natural language code generation
  • Shell command execution
  • Code review and debugging
  • Integration with local and cloud LLMs

Setup

Install EmailVerify CLI

npm install -g @emailverify/cli
bv config set api-key YOUR_API_KEY

Configure Environment

Add to your shell configuration:

export EMAILVERIFY_API_KEY=your-api-key

Usage with OpenCode

Basic Verification

You: Verify if user@company.com is a valid email using the bv command

OpenCode:

I'll run the EmailVerify CLI to check that email.

$ bv verify user@company.com

Email: user@company.com
Status: valid
Score: 0.92
Deliverable: yes
Disposable: no
Role: no

The email is valid and safe to use.

Generate Verification Code

You: Create a TypeScript function to verify emails with EmailVerify

OpenCode:

async function verifyEmail(email: string): Promise<VerificationResult> {
  const response = await fetch('https://api.emailverify.ai/v1/verify', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.EMAILVERIFY_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ email }),
  });

  if (!response.ok) {
    throw new Error(`Verification failed: ${response.statusText}`);
  }

  return response.json();
}

interface VerificationResult {
  email: string;
  status: 'valid' | 'invalid' | 'unknown';
  score: number;
  result: {
    deliverable: boolean;
    disposable: boolean;
    role: boolean;
  };
}

Data Processing

You: Write a script to clean up my user database by verifying all emails

OpenCode:

#!/usr/bin/env python3
"""
Clean user database by verifying email addresses.
Moves invalid emails to a separate table for review.
"""
import os
import requests
import sqlite3
from typing import List, Tuple

API_KEY = os.environ['EMAILVERIFY_API_KEY']
API_URL = 'https://api.emailverify.ai/v1/verify'

def verify_email(email: str) -> dict:
    """Verify a single email address."""
    response = requests.post(
        API_URL,
        headers={
            'Authorization': f'Bearer {API_KEY}',
            'Content-Type': 'application/json',
        },
        json={'email': email}
    )
    return response.json()

def process_users(db_path: str) -> Tuple[int, int, int]:
    """Process all users and categorize by email validity."""
    conn = sqlite3.connect(db_path)
    cursor = conn.cursor()

    # Create table for invalid emails if not exists
    cursor.execute('''
        CREATE TABLE IF NOT EXISTS invalid_emails (
            user_id INTEGER,
            email TEXT,
            reason TEXT,
            verified_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
        )
    ''')

    # Get all users
    cursor.execute('SELECT id, email FROM users')
    users = cursor.fetchall()

    valid = 0
    invalid = 0
    unknown = 0

    for user_id, email in users:
        result = verify_email(email)

        if result['status'] == 'valid':
            valid += 1
        elif result['status'] == 'invalid':
            invalid += 1
            cursor.execute(
                'INSERT INTO invalid_emails (user_id, email, reason) VALUES (?, ?, ?)',
                (user_id, email, 'invalid')
            )
        else:
            unknown += 1

        # Rate limiting
        import time
        time.sleep(0.1)

    conn.commit()
    conn.close()

    return valid, invalid, unknown

if __name__ == '__main__':
    valid, invalid, unknown = process_users('users.db')
    print(f'Results: {valid} valid, {invalid} invalid, {unknown} unknown')

CI/CD Integration

You: Add email verification to my GitHub Actions workflow

OpenCode:

# .github/workflows/verify-test-emails.yml
name: Verify Test Emails

on:
  pull_request:
    paths:
      - 'test/**'
      - 'fixtures/**'

jobs:
  verify-emails:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install EmailVerify CLI
        run: npm install -g @emailverify/cli

      - name: Extract and verify emails
        env:
          EMAILVERIFY_API_KEY: ${{ secrets.EMAILVERIFY_API_KEY }}
        run: |
          # Find all email addresses in test files
          emails=$(grep -rhoE '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' test/ fixtures/ | sort -u)

          echo "Found emails to verify:"
          echo "$emails"

          # Verify each email
          failed=0
          for email in $emails; do
            # Skip example.com and test domains
            if [[ "$email" =~ @(example\.(com|org|net)|test\.com)$ ]]; then
              echo "⏭️ Skipping test domain: $email"
              continue
            fi

            result=$(bv verify "$email" --json 2>/dev/null)
            status=$(echo "$result" | jq -r '.status')

            if [ "$status" = "valid" ]; then
              echo "⚠️ Real email found in tests: $email"
              failed=1
            fi
          done

          if [ $failed -eq 1 ]; then
            echo "::error::Real email addresses found in test files!"
            exit 1
          fi

          echo "✅ No real emails in test files"

Automation Recipes

Batch Processing Script

#!/bin/bash
# verify-list.sh - Verify a list of emails and output results as CSV

input_file="${1:-emails.txt}"
output_file="${2:-results.csv}"

echo "email,status,score,disposable,role" > "$output_file"

while IFS= read -r email; do
    [ -z "$email" ] && continue

    result=$(bv verify "$email" --json 2>/dev/null)

    status=$(echo "$result" | jq -r '.status')
    score=$(echo "$result" | jq -r '.score')
    disposable=$(echo "$result" | jq -r '.result.disposable')
    role=$(echo "$result" | jq -r '.result.role')

    echo "$email,$status,$score,$disposable,$role" >> "$output_file"

    # Progress indicator
    echo -n "."
done < "$input_file"

echo ""
echo "Results saved to $output_file"

Webhook Handler

// webhook-handler.js - Verify emails from webhook events

const express = require('express');
const app = express();

app.use(express.json());

app.post('/webhook/new-signup', async (req, res) => {
  const { email, userId } = req.body;

  // Verify the email
  const verifyResponse = await fetch('https://api.emailverify.ai/v1/verify', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.EMAILVERIFY_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ email }),
  });

  const result = await verifyResponse.json();

  if (result.status === 'invalid' || result.result.disposable) {
    // Flag the user for review
    console.log(`Flagged user ${userId}: ${email} - ${result.status}`);
    // await flagUser(userId, 'suspicious_email');
  }

  res.json({ verified: true, result });
});

app.listen(3000);

Next Steps

On this page