umputun / remark42

comment engine
https://remark42.com
MIT License
4.87k stars 377 forks source link

AUTH_EMAIL_FROM does not support 'noreply <noreply@example.com>' configuration #1735

Open antonchen opened 8 months ago

antonchen commented 8 months ago
failed to send confirmation - bad from address "noreply <noreply@example.com>": 501 mail from address must be same as authorization user - 500 - IP - /auth/email/login?site=RawLab&address=test@example.com&user=Anton [caused by auth/provider/verify.go:194 provider.VerifyHandler.sendConfirmation]
paskal commented 7 months ago

You need to use AUTH_EMAIL_FROM and NOTIFY_EMAIL_FROM variables like that:

      - ADMIN_SHARED_EMAIL=admin@example.com
      - NOTIFY_USERS=email
      - NOTIFY_ADMINS=email
      - SMTP_TLS=true
      - SMTP_HOST=smtp.sendgrid.net
      - SMTP_PORT=465
      - SMTP_USERNAME=apikey
      - SMTP_PASSWORD=secret_password
      - AUTH_EMAIL_FROM="My auth system notification using SendGrid"<notify@example.com>
      - NOTIFY_EMAIL_FROM="My notification system using SendGrid"<notify@example.com>

It looks like that in the Gmail:

image

Resolving: feel free to reopen if I'm wrong, and that's different from what you are looking for.

antonchen commented 7 months ago

My remark42 is running on fly.io, fly.io environment variable configuration

[env]
   AUTH_EMAIL_ENABLE = 'true'
   AUTH_EMAIL_FROM = 'notify@example.com'
  # I tried the following configuration, but got the same error.
  # fly.io configuration requires that the value of the variable needs quotes
  # AUTH_EMAIL_FROM = 'Notify <notify@example.com>'
  # AUTH_EMAIL_FROM = 'Notify<notify@example.com>'
  # AUTH_EMAIL_FROM = '"Notify"<notify@example.com>'

I used an old version before without this problem, but I can't remember the version number

paskal commented 7 months ago

Can you please try the master version of the container and see if the problem reproduces? Finding the version that's not broken for you would be very useful if it is. The format is like in my example, AUTH_EMAIL_FROM="My auth system notification using SendGrid"<notify@example.com> - text in quotes, then email in the brackets.

antonchen commented 7 months ago

The issue originated from a modification in fly.io's configuration file format, which introduced a requirement for environment variable values to be enclosed in quotes. As a result, I couldn't transfer the environment variable in the format AUTH_EMAIL_FROM="My auth system notification using SendGrid"notify@example.com to the container.

My attempt to conform to fly.io's format by passing AUTH_EMAIL_FROM='"My auth system notification using SendGrid"<notify@example.com>' led to remark42 receiving the value as "\"My auth system notification using SendGrid\"<notify@example.com>", triggering errors.

paskal commented 6 months ago

I can't reproduce it, unfortunately. My config:

[env]
  AUTH_EMAIL_FROM = '"My auth system notification using SendGrid"<notify@example.com>'
❯ fly ssh console     
Connecting to fdaa:8:b685:a7b:c988:1ee8:e670:2... complete
root@178190eb244008:/usr/src/app# env | grep AUTH_EMAIL_FROM
AUTH_EMAIL_FROM="My auth system notification using SendGrid"<notify@example.com>

What is the output of env | grep AUTH_EMAIL_FROM in your case?

antonchen commented 6 months ago
2024/03/17 11:44:55.713 [INFO] failed to send confirmation - bad from address "\"Noreply RawLab\"<noreply@rawlab.net>": 501 mail from address must be same as authorization user - 500 - 46.3.241.98 - /auth/email/login?site=RawLab&address=antonchen@hotmail.com&user=Anton [caused by auth/provider/verify.go:191 provider.VerifyHandler.sendConfirmation]

My config:

app = 'rawlab-comments'
primary_region = 'nrt'
kill_signal = 'SIGINT'
kill_timeout = '10s'
console_command = '/bin/sh'

[experimental]
  auto_rollback = true

[build]
  image = 'umputun/remark42:master'

[env]
  ADMIN_SHARED_ID = 'github_a0d8d890470be032928ee4faf4a4e67bc5e3e755'
  AUTH_EMAIL_ENABLE = 'true'
  AUTH_EMAIL_FROM = '"Noreply RawLab"<noreply@rawlab.net>'
  AUTH_EMAIL_SUBJ = 'Email verification'
  AUTH_TELEGRAM = 'true'
  DEBUG = 'false'
  EMOJI = 'true'
  NOTIFY_ADMINS = 'telegram'
  NOTIFY_USERS = 'telegram,email'
  REMARK_PORT = '8080'
  REMARK_URL = 'https://cm.rawlab.net'
  SITE = 'RawLab'
  TIME_ZONE = 'Asia/Shanghai'

[[mounts]]
  source = 'remark42_data'
  destination = '/srv/var'
  initial_size = '1GB'

[http_service]
  internal_port = 8080
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 1
  processes = ['app']

[[http_service.checks]]
    interval = '30s'
    timeout = '5s'
    grace_period = '10s'
    method = 'GET'
    path = '/ping'

[[services]]
  protocol = 'tcp'
  internal_port = 8080
  processes = ['app']

[[services.ports]]
    port = 80
    handlers = ['http']

[[services.ports]]
    port = 443
    handlers = ['tls', 'http']

    [services.ports.http_options]
      [services.ports.http_options.response]
        [services.ports.http_options.response.headers]
          Access-Control-Allow-Origin = '*'
          App-Name = false
          App-Version = false
          Autho = false

[[vm]]
  cpu_kind = 'shared'
  cpus = 1
  memory_mb = 256

Console:

> flyctl ssh console
Connecting to fdaa:1:140d:a7b:22f:5db0:78b8:2... complete
91852e3ea5de38:/srv# env | grep AUTH_EMAIL_FROM
AUTH_EMAIL_FROM="Noreply RawLab"<noreply@rawlab.net>
91852e3ea5de38:/srv#