|
| 1 | +# EmailJS Setup Guide for Contact Form |
| 2 | + |
| 3 | +This guide will help you set up EmailJS to enable real email sending from the contact form in your portfolio. |
| 4 | + |
| 5 | +## What is EmailJS? |
| 6 | + |
| 7 | +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! |
| 8 | + |
| 9 | +## Setup Instructions |
| 10 | + |
| 11 | +### Step 1: Create EmailJS Account |
| 12 | + |
| 13 | +1. Go to [EmailJS.com](https://www.emailjs.com/) |
| 14 | +2. Sign up for a free account |
| 15 | +3. Verify your email address |
| 16 | + |
| 17 | +### Step 2: Add Email Service |
| 18 | + |
| 19 | +1. In your EmailJS dashboard, go to **"Email Services"** |
| 20 | +2. Click **"Add New Service"** |
| 21 | +3. Choose your email provider (Gmail, Outlook, Yahoo, etc.) |
| 22 | +4. Follow the authentication steps to connect your email account |
| 23 | +5. **Note down the Service ID** (e.g., `service_abc123`) |
| 24 | + |
| 25 | +### Step 3: Create Email Template |
| 26 | + |
| 27 | +1. Go to **"Email Templates"** |
| 28 | +2. Click **"Create New Template"** |
| 29 | +3. Use this template structure: |
| 30 | + |
| 31 | +``` |
| 32 | +Subject: New Portfolio Contact from {{from_name}} |
| 33 | +
|
| 34 | +Hi Involvex, |
| 35 | +
|
| 36 | +You have received a new message from your portfolio contact form: |
| 37 | +
|
| 38 | +👤 Contact Details: |
| 39 | + • Name: {{from_name}} |
| 40 | + • Email: {{from_email}} |
| 41 | + • Discord: {{discord_name}} |
| 42 | +
|
| 43 | +📝 Message: |
| 44 | +{{message}} |
| 45 | +
|
| 46 | +--- |
| 47 | +This message was sent from your portfolio website. |
| 48 | +``` |
| 49 | + |
| 50 | +4. **Note down the Template ID** (e.g., `template_xyz789`) |
| 51 | + |
| 52 | +### Step 4: Get Public Key |
| 53 | + |
| 54 | +1. Go to **"Account"** → **"General"** |
| 55 | +2. Copy your **"Public Key"** (e.g., `user_def456`) |
| 56 | + |
| 57 | +### Step 5: Configure Environment Variables |
| 58 | + |
| 59 | +1. Copy the `.env.example` file to `.env`: |
| 60 | + ```bash |
| 61 | + cp .env.example .env |
| 62 | + ``` |
| 63 | + |
| 64 | +2. Edit the `.env` file and replace the placeholder values: |
| 65 | + ```env |
| 66 | + VITE_EMAILJS_SERVICE_ID=service_abc123 |
| 67 | + VITE_EMAILJS_TEMPLATE_ID=template_xyz789 |
| 68 | + VITE_EMAILJS_PUBLIC_KEY=user_def456 |
| 69 | + ``` |
| 70 | + |
| 71 | +### Step 6: Test the Setup |
| 72 | + |
| 73 | +1. Start your development server: |
| 74 | + ```bash |
| 75 | + npm run dev |
| 76 | + ``` |
| 77 | + |
| 78 | +2. Go to the contact section of your portfolio |
| 79 | +3. Fill out the form and submit |
| 80 | +4. Check your email for the test message |
| 81 | + |
| 82 | +## Free Plan Limits |
| 83 | + |
| 84 | +EmailJS free plan includes: |
| 85 | +- 200 emails per month |
| 86 | +- 50 emails per day |
| 87 | +- Unlimited email templates |
| 88 | + |
| 89 | +## Troubleshooting |
| 90 | + |
| 91 | +### Common Issues |
| 92 | + |
| 93 | +1. **"Failed to send message" error** |
| 94 | + - Check that your environment variables are correctly set |
| 95 | + - Verify your email service is properly connected |
| 96 | + - Ensure your template ID is correct |
| 97 | + |
| 98 | +2. **Template variables not working** |
| 99 | + - Make sure your template uses the exact variable names: `{{from_name}}`, `{{from_email}}`, `{{discord_name}}`, `{{message}}` |
| 100 | + - Check that the template is saved and published |
| 101 | + |
| 102 | +3. **Authentication issues** |
| 103 | + - Reconnect your email service in the EmailJS dashboard |
| 104 | + - Check if your email provider requires app-specific passwords |
| 105 | + |
| 106 | +### Debug Mode |
| 107 | + |
| 108 | +To enable debug logging, add this to your `.env` file: |
| 109 | +```env |
| 110 | +VITE_EMAILJS_DEBUG=true |
| 111 | +``` |
| 112 | + |
| 113 | +## Alternative Email Services |
| 114 | + |
| 115 | +If you prefer not to use EmailJS, consider these alternatives: |
| 116 | + |
| 117 | +1. **Formspree**: Simple form handling service |
| 118 | +2. **Netlify Forms**: If deploying to Netlify |
| 119 | +3. **Getform**: Another form backend service |
| 120 | +4. **Direct SMTP**: Using nodemailer with a backend |
| 121 | + |
| 122 | +## Security Notes |
| 123 | + |
| 124 | +- Never expose your EmailJS private keys (only public keys are safe for frontend) |
| 125 | +- The free plan has rate limiting to prevent abuse |
| 126 | +- Consider implementing CAPTCHA for production use |
| 127 | +- Monitor your email sending to stay within limits |
| 128 | + |
| 129 | +## Support |
| 130 | + |
| 131 | +- [EmailJS Documentation](https://www.emailjs.com/docs/) |
| 132 | +- [EmailJS Support](https://www.emailjs.com/support/) |
| 133 | +- [Vue.js Contact Form Tutorial](https://www.emailjs.com/docs/vuejs-contact-form/) |
| 134 | + |
| 135 | +--- |
| 136 | + |
| 137 | +**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. |
0 commit comments