This guide will help you deploy your blog with email notifications on Vercel.
- Push your code to GitHub
- Connect to Vercel: Go to vercel.com and import your repository
- Deploy: Vercel will automatically deploy your React app
- Go to your Vercel project dashboard
- Navigate to Settings → Environment Variables
- Add these environment variables:
# Gmail SMTP Configuration
REACT_APP_GMAIL_USER=phcoder.blog@gmail.com
REACT_APP_GMAIL_APP_PASSWORD=your-16-character-app-password
# Optional: SendGrid Configuration (for production)
REACT_APP_SENDGRID_API_KEY=your-sendgrid-api-key
REACT_APP_SENDGRID_FROM_EMAIL=phcoder.blog@gmail.com-
Install Vercel CLI:
npm i -g vercel
-
Login to Vercel:
vercel login
-
Add environment variables:
vercel env add REACT_APP_GMAIL_USER vercel env add REACT_APP_GMAIL_APP_PASSWORD vercel env add REACT_APP_SENDGRID_API_KEY
-
Enable 2-Factor Authentication on your Gmail account
-
Generate App Password:
- Go to: https://myaccount.google.com/apppasswords
- Select Mail as the app
- Select Other (Custom name)
- Enter name: "PHcoder Blog Vercel"
- Click Generate
- Copy the 16-character password
-
Add to Vercel:
- Go to your Vercel project → Settings → Environment Variables
- Add
REACT_APP_GMAIL_APP_PASSWORDwith your app password
- Visit your deployed blog
- Subscribe to newsletter with a test email
- Check if welcome email is received
- Login to admin dashboard
- Create a new blog post
- Check if subscribers receive notifications
- Go to your Vercel project
- Navigate to Functions → Logs
- Look for email sending logs
- Open browser developer tools
- Check console for email logs
- Look for success/error messages
-
Check Environment Variables:
- Verify all variables are set in Vercel
- Make sure variable names start with
REACT_APP_
-
Check Gmail App Password:
- Ensure 2FA is enabled
- Verify app password is correct
- Check Gmail account settings
-
Check Vercel Logs:
- Look for error messages
- Verify function execution
- "Invalid credentials": Double-check app password
- "Environment variable not found": Restart deployment
- "Function timeout": Check email service configuration
| Variable | Description | Required | Example |
|---|---|---|---|
REACT_APP_GMAIL_USER |
Gmail address for sending emails | ✅ | phcoder.blog@gmail.com |
REACT_APP_GMAIL_APP_PASSWORD |
Gmail app password | ✅ | abcd efgh ijkl mnop |
REACT_APP_SENDGRID_API_KEY |
SendGrid API key (optional) | ❌ | SG.xxx... |
REACT_APP_SENDGRID_FROM_EMAIL |
SendGrid sender email | ❌ | phcoder.blog@gmail.com |
- Never commit environment variables to Git
- Use app passwords instead of regular passwords
- Rotate app passwords regularly
- Monitor email sending for abuse
- Set up email delivery monitoring
- Use SendGrid instead of Gmail SMTP
- Set up email analytics
- Monitor delivery rates
- Implement rate limiting
- Verify your domain with email providers
- Set up SPF/DKIM records
- Monitor spam complaints
- Use professional email templates
- Vercel deployment successful
- Environment variables configured
- Gmail app password generated
- Welcome emails working
- Blog notifications working
- Unsubscribe emails working
- Admin dashboard accessible
- Email logs visible in Vercel
Your blog is now ready to send professional email notifications to subscribers! 🎉