remark42 icon indicating copy to clipboard operation
remark42 copied to clipboard

AUTH_EMAIL_FROM does not support 'noreply <[email protected]>' configuration

Open antonchen opened this issue 1 year ago • 6 comments

failed to send confirmation - bad from address "noreply <[email protected]>": 501 mail from address must be same as authorization user - 500 - IP - /auth/email/login?site=RawLab&[email protected]&user=Anton [caused by auth/provider/verify.go:194 provider.VerifyHandler.sendConfirmation]

antonchen avatar Jan 29 '24 06:01 antonchen

You need to use AUTH_EMAIL_FROM and NOTIFY_EMAIL_FROM variables like that:

      - [email protected]
      - 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"<[email protected]>
      - NOTIFY_EMAIL_FROM="My notification system using SendGrid"<[email protected]>

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.

paskal avatar Feb 18 '24 14:02 paskal

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

[env]
   AUTH_EMAIL_ENABLE = 'true'
   AUTH_EMAIL_FROM = '[email protected]'
  # 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 <[email protected]>'
  # AUTH_EMAIL_FROM = 'Notify<[email protected]>'
  # AUTH_EMAIL_FROM = '"Notify"<[email protected]>'

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

antonchen avatar Feb 21 '24 07:02 antonchen

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"<[email protected]> - text in quotes, then email in the brackets.

paskal avatar Feb 21 '24 09:02 paskal

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"[email protected] to the container.

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

antonchen avatar Feb 21 '24 10:02 antonchen

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

[env]
  AUTH_EMAIL_FROM = '"My auth system notification using SendGrid"<[email protected]>'
❯ 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"<[email protected]>

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

paskal avatar Mar 16 '24 16:03 paskal

2024/03/17 11:44:55.713 [INFO] failed to send confirmation - bad from address "\"Noreply RawLab\"<[email protected]>": 501 mail from address must be same as authorization user - 500 - 46.3.241.98 - /auth/email/login?site=RawLab&[email protected]&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"<[email protected]>'
  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"<[email protected]>
91852e3ea5de38:/srv#

antonchen avatar Mar 17 '24 05:03 antonchen