papermark icon indicating copy to clipboard operation
papermark copied to clipboard

Emails not sent

Open itacasoft opened this issue 2 years ago • 6 comments

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

[email protected] 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.

itacasoft avatar Feb 28 '24 19:02 itacasoft

Thanks @itacasoft for the report.

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

https://github.com/mfts/papermark/blob/a438ccccff2fd04c5304769090f383cbefbd9a2c/pages/api/auth/%5B...nextauth%5D.ts#L51-L63

mfts avatar Feb 29 '24 05:02 mfts

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!

itacasoft avatar Feb 29 '24 09:02 itacasoft

On localhost, if emails are sent, all emails go to a resend sandbox ([email protected]), 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 🙏

https://github.com/mfts/papermark/blob/77699f3404c538a25e4450f9d94bc933378cbb9c/lib/resend.ts#L33

mfts avatar Feb 29 '24 09:02 mfts

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.

itacasoft avatar Feb 29 '24 12:02 itacasoft

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 avatar Mar 04 '24 14:03 mfts

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

mfts avatar Mar 17 '24 06:03 mfts