This guide will help you set up EmailJS to enable real email sending from the contact form in your portfolio.
EmailJS is a service that allows you to send emails directly from the frontend without needing a backend server. Perfect for static websites and portfolios!
- Go to EmailJS.com
- Sign up for a free account
- Verify your email address
- In your EmailJS dashboard, go to "Email Services"
- Click "Add New Service"
- Choose your email provider (Gmail, Outlook, Yahoo, etc.)
- Follow the authentication steps to connect your email account
- Note down the Service ID (e.g.,
service_abc123)
- Go to "Email Templates"
- Click "Create New Template"
- Use this template structure:
Subject: New Portfolio Contact from {{from_name}}
Hi Involvex,
You have received a new message from your portfolio contact form:
👤 Contact Details:
• Name: {{from_name}}
• Email: {{from_email}}
• Discord: {{discord_name}}
📝 Message:
{{message}}
---
This message was sent from your portfolio website.
- Note down the Template ID (e.g.,
template_xyz789)
- Go to "Account" → "General"
- Copy your "Public Key" (e.g.,
user_def456)
-
Copy the
.env.examplefile to.env:cp .env.example .env
-
Edit the
.envfile and replace the placeholder values:VITE_EMAILJS_SERVICE_ID=service_abc123 VITE_EMAILJS_TEMPLATE_ID=template_xyz789 VITE_EMAILJS_PUBLIC_KEY=user_def456
-
Start your development server:
npm run dev
-
Go to the contact section of your portfolio
-
Fill out the form and submit
-
Check your email for the test message
EmailJS free plan includes:
- 200 emails per month
- 50 emails per day
- Unlimited email templates
-
"Failed to send message" error
- Check that your environment variables are correctly set
- Verify your email service is properly connected
- Ensure your template ID is correct
-
Template variables not working
- Make sure your template uses the exact variable names:
{{from_name}},{{from_email}},{{discord_name}},{{message}} - Check that the template is saved and published
- Make sure your template uses the exact variable names:
-
Authentication issues
- Reconnect your email service in the EmailJS dashboard
- Check if your email provider requires app-specific passwords
To enable debug logging, add this to your .env file:
VITE_EMAILJS_DEBUG=trueIf you prefer not to use EmailJS, consider these alternatives:
- Formspree: Simple form handling service
- Netlify Forms: If deploying to Netlify
- Getform: Another form backend service
- Direct SMTP: Using nodemailer with a backend
- Never expose your EmailJS private keys (only public keys are safe for frontend)
- The free plan has rate limiting to prevent abuse
- Consider implementing CAPTCHA for production use
- Monitor your email sending to stay within limits
Note: This setup enables real email sending from your portfolio. Make sure to test thoroughly and monitor your usage to stay within the free plan limits.