fief-dev / fief

Users and authentication management SaaS
https://www.fief.dev
Other
486 stars 42 forks source link

Email Provider SendGrid does not work #272

Closed JustinGuese closed 9 months ago

JustinGuese commented 9 months ago

Describe the bug

When using SendGrid because SMTP does not work neither https://github.com/fief-dev/fief/issues/271, I am getting a 403 Forbidden error.

I know this project is in beta... but come on guys did you even test it? That's 3 massive bugs already in 1 day

To Reproduce

Steps to reproduce the behavior:

  1. Create an API key, verify sender ID in SendGrid, check SendGrid with Python -> yes it works
  2. Set up SendGrid like described in the docs https://docs.fief.dev/self-hosting/deployment/setup-email-provider/
           └ <asyncio.runners.Runner object at 0xffff8ddf3590>
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           │      └ <method 'result' of '_asyncio.Task' objects>
           └ <Task finished name='Task-141' coro=<OnAfterRegisterTask.run() done, defined at /usr/local/lib/python3.11/site-packages/fief/...
  File "/usr/local/lib/python3.11/site-packages/fief/tasks/register.py", line 63, in run
    self.email_provider.send_email(
    │    │              └ <function Sendgrid.send_email at 0xffff97182200>
    │    └ <fief.services.email.sendgrid.Sendgrid object at 0xffff95aa73d0>
    └ <fief.tasks.register.OnAfterRegisterTask object at 0xffff958ce810>
  File "/usr/local/lib/python3.11/site-packages/fief/services/email/sendgrid.py", line 53, in send_email
    raise SendEmailError(str(e)) from e
          └ <class 'fief.services.email.base.SendEmailError'>

fief.services.email.base.SendEmailError: HTTP Error 403: Forbidden

Expected behavior

Email is sent

Configuration

Additional context

Add any other context about the problem here.

JustinGuese commented 9 months ago

ah yes you are not setting the right email in the mail send module, it takes "contact@fief.dev" instead, which fails with 403 understandably

 return self.client.mail.send.post(request_body=message)
           │    │                                  └ {'from': {'name': 'Fief', 'email': 'contact@fief.dev'}, 'subject': 'Welcome to Fief', 'personalizations': [{'to': [{'email': ...
frankie567 commented 9 months ago

The DEFAULT_FROM_EMAIL and DEFAULT_FROM_NAME can already be customized with environment variables. Ref: https://docs.fief.dev/self-hosting/environment-variables/#email-provider

frankie567 commented 9 months ago

I know this project is in beta... but come on guys did you even test it? That's 3 massive bugs already in 1 day

Reports and suggestions are greatly appreciated and encouraged, but that tone, clearly not. I would like to remind you this is an open-source project, provided 100% free without any guarantee. There are bugs indeed, the documentation has probably lot of room for improvements, but that's not a reason to despise us like this.