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

Wrong sender email address when using Docker image #25162

Open
gunzino opened this issue Jan 16, 2021 · 14 comments · May be fixed by #46040
Open

Wrong sender email address when using Docker image #25162

gunzino opened this issue Jan 16, 2021 · 14 comments · May be fixed by #46040
Assignees

Comments

@gunzino
Copy link

gunzino commented Jan 16, 2021

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Steps to reproduce

  1. Install nextcloud from Docker - using 'nextcloud' image
  2. Configure SMTP
  3. Send testing mail

Expected behaviour

Mail should arrive

Actual behaviour

A problem occurred while sending the email. Please revise your settings. (Error: Address in mailbox given [cloud@gunzo.eu@localhost.localdomain] does not comply with RFC 2822, 3.6.2.)

Server configuration

Operating system: Docker

Web server: Apache

Database: MariaDB

PHP version: From docker image

Nextcloud version: 20.0.5

Updated from an older Nextcloud/ownCloud or fresh install: fresh install

Where did you install Nextcloud from: Docker

Config.php:
'mail_smtpmode' => 'smtp',
'mail_smtphost' => 'smtp.eu.mailgun.org',
'mail_smtpport' => '587',
'mail_smtpsecure' => 'tls',
'mail_smtpauth' => 1,
'mail_smtpauthtype' => 'LOGIN',
'mail_smtpname' => 'postmaster@gunzo.eu',
'mail_smtppassword' => 'xxxxx',
'mail_from_address' => 'cloud',
'mail_domain' => 'gunzo.eu',

docker-compose.xml:

version: '2'

services:
  db:
    image: mariadb
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    volumes:
      - ./db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=nextcloud654
      - MYSQL_PASSWORD=xxx
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud
    restart: always
    ports:
      - 8092:80
    links:
      - db
    volumes:
      - ./data:/var/www/html
    environment:
      - MYSQL_PASSWORD=xxx
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db
      - SMTP_HOST=smtp.eu.mailgun.org
      - SMTP_SECURE=tls
      - SMTP_PORT=587
      - SMTP_AUTHTYPE=LOGIN
      - SMTP_NAME=postmaster@gunzo.eu
      - SMTP_PASSWORD=xxxx
      - MAIL_FROM_ADDRESS=cloud@gunzo.eu
      - MAIL_DOMAIN=gunzo.eu
@gunzino gunzino added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Jan 16, 2021
@gunzino gunzino closed this as completed Jan 16, 2021
@ngrigoriev
Copy link

Sorry, why this one got closed? This is exactly the problem I have with the fresh install of Nextcloud: "A problem occurred while sending the email. Please revise your settings. (Error: Address in mailbox given [nextcloud@@localhost.localdomain] does not comply with RFC 2822, 3.6.2.

@ngrigoriev
Copy link

ngrigoriev commented Apr 25, 2021

Although this issue was closed for unknown reason, I think I have got rid of this problem with my installation using the following settings:

nextcloud:
  host: "nextcloud.<my-domain>"
  mail:
    enabled: true
    domain: "<my-domain>"
    fromAddress: "nextcloud"
    smtp:
      host: "<my-smtp-relay>"
      secure: "ssl"
      port: 465
  extraEnv:
    - name: NEXTCLOUD_HOSTNAME
      value: "nextcloud.<my-domain>"
    - name: OVERWRITEHOST
      value: "nextcloud.<my-domain>"
    - name: OVERWRITEPROTOCOL
      value: "https"

I was able to send the test email properly.

@vitobotta
Copy link

I've had this issue for ages. I upgraded to v23 and there's still the same issue.

@Adi-18
Copy link

Adi-18 commented Feb 3, 2022

I've the same problem right now. The additional @localhost.localdomain gives me the problem.

@alexisindesign
Copy link

Same here.
The issue persists.

@tcitworld tcitworld changed the title Sending mail RFC 2822, 3.6.2 Problem Wrong sender email address when using Docker image Feb 4, 2022
@tcitworld tcitworld reopened this Feb 4, 2022
@alexisindesign
Copy link

After reading docs thoroughly, was able to fix the issue.

docker-compose config:

    environment:
      # Mail config
      - MAIL_DOMAIN=mydomain.com
      - SMTP_HOST=mail.mydomain.com
      - SMTP_SECURE=ssl
      - SMTP_PORT=465
      - SMTP_AUTHTYPE=login
      - SMTP_NAME=noreply@mydomain.com
      - SMTP_PASSWORD=*******
      - MAIL_FROM_ADDRESS=noreply

@tcitworld
Copy link
Member

Yeah, the issue is now more about Nextcloud checking for invalid configuration before trying to send the email.

@Adi-18
Copy link

Adi-18 commented Feb 4, 2022

MAIL_FROM_ADDRESS=noreply

I see the misinterpretation of MAIL_FROM_ADDRESS: It suggest to type "mail@domain.tld ". Could it be?

@jordan-bravo
Copy link

jordan-bravo commented May 1, 2022

+1 same issue here on Nextcloud 23.0.3.

In Settings -> Basic Settings, under Email Server when I click "Send email" to test and verify settings, it shows this error: Address in mailbox given [<user@mydomain.com>@localhost.localdomain] does not comply with RFC 2822, 3.6.2.) where <user@mydomain.com> is my username and domain name.

@nawordar
Copy link

nawordar commented Jun 17, 2022

MAIL_FROM_ADDRESS=noreply

I see the misinterpretation of MAIL_FROM_ADDRESS: It suggest to type "mail@domain.tld ". Could it be?

Yep. In getDefaultEmailAddress() clearly mail_from_address is used only for the user part of e-mail. This is extremely confusing. IMO that variable should be deprecated and replaced with one with a clearer name

Also, I don't think it is a good idea to just fallback to localhost.localdomain. If validating e-mail address failed, something is clearly wrong and an error should be produced.

@szaimen

This comment was marked as outdated.

@nawordar
Copy link

@szaimen The getDefaultEmailAddress() function hasn't been changed in NC 25, so there is no way this has been solved.

This isn't really a bug, but an issue with:

  • incorrect variable name — MAIL_FROM_ADDRESS should contain only the user part, not the whole address, as the name suggests,
  • error handling — getDefaultEmailAddress() should not fallback to a default value when validating failed, but raise an exception.

In OP's case, environment variable contains the full address cloud@gunzo.eu and overrides the valid mail_from_address variable in config.php. Removing the environment variable should be enough to fix the OP's problem, but the issue with communicating what went wrong still persists.

@tcitworld
Copy link
Member

Can we split the two then, the first part should be an issue in nextcloud/docker, or use nextcloud/docker#1187, and this issue should be renamed to handle the second part.

@szaimen
Copy link
Contributor

szaimen commented Jan 23, 2023

Can we split the two then, the first part should be an issue in nextcloud/docker, or use nextcloud/docker#1187, and this issue should be renamed to handle the second part.

sounds good!

joshtrichards added a commit that referenced this issue Jun 21, 2024
Fixes #25162 

Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards joshtrichards linked a pull request Jun 21, 2024 that will close this issue
4 tasks
@joshtrichards joshtrichards added 3. to review Waiting for reviews and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Jul 29, 2024
@joshtrichards joshtrichards self-assigned this Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants