Mails not being sent (Mailgun and Sendgrid tested => both haven't even got an API request)

Hey, I have setup my main.wasp with my email I have registered and set the APIKey - for password reset I am getting 200 as return but no mail is ever being sent
7 Replies
kapa.ai
kapa.ai8mo ago
Hi @Johnny. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I'm sorry to hear that you're having trouble with sending emails. Here are a few things you can check: 1. Provider Setup: Make sure you have correctly set up the email provider in your main.wasp file. If you're using Mailgun, your setup should look like this:
app Example {
...
emailSender: {
provider: Mailgun,
}
}
app Example {
...
emailSender: {
provider: Mailgun,
}
}
If you're using SendGrid, replace Mailgun with SendGrid in the provider field. 2. API Key and Domain: Ensure that you have correctly added your Mailgun API key and domain to your .env.server file. The file should look like this:
MAILGUN_API_KEY=your_api_key
MAILGUN_DOMAIN=your_domain
MAILGUN_API_KEY=your_api_key
MAILGUN_DOMAIN=your_domain
If you're using SendGrid, replace MAILGUN_API_KEY and MAILGUN_DOMAIN with your SendGrid API key and domain. 3. Email Address: Check if you have already logged in with the same email address using the Email method. If so, run wasp db studio and delete that user and try logging in again. 4. Check Logs: If you're using the Dummy provider during development, it will console.log the emails in the console instead of sending them. Check your console logs to see if the emails are being logged. 5. Check with Provider: If everything seems to be set up correctly, but emails are still not being sent, it might be worth checking with your email provider (Mailgun or SendGrid) to see if they have received any API requests. If you're still having trouble, it might be helpful to look at the Wasp documentation on sending emails (https://wasp-lang.dev/docs/advanced/email) or ask for help in the Wasp Discord community (https://discord.com/channels/686873244791210014/1179895919471247490). Sources: - Wasp Documentation: Sending Emails (https://wasp-lang.dev/docs/advanced/email) - Wasp Documentation: Using the Mailgun Provider (https://wasp-lang.dev/docs/advanced/email#using-the-mailgun-provider) - Wasp Discord Community (https://discord.com/channels/686873244791210014/1179895919471247490) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Johnny, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Johnny
Johnny8mo ago
Edit - found the issue - some error handling would maybe an idea If the use has no email in the database he cant get a mail delivered Edit 2: still getting no emails delivered
MEE6
MEE68mo ago
Wohooo @Johnny, you just became a Waspeteer level 1!
miho
miho8mo ago
We need more information to be able to help you 🤷🏻‍♂️ what kind of app are you building? Are you using open saas? Did you use Mailgun or Sendgrid before successfully? Sometimes you need to verify the sending domain and it might work only for your test email acc. That's want happened to me sometimes.
Johnny
Johnny8mo ago
I switched from sendgrid/mailgun to a smtp server (hetzner) I am using open saas And trying to figure out how to get the mail sencind done Manages to use it succesfully with my own application already
miho
miho8mo ago
Could you share a bit of code? 🫡
Johnny
Johnny8mo ago
set up SMTP_HOST=mail.your-server.de [email protected] SMTP_PASSWORD= SMTP_PORT=465 Could it be that password reset is not set up by default?
auth: {
// 1. Specify the user entity (we'll define it next)
userEntity: User,
methods: {
// 2. Enable email authentication
email: {
// 3. Specify the email from field
fromField: {
name: "xx",
},
// 4. Specify the email verification and password reset options (we'll talk about them later)
emailVerification: {
clientRoute: EmailVerificationRoute,
getEmailContentFn: import { getVerificationEmailContent } from "@src/server/auth/email.ts",

},
passwordReset: {
clientRoute: PasswordResetRoute,
getEmailContentFn: import { getPasswordResetEmailContent } from "@src/server/auth/email.ts",
},
},

auth: {
// 1. Specify the user entity (we'll define it next)
userEntity: User,
methods: {
// 2. Enable email authentication
email: {
// 3. Specify the email from field
fromField: {
name: "xx",
},
// 4. Specify the email verification and password reset options (we'll talk about them later)
emailVerification: {
clientRoute: EmailVerificationRoute,
getEmailContentFn: import { getVerificationEmailContent } from "@src/server/auth/email.ts",

},
passwordReset: {
clientRoute: PasswordResetRoute,
getEmailContentFn: import { getPasswordResetEmailContent } from "@src/server/auth/email.ts",
},
},

db: {
system: PostgreSQL,
seeds: [
import { devSeedUsers } from "@src/server/scripts/usersSeed.js",
]
},
client: {
rootComponent: import App from "@src/client/App",
},
emailSender: {
provider: SMTP,
},
}
db: {
system: PostgreSQL,
seeds: [
import { devSeedUsers } from "@src/server/scripts/usersSeed.js",
]
},
client: {
rootComponent: import App from "@src/client/App",
},
emailSender: {
provider: SMTP,
},
}
I have no clue what I am doing wrong tbh. 😄 And with "Dummy" I am only getting
[ Server ] GET /auth/me 401 0.520 ms - 43
[ Server ] POST /auth/email/request-password-reset 200 1856.935 ms - 16
[ Server ] GET /auth/me 401 0.656 ms - 43
[ Server ] GET /auth/me 401 0.520 ms - 43
[ Server ] POST /auth/email/request-password-reset 200 1856.935 ms - 16
[ Server ] GET /auth/me 401 0.656 ms - 43
And
import { type GetVerificationEmailContentFn, type GetPasswordResetEmailContentFn } from "wasp/server/auth";

export const getVerificationEmailContent: GetVerificationEmailContentFn = ({ verificationLink }) => ({
subject: 'Verify your email',
text: `Click the link below to verify your email: ${verificationLink}`,
html: `
<p>Click the link below to verify your email</p>
<a href="${verificationLink}">Verify email</a>
`,
});

export const getPasswordResetEmailContent: GetPasswordResetEmailContentFn = ({ passwordResetLink }) => ({
subject: 'Password reset',
text: `Click the link below to reset your password: ${passwordResetLink}`,
html: `
<p>Click the link below to reset your password</p>
<a href="${passwordResetLink}">Reset password</a>
`,
});
import { type GetVerificationEmailContentFn, type GetPasswordResetEmailContentFn } from "wasp/server/auth";

export const getVerificationEmailContent: GetVerificationEmailContentFn = ({ verificationLink }) => ({
subject: 'Verify your email',
text: `Click the link below to verify your email: ${verificationLink}`,
html: `
<p>Click the link below to verify your email</p>
<a href="${verificationLink}">Verify email</a>
`,
});

export const getPasswordResetEmailContent: GetPasswordResetEmailContentFn = ({ passwordResetLink }) => ({
subject: 'Password reset',
text: `Click the link below to reset your password: ${passwordResetLink}`,
html: `
<p>Click the link below to reset your password</p>
<a href="${passwordResetLink}">Reset password</a>
`,
});
Anyone an idea why SMTP isn't working? Password, username etc. is correct For anyone having simillar problems - solved it. It seems to only work with port 587 via hetzner (465 isn't)
Want results from more Discord servers?
Add your server