Skip to content

Commit

Permalink
Make nodemailer optional, see if this fixed cloudflare
Browse files Browse the repository at this point in the history
  • Loading branch information
scosman committed Jul 25, 2024
1 parent a70edfa commit 14d3ca9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,11 @@ If you prefer another host you can explore alternatives:
## Setup Admin Emailer -- Optional
SaaS Starter includes an admin emailer for sending yourself email notifications when important events happen, such as a new user creating their profile. This let's you monitor your app and respond to users without watching the database.
SaaS Starter includes an admin emailer for sending yourself email notifications when important events happen. This let's you monitor your app and respond to users without watching the database.
Provide email SMTP credientials in your environment variables: `PRIVATE_SMTP_HOST`, `PRIVATE_SMTP_PORT`, `PRIVATE_SMTP_USER`, `PRIVATE_SMTP_PASS`. You can use any SMTP providers such as Gmail, Sendgrid, AWS SES, Resend, or Mailgun.
If you setup the admin emailer, it will email you when users create their profile or the 'Contact Us' form is submitted. You can add additional calls to sendAdminEmail() for any other events you want to monitor.
Set the email address which admil emails will be sent to in `PRIVATE_ADMIN_EMAIL`.
You can add additional calls to sendAdminEmail() for any other events you want to monitor.
To setup, provide email SMTP credientials in your environment variables: `PRIVATE_SMTP_HOST`, `PRIVATE_SMTP_PORT`, `PRIVATE_SMTP_USER`, `PRIVATE_SMTP_PASS`. You can use any SMTP providers such as Gmail, Sendgrid, AWS SES, Resend, or Mailgun. Then set the email address to which admin emails will be sent in `PRIVATE_ADMIN_EMAIL`.
## Add Your Content
Expand Down
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@
"@supabase/auth-ui-svelte": "^0.2.9",
"@supabase/supabase-js": "^2.33.0",
"@types/nodemailer": "^6.4.15",
"nodemailer": "^6.9.14",
"stripe": "^13.3.0"
},
"peerDependencies": {
"nodemailer": "^6.9.14"
},
"peerDependenciesMeta": {
"nodemailer": {
"optional": true
}
}
}
7 changes: 7 additions & 0 deletions src/routes/(marketing)/contact_us/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { fail } from "@sveltejs/kit"
import { sendAdminEmail } from "$lib/admin_mailer.js"

/** @type {import('./$types').Actions} */
export const actions = {
Expand Down Expand Up @@ -67,5 +68,11 @@ export const actions = {
if (insertError) {
return fail(500, { errors: { _: "Error saving" } })
}

// Send email to admin
sendAdminEmail({
subject: "New contact request",
body: `New contact request from ${firstName} ${lastName}.\n\nEmail: ${email}\n\nPhone: ${phone}\n\nCompany: ${company}\n\nMessage: ${message}`,
})
},
}

0 comments on commit 14d3ca9

Please sign in to comment.