# How to Get and Use SendGrid API Key for Email Sending This project uses **SendGrid** to send emails (such as account verification or notifications). Follow these steps to set it up: --- ## Step 1: Create a SendGrid Account 1. Go to [https://sendgrid.com](https://sendgrid.com) 2. Click **Sign Up** and create a free account 3. Complete the registration and verify your email --- ## Step 2: Create an API Key 1. Log in to your SendGrid dashboard 2. In the left sidebar, click **Settings** → **API Keys** 3. Click **Create API Key** 4. Enter a name (e.g., "Car Wash App Key") 5. Choose **Full Access** (or "Restricted Access" with email sending permissions) 6. Click **Create & View** 7. Copy the generated API key (you won’t be able to see it again later!) --- ## Step 3: Verify Your Sender Identity 1. In the SendGrid dashboard, go to **Sender Authentication** 2. Choose **Single Sender Verification** 3. Add and verify the email address you want to send emails from (e.g., `your-email@example.com`) 4. Follow the verification email instructions --- ## Step 4: Add API Key and Email to Your Environment Variables In your `.env` file (inside the `server` folder), add: ```env SENDGRID_API_KEY=your-sendgrid-api-key SENDGRID_FROM_EMAIL=your-verified-email@example.com ``` --- ## Step 5: Verify Your Sender Identity To prevent your emails from landing in spam, you must authenticate your sender identity: In the dashboard, go to Settings > Sender Authentication Under Domain Authentication, click Authenticate Your Domain Choose your DNS host (e.g., GoDaddy, Namecheap, etc.) Enter your domain (e.g., yourdomain.com) Add the given DNS records to your domain’s DNS settings Click Verify in SendGrid (after DNS propagation, usually within 24 hrs) 🔔 Why? If domain authentication is not completed, most emails may go to spam. ## Step 6: Run the App * Your backend will use these settings to send emails via SendGrid * Make sure your app is restarted after adding/updating `.env` --- ## Troubleshooting * If emails aren’t sending, check SendGrid dashboard for any errors or warnings * Ensure the API key and sender email are correct and verified * Check your spam folder just in case --- ## Useful Links * [SendGrid Docs: API Keys](https://docs.sendgrid.com/ui/account-and-settings/api-keys) * [SendGrid Docs: Sender Authentication](https://docs.sendgrid.com/ui/account-and-settings/how-to-set-up-domain-authentication) ---