Overview
The Plugin Agency contact form requires several environment variables for email delivery and spam protection via Google reCAPTCHA. This guide covers all required and optional variables, plus setup instructions.Required Variables
EMAIL_USER
Description: Email account username for sending contact form submissions..env
EMAIL_PASS
Description: Email account password or app-specific password..env
VITE_RECAPTCHA_SITE_KEY
Description: Google reCAPTCHA v2 site key (public key)..env
Variables prefixed with
VITE_ are exposed to the browser. This is intentional for the site key (it’s public).RECAPTCHA_SECRET_KEY
Description: Google reCAPTCHA v2 secret key (private key)..env
Optional Variables
EMAIL_TO
Description: Comma-separated list of recipient email addresses..env
api/send-email.js
EMAIL_CC
Description: CC recipients for contact form emails (currently commented out)..env
api/send-email.js
Setup Guides
Gmail App Password Setup
Google requires app-specific passwords for third-party applications.Enable 2-Factor Authentication
- Go to Google Account Security
- Enable 2-Step Verification if not already enabled
- Complete the setup process
Generate App Password
- Go to App Passwords
- Select App: “Mail”
- Select Device: “Other (Custom name)”
- Enter name: “Plugin Agency Contact Form”
- Click Generate
Copy Password
Google will display a 16-character password:Copy this password (without spaces) to your
.env file:.env
reCAPTCHA Key Setup
Protect your contact form from spam with Google reCAPTCHA v2.Create reCAPTCHA Site
- Go to Google reCAPTCHA Admin
- Sign in with your Google account
- Fill out the registration form:
- Label: “Plugin Agency Contact Form”
- reCAPTCHA type: reCAPTCHA v2 → “I’m not a robot” Checkbox
- Domains:
localhost(for development)plugin.uy(your production domain)*.vercel.app(for Vercel preview deployments)
- Accept the Terms of Service
- Click Submit
Add to Environment
Add both keys to your
.env file:.env
The site key has the
VITE_ prefix (exposed to browser). The secret key does NOT (server-side only).How reCAPTCHA Works in the Code
How reCAPTCHA Works in the Code
Client-side (Contact.jsx):Server-side (api/send-email.js):
Email Configuration Details
The contact form uses Nodemailer with custom SMTP settings.SMTP Configuration
api/send-email.js
Using Gmail SMTP Instead
Using Gmail SMTP Instead
If you want to use Gmail’s SMTP server instead of a custom domain:Or with explicit settings:
Email Template
api/send-email.js
Security Best Practices
Never Commit Secrets
Add
.env* to .gitignore. Never commit API keys, passwords, or tokens to version control.Use App Passwords
For Gmail, always use app-specific passwords instead of your main account password.
Rotate Keys Regularly
Periodically regenerate reCAPTCHA keys and email passwords, especially after team changes.
Limit Domain Access
Configure reCAPTCHA to only work on your specific domains to prevent unauthorized use.
Vercel Configuration
For production deployment, add variables in Vercel:Add Each Variable
For each variable:
- Enter Key: e.g.,
EMAIL_USER - Enter Value: e.g.,
[email protected] - Select environments: Production, Preview, Development
- Click Save
Environment variables are encrypted at rest and in transit by Vercel. They are only decrypted during build and runtime.
Troubleshooting
Email not sending
Email not sending
Check:Check console for error messages.
EMAIL_USERandEMAIL_PASSare correctly set- App password is valid (not regular Gmail password)
- SMTP host and port are correct
- No firewall blocking port 465/587
reCAPTCHA validation failing
reCAPTCHA validation failing
Check:Should output the site key (not undefined).
- Both
VITE_RECAPTCHA_SITE_KEYandRECAPTCHA_SECRET_KEYare set - Keys match the reCAPTCHA version (v2)
- Domain is registered in reCAPTCHA admin
localhostis added for local development
Variables not loading in Vercel
Variables not loading in Vercel
Check:
- Variables are set for correct environment (Production/Preview)
- Site has been redeployed after adding variables
- Variable names match exactly (case-sensitive)
- No typos in variable values
VITE_ prefix confusion
VITE_ prefix confusion
Rule:
VITE_prefix = exposed to browser (public)- No prefix = server-side only (secret)
- ✅
VITE_RECAPTCHA_SITE_KEY- Safe to expose (public key) - ❌
VITE_RECAPTCHA_SECRET_KEY- NEVER expose (private key) - ✅
RECAPTCHA_SECRET_KEY- Correct (server-side only)
Example .env File
.env
Next Steps
Deployment Guide
Deploy to Vercel with environment variables
Contact Component
Learn how the contact form component works