# EmailJS Setup Guide for Sweet Dreams Bakery
This guide will walk you through setting up EmailJS to enable professional email functionality for order processing, contact forms, and customer communications.
## ๐ง What is EmailJS?
EmailJS allows you to send emails directly from your frontend application without needing a backend server. It's perfect for:
- Order confirmations
- Contact form submissions
- Newsletter subscriptions
- Business notifications
## ๐ Quick Setup (5 minutes)
### **Step 1: Create EmailJS Account**
1. Go to [emailjs.com](https://www.emailjs.com)
2. Click "Sign Up" and create a free account
3. Verify your email address
4. Log in to your EmailJS dashboard
### **Step 2: Set Up Email Service**
1. **Add Email Service:**
- In your EmailJS dashboard, click "Email Services"
- Click "Add New Service"
- Choose your email provider:
- **Gmail** (recommended for personal/small business)
- **Outlook/Hotmail**
- **Yahoo Mail**
- **Other SMTP services**
2. **Configure Gmail Service (Most Common):**
- Select "Gmail"
- Click "Connect Account"
- Sign in with your Gmail account
- Allow EmailJS permissions
- Your service will be created with an ID like `service_abc123`
3. **Configure Custom SMTP (Business Email):**
- Select "Other"
- Enter your SMTP settings:
```
SMTP Server: mail.yourdomain.com
Port: 587 (or 465 for SSL)
Username: orders@yourbakery.com
Password: your-email-password
```
- Test the connection
- Save the service
### **Step 3: Create Email Templates**
You'll need to create these templates in your EmailJS dashboard:
#### **Template 1: Customer Order Confirmation**
1. Go to "Email Templates" โ "Create New Template"
2. Template Name: `Customer Order Confirmation`
3. Template ID: `customer_order_confirmation` (you'll need this)
4. Configure the template (see detailed template code below)
#### **Template 2: Business Order Notification**
1. Create another template
2. Template Name: `Business Order Notification`
3. Template ID: `business_order_notification`
4. Configure for internal notifications
#### **Template 3: Contact Form**
1. Create a third template
2. Template Name: `Contact Form Inquiry`
3. Template ID: `contact_form_inquiry`
4. For general inquiries and consultations
### **Step 4: Get Your Credentials**
1. **Service ID**: Found in Email Services (e.g., `service_abc123`)
2. **Template IDs**: From your created templates
3. **User ID (Public Key)**: Account โ API Keys โ Public Key
### **Step 5: Update Website Configuration**
Edit `script.js` and update the EmailJS configuration:
```javascript
// Update these values with your actual EmailJS credentials
const emailJSConfig = {
serviceID: 'service_abc123', // Your service ID
templateID: 'customer_order_confirmation', // Your main template ID
userID: 'user_xyz789' // Your public key
};
```
## ๐ Email Template Configurations
### **Customer Order Confirmation Template**
**Template Settings:**
- **To Email**: `{{to_email}}`
- **From Name**: Sweet Dreams Bakery
- **From Email**: orders@sweetdreamsbakery.com (or your business email)
- **Subject**: Order Confirmation - Thank You {{to_name}}!
**Email Template Body** (copy this HTML):
```html
Hello {{to_name}}!
We've received your order and we're excited to create something special for you! Here are your order details:
๐ Order Summary
Order Number: {{order_number}}
Event Date: {{event_date}}
Delivery Method: {{delivery_method}}
Items Ordered:
{{order_items}}
Total Amount: ${{order_total}}
{{#special_requests}}
Special Requests: {{special_requests}}
{{/special_requests}}
๐ฏ What's Next?
- Within 24 hours: We'll contact you to confirm details
- Design consultation: Discuss any customizations
- Payment arrangement: Flexible payment options
- Final confirmation: Before we start baking!
Have questions? Reply to this email or call us at (555) 123-CAKE
Contact Us
```
### **Business Order Notification Template**
**Template Settings:**
- **To Email**: orders@sweetdreamsbakery.com (your business email)
- **From Name**: Website Orders
- **Subject**: ๐จ NEW ORDER: {{customer_name}} - ${{order_total}}
**Email Template Body:**
```html