Netlify function: send-schedule
This site includes a Netlify Function at netlify/functions/send-schedule.js that sends an email with the submitted CSV attached using SendGrid.
Setup steps (Netlify):
Ensure the repository is deployed on Netlify. You can connect this GitHub repo to Netlify for automatic deploys.
Set the following environment variables in your Netlify site settings (Site settings → Build & deploy → Environment):
- SENDGRID_API_KEY: your SendGrid API key
- FROM_EMAIL: a verified sender email in your SendGrid account (e.g. no-reply@yourdomain.com)
- TO_EMAIL: the recipient address (defaults to flaherty.147@osu.edu if not set)
Netlify will install dependencies from the repo
package.json. We added@sendgrid/mailas a dependency. Netlify will install it during build. If you run locally, run:npm install
Deploy the site. The function will be available at
/.netlify/functions/send-schedule.
Client behavior
- The
Submit schedulebutton now POSTs JSON { name, email, csv } to the function. - The function sends an email with the CSV attached and returns a JSON result.
- If the function fails, the page falls back to opening the user’s default mail client with the CSV in the message body.
Security notes
- Keep
SENDGRID_API_KEYand other secrets in Netlify environment variables only; never expose them in client-side JS. - The function commits nothing to the repository; it only sends email. If you want to also save submissions into
submissions/in the repo, we can extend the function to push files to the GitHub API (requires a GitHub token in env vars).
