Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emails not sent #319

Open
itacasoft opened this issue Feb 28, 2024 · 6 comments
Open

Emails not sent #319

itacasoft opened this issue Feb 28, 2024 · 6 comments

Comments

@itacasoft
Copy link

Hi all,
environment:

  • Windows 10.0.19045.4046
  • Node 20.11.1
  • PostGres 16
  • Resend FREE plan
  • No GOOGLE_CLIENT_ID set

I successfully managed to install, run and open the web application with command "npm run dev".
But when I try to register on page http://localhost:3000/login, apparently it works, but actually no email is sent.

image

I registered on Resend with a free plan and set the RESEND_API_KEY value in the .env environment with the API Key copied from Resend web site, but I do not receive any email.

Tries:

  • Open a CMD and execute command "npm run email", then another CMD and execute command "npm run dev" --> seems nothing changes.
  • With "npm run email", I tried to open the page at http://localhost:3001 and send a "welcome" email from React email page. The email has arrived at my email box.
  • On Resend web site, tried to send an email to my email address, it works.

Below my application log:

C:\usr\Projects\papermark>npm run dev

papermark@0.1.0 dev
next dev

▲ Next.js 14.1.0

  • Local: http://localhost:3000
  • Environments: .env
  • Experiments (use at your own risk):
    · missingSuspenseWithCSRBailout

✓ Ready in 4.3s
○ Compiling /middleware ...
✓ Compiled /middleware in 514ms (171 modules)
○ Compiling / ...
✓ Compiled /login in 19.7s (1107 modules)
○ Compiling /api/auth/[...nextauth] ...
✓ Compiled /api/auth/[...nextauth] in 1442ms (1459 modules)
[Login URL] http://localhost:3000/api/auth/callback/email?callbackUrl=http%3A%2F%2Flocalhost%3A3000%2Flogin&token=e6c2e33a4ba84b6adeea95cc19f6dcaa352ab8462e6532c216bdfbd4120a188d&email=itacasoft%40gmail.com

Any help very appreciated, thanks.

@mfts
Copy link
Owner

mfts commented Feb 29, 2024

Thanks @itacasoft for the report.

On localhost, there are no welcome emails being sent instead, the login url is logged to the console

EmailProvider({
async sendVerificationRequest({ identifier, url }) {
if (process.env.NODE_ENV === "development") {
console.log("[Login URL]", url);
return;
} else {
await sendVerificationRequestEmail({
url,
email: identifier,
});
}
},
}),

@itacasoft
Copy link
Author

Hi @mfts , thank you for your reply.
Unfortunately, this does not help to resolve this issue. My web app is not sending emails, hence I'm unable to test its brilliant features.
I could try to debug it, but I'm sure my help to the project can be more effective in other roles such as Product Manager (which is currently the job I'm doing :)) or tester.
Thx for any help!

@mfts
Copy link
Owner

mfts commented Feb 29, 2024

On localhost, if emails are sent, all emails go to a resend sandbox (delivered@resend.dev), you can find these emails in resend.com/dashboard

If you want to change that behaviour you can change this line to exclude the test prop.

I'm sorry this was not documented properly. Thanks for bringing it up and helps making it easier for the next person 🙏

to: test ? "delivered@resend.dev" : to,

@itacasoft
Copy link
Author

Hi again @mfts , resend.com/dashboard returns 404.
However, I have checked at page resend.com/logs:

image

As you can see, only my test after having created the API Key is present.
I have thought about a firewall problem, but no rules are set for oubound connections.
Besides, the fact that the console of CMD prompt doesn't say "connection failure" or something is suspicious, it makes me think that I'm missing an important piece.
Thx again.

@mfts
Copy link
Owner

mfts commented Mar 4, 2024

Hey @itacasoft I refactored the sendEmail function that will return better error messages.

As an aside, emails are not sent in localhost for signup/signins.

@mfts
Copy link
Owner

mfts commented Mar 17, 2024

@itacasoft do you still experience the issue on the latest version?

@mfts mfts added the self-host label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants