W
Wasp-lang•2mo ago
Sven

failed to send email production app

When i try to sign up in my opensaas app it says "check email" but the server logs say: ``` POST /auth/email/signup 200 286.658 ms - 16 2024-10-20T13:53:21.731 app[148e2444f93578] ams [info] Failed to send email ResponseError: Forbidden 2024-10-20T13:53:21.731 app[148e2444f93578] ams [info] at /app/node_modules/@sendgrid/client/src/classes/client.js:146:29 2024-10-20T13:53:21.731 app[148e2444f9357] ams [info] at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { 2024-10-20T13:53:21.731 app[148e2444f93578] ams [info] code: 403, 2024-10-20T13:53:21.731 app[148e2444f93578] ams [info] response: { 2024-10-20T13:53:21.731 app[148e2444f93578] ams [info] headers: { 2024-10-20T13:53:21.731 app[148e2444f93578] ams [info] server: 'nginx', 2024-10-20T13:53:21.731 app[148e2444f93578] ams [info] date: 'Sun, 20 Oct 2024 13:53:21 GMT', 2024-10-20T13:53:21.731 app[148e2444f93578] ams [info] 'content-type': 'application/json', 2024-10-20T13:53:21.731 app[148e2444f93578] ams [info] 'content-length': '281', 2024-10-20T13:53:21.731 app[148e2444f93578] ams [info] connection: 'close', 2024-10-20T13:53:21.731 app[148e2444f93578] ams [info] 'access-control-allow-origin': 'https://sendgrid.api-docs.io', 2024-10-20T13:53:21.731 app[148e2444f93578] ams [info] 'access-control-allow-methods': 'POST', 2024-10-20T13:53:21.731 app[148e2444f93578] ams [info] 'access-control-allow-headers': 'Authorization, Content-Type, On-behalf-of, x-sg-elas-acl', 2024-10-20T13:53:21.731 app[148e2444f93578] ams [info] 'access-control-max-age': '600', 2024-10-20T13:53:21.731 app[148e2444f93578] ams [info] 'x-no-cors-reason': 'https://sendgrid.com/docs/Classroom/Basics/API/cors.html', 2024-10-20T13:53:21.731 app[148e2444f93578] ams [info] 'strict-transport-security': 'max-age=600; includeSubDomains'
Cross Origin Resource Sharing (CORS) | SendGrid Docs | Twilio
CORS is a security feature of modern browsers to keep browser users secure.
10 Replies
kapa.ai
kapa.ai•2mo ago
Hi @Sven. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Sven
SvenOP•2mo ago
My my email sender:
emailSender: {
// NOTE: "Dummy" provider is just for local development purposes.
// Make sure to check the server logs for the email confirmation url (it will not be sent to an address)!
// Once you are ready for production, switch to e.g. "SendGrid" or "Mailgun" providers. Check out https://docs.opensaas.sh/guides/email-sending/ .
provider: SendGrid,
defaultFrom: {
name: "randname",
// When using a real provider, e.g. SendGrid, you must use the same email address that you configured your account to send out emails with!
},
},
emailSender: {
// NOTE: "Dummy" provider is just for local development purposes.
// Make sure to check the server logs for the email confirmation url (it will not be sent to an address)!
// Once you are ready for production, switch to e.g. "SendGrid" or "Mailgun" providers. Check out https://docs.opensaas.sh/guides/email-sending/ .
provider: SendGrid,
defaultFrom: {
name: "randname",
// When using a real provider, e.g. SendGrid, you must use the same email address that you configured your account to send out emails with!
},
},
Email is the same as single sender in my sendgrid. Also i set my secret in my env.server and my email is verified
kapa.ai
kapa.ai•2mo ago
---------------------- The error message you're seeing indicates that the SendGrid API is returning a 403 Forbidden error. This typically means that the server understood the request, but it refuses to authorize it. This status is commonly returned if the request lacks valid authentication credentials for the target resource or if the provided API key is not correct. In your main.wasp file, you should have set the provider field to SendGrid as shown below:
app Example {
...
emailSender: {
provider: SendGrid,
}
}
app Example {
...
emailSender: {
provider: SendGrid,
}
}
Then, you need to get the SendGrid API key and add it to your .env.server file. Here are the steps to get the API key: 1. Go to SendGrid (https://sendgrid.com/) and create an account. 2. Go to API Keys (https://app.sendgrid.com/settings/api_keys) and create a new API key. 3. Copy the API key and add it to your .env.server file. Your .env.server file should look like this:
SENDGRID_API_KEY=
SENDGRID_API_KEY=
Please ensure that you have correctly set the SendGrid API key in your .env.server file. If the problem persists, you might want to check if the API key has the necessary permissions or if it is active. For more information, you can refer to the Wasp documentation on using the SendGrid provider (https://wasp-lang.dev/docs/advanced/email#using-the-sendgrid-provider). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sven, 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?
miho
miho•2mo ago
The from email needs to be approved on SendGrid, [email protected] won't work unless you own the email.com domain and verify it with SendGrid.
Sven
SvenOP•2mo ago
yeah that is a placeholder i have it as my personal gmail
Sven
SvenOP•2mo ago
look it is verified
No description
Sven
SvenOP•2mo ago
emailSender: {
// NOTE: "Dummy" provider is just for local development purposes.
// Make sure to check the server logs for the email confirmation url (it will not be sent to an address)!
// Once you are ready for production, switch to e.g. "SendGrid" or "Mailgun" providers. Check out https://docs.opensaas.sh/guides/email-sending/ .
provider: SendGrid,
defaultFrom: {
name: "svenTEST",
// When using a real provider, e.g. SendGrid, you must use the same email address that you configured your account to send out emails with!
email: "Placeholder for now"
},
},
}
emailSender: {
// NOTE: "Dummy" provider is just for local development purposes.
// Make sure to check the server logs for the email confirmation url (it will not be sent to an address)!
// Once you are ready for production, switch to e.g. "SendGrid" or "Mailgun" providers. Check out https://docs.opensaas.sh/guides/email-sending/ .
provider: SendGrid,
defaultFrom: {
name: "svenTEST",
// When using a real provider, e.g. SendGrid, you must use the same email address that you configured your account to send out emails with!
email: "Placeholder for now"
},
},
}
only the email is a placeholder the email in main.wasp exactly matches the one verified here name not tho idk if that is a must..
miho
miho•2mo ago
What's the value of auth.email.fromField?
Sven
SvenOP•2mo ago
solved i had to scroll up and also change the email in the field there didnt know it was even there my bad i geuss
miho
miho•2mo ago
No worries, I'm glad it's sorted đź‘Ť
Want results from more Discord servers?
Add your server