The 500 error is caused by missing Mailgun SMTP credentials in your Azure Function App configuration.
-
Go to Azure Portal: https://portal.azure.com
-
Find Your Azure Static Web App:
- Search for "artloop" in the search bar
- Click on your Static Web App (likely named something with "gray-water")
-
Navigate to Function App Settings:
- In the left menu, click "Configuration" or "Environment variables"
- OR: If your API is in a separate Function App named
artloop-email-function, go to that instead
-
Add Application Settings (Environment Variables):
Click "+ New application setting" for each of these:
Name Value Where to Find MAILGUN_SMTP_HOSTsmtp.mailgun.orgStandard Mailgun SMTP MAILGUN_SMTP_USERNAMEpostmaster@your-domain.mailgun.orgMailgun Dashboard → Domain Settings → SMTP credentials MAILGUN_SMTP_PASSWORDyour-smtp-passwordMailgun Dashboard → Domain Settings → SMTP credentials FROM_EMAILnoreply@your-domain.comMust be from your verified Mailgun domain -
Save Changes:
- Click "Save" at the top
- Click "Continue" to confirm the restart
-
Wait 1-2 minutes for the Function App to restart
If you have Azure CLI installed and logged in:
# Login to Azure
az login
# Set variables (replace with your actual values)
RESOURCE_GROUP="your-resource-group-name"
FUNCTION_APP="artloop-email-function" # or your Static Web App name
# Add the settings
az functionapp config appsettings set \
--name $FUNCTION_APP \
--resource-group $RESOURCE_GROUP \
--settings \
"MAILGUN_SMTP_HOST=smtp.mailgun.org" \
"MAILGUN_SMTP_USERNAME=postmaster@yourdomain.mailgun.org" \
"MAILGUN_SMTP_PASSWORD=your-smtp-password" \
"FROM_EMAIL=noreply@yourdomain.com"- Go to https://app.mailgun.com
- Click on "Sending" → "Domains"
- Select your domain
- Click "Domain Settings" → "SMTP credentials"
- You'll see:
- Login:
postmaster@yourdomain.mailgun.org - Password: Click "Reset password" if you don't have it
- SMTP Hostname:
smtp.mailgun.org
- Login:
-
Sign up for Mailgun: https://signup.mailgun.com/new/signup
- Free tier: 5,000 emails/month for 3 months
- No credit card required for sandbox
-
Add and Verify Your Domain:
- Go to Sending → Domains → Add New Domain
- Add your domain (e.g.,
mg.artloop.usormail.artloop.us) - Follow DNS setup instructions (add MX, TXT, CNAME records)
- Wait for verification (usually 5-15 minutes)
-
Get SMTP Credentials:
- Once verified, go to Domain Settings → SMTP credentials
- Copy the credentials
-
Important: Use a subdomain like
mg.yourdomain.comfor Mailgun to avoid affecting your main domain's email
For quick testing, you can use Mailgun's sandbox domain:
- Go to Mailgun Dashboard
- Find your Sandbox Domain (looks like
sandboxXXXXX.mailgun.org) - Add Authorized Recipients:
- Click on your sandbox domain
- Go to "Sending" → "Authorized Recipients"
- Add your email address and the organizer's email
- Verify both email addresses
- Use sandbox credentials:
MAILGUN_SMTP_USERNAME:postmaster@sandboxXXXXX.mailgun.org- From the SMTP credentials section
Note: Sandbox can only send to authorized recipients (max 5).
After adding the environment variables:
-
Wait 1-2 minutes for the Function App to restart
-
Test the registration:
- Go to https://artloop.us/events/2 or /events/3
- Try registering
- Check browser console for success message
-
Check Azure Function Logs:
- Azure Portal → Function App → Monitor → Logs
- Or: Function App → Functions → send-email → Monitor
- Look for error messages or success logs
Cause: Wrong SMTP credentials
Solution:
- Double-check username and password from Mailgun
- Make sure you're using the SMTP password, not API key
- Try resetting the SMTP password in Mailgun
Cause: Using sandbox domain without authorized recipients
Solution:
- Add recipient email as authorized in sandbox
- Or: Verify and use a real domain
Cause: DNS records not properly configured
Solution:
- Check DNS records in your domain registrar
- Wait for DNS propagation (can take up to 24 hours)
- Use
digornslookupto verify DNS records
Cause: Function App didn't restart or settings not saved
Solution:
- Go to Azure Portal → Function App
- Click "Restart" in the top menu
- Wait 2-3 minutes
- Try again
You can test Mailgun connectivity:
# Test SMTP connection
curl -v smtp://smtp.mailgun.org:587 \
--user "postmaster@yourdomain.mailgun.org:your-password" \
--mail-from "noreply@yourdomain.com" \
--mail-rcpt "test@example.com" \
--upload-file - << EOF
From: noreply@yourdomain.com
To: test@example.com
Subject: Test Email
This is a test email.
EOFIn the api directory:
cd api
# Edit test-email.js with your credentials
node test-email.jsRequired for Azure Function App:
MAILGUN_SMTP_HOST=smtp.mailgun.org
MAILGUN_SMTP_USERNAME=postmaster@yourdomain.mailgun.org
MAILGUN_SMTP_PASSWORD=your-smtp-password
FROM_EMAIL=noreply@yourdomain.com
- ✅ Add the environment variables in Azure Portal
- ✅ Restart the Function App
- ✅ Test registration on https://artloop.us/events/2
- ✅ Check browser console for success (✅) or error (❌)
- ✅ Check Azure Function logs if still failing
If you're still seeing errors after configuration:
-
Get the exact error from Azure Function logs:
- Azure Portal → Function App → Monitor → Logs
- Look for the latest execution with error details
-
Share the error and we can troubleshoot further
-
Alternative email services:
- SendGrid (Azure native)
- Azure Communication Services
- AWS SES
- Any SMTP provider