Server: Email validation fails in multiple locations

Created on 16 Nov 2016  路  3Comments  路  Source: nextcloud/server

Steps to reproduce

  1. Attempt to enter an email address on the personal settings page of a logged in user.
  2. Attempt to send an email from Additional Settings - > Email server.

Expected behaviour

1: A valid email address should be accepted.
2: Email should be sent using the valid email address set.

Actual behaviour

Valid email address are rejected.

Server configuration

Operating system: FreeBSD

Web server: Nginx 1.10

Database: MariaDB 10

PHP version: 5.6.27 & 7.0.12

Nextcloud version: (see Nextcloud admin page) 10.0.1

Updated from an older Nextcloud/ownCloud or fresh install: Updated. Originally ownCloud. Also tested with a clean install of 10.0.1 directly.

Where did you install Nextcloud from: Direct download

Signing status:

Signing status

No errors have been found.

List of activated apps:

App list

Enabled:
  - activity: 2.3.2
  - comments: 1.0.0
  - dav: 1.0.1
  - federatedfilesharing: 1.0.1
  - federation: 1.0.1
  - files: 1.5.2
  - files_pdfviewer: 0.8.1
  - files_sharing: 1.0.0
  - files_texteditor: 2.1
  - files_trashbin: 1.0.0
  - files_versions: 1.3.0
  - files_videoplayer: 0.9.8
  - firstrunwizard: 1.1
  - gallery: 15.0.0
  - notifications: 0.3.0
  - password_policy: 1.0.0
  - provisioning_api: 1.0.0
  - serverinfo: 1.1.1
  - survey_client: 0.1.5
  - systemtags: 1.0.2
  - theming: 1.0.1
  - updatenotification: 1.0.1
  - workflowengine: 1.0.1

The content of config/config.php:

Config report

    "system": {
        "instanceid": "oceyehzzcnpk",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "demo.***REMOVED SENSITIVE VALUE***"
        ],
        "datadirectory": "\/private_html\/data",
        "overwrite.cli.url": "https:\/\/demo.***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "9.1.1.5",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "logtimezone": "UTC",
        "installed": true,
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "PLAIN",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***"
    }

Are you using external storage, if yes which one: No
Are you using encryption: No
Are you using an external user-backend: No

Client configuration

Browser: Firefox, Chrome, Epiphany, Chromium

Operating system: Fedora GNU/Linux

Logs

Web server error log

Nothing in the error log

Nextcloud log (data/nextcloud.log)

Nothing in the data log

More information
Here is a breakdown of my testing and the exact errors I am seeing.

Email address are not being validating properly. There are two areas where I can reproduce this.

1: Attempting to set the email on a users personal page.

This simply tells you that any input is invalid regardless of what is entered.

2: Setting up email for sending notifications. Click the send email button after configuring SMTP settings. The following error is displayed.

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

This seems related, https://github.com/swiftmailer/swiftmailer/issues/382

I can disable the check by commenting out the code on lines 348-351 of /3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php

        throw new Swift_RfcComplianceException(
            'Address in mailbox given ['.$address.
            '] does not comply with RFC 2822, 3.6.2.'
            );

With that code commented out, Nextcloud sends the email, which is then properly rejected by the SMTP server. Here the errors from that.

Nextcloud Error:

 A problem occurred while sending the email. Please revise your settings. (Error: Expected response code 250 but got code "501", with message "501 5.1.7 Bad sender address syntax ")

SMTP server error:

Error: warning: Illegal address syntax from [216.*.*.*] in MAIL command: <noreply@>

It seems the domain is not being appended to the email address. Previous versions of Nextcloud, and ownCloud before it worked properly. I have manually tested swiftmailer, and as far as I can tell it works perfectly.

Any ideas or tests I can run to provide more information?

Most helpful comment

This issue was resolved by installing the icu program (http://www.freshports.org/devel/icu/) and related libraries into the PHP chroot environment.

While icu was installed properly in the web environment, this is not sufficient when using php-fpm's chroot feature. The icu and related Unicode libraries need to be accessible in the chroot directory structure.

It would be nice if Nextcloud could run a check for this and report an error other than silently failing.

All 3 comments

This issue was resolved by installing the icu program (http://www.freshports.org/devel/icu/) and related libraries into the PHP chroot environment.

While icu was installed properly in the web environment, this is not sufficient when using php-fpm's chroot feature. The icu and related Unicode libraries need to be accessible in the chroot directory structure.

It would be nice if Nextcloud could run a check for this and report an error other than silently failing.

Feel free to reopen with more information, especially the address you are trying to use.

This issue was resolved by installing the icu program (http://www.freshports.org/devel/icu/) and related libraries into the PHP chroot environment.

While icu was installed properly in the web environment, this is not sufficient when using php-fpm's chroot feature. The icu and related Unicode libraries need to be accessible in the chroot directory structure.

It would be nice if Nextcloud could run a check for this and report an error other than silently failing.

This was really useful in pointing me towards a solution to the problem I was having!

For a few weeks, I have been running Nextcloud inside of a very restrictive chroot. Yesterday I had a user tell me that they got an error when trying to reset their password via e-mail. After testing e-mail sending from the admin interface, I got the "Address in mailbox given ... does not comply with RFC 2822, 3.6.2." error.

I eventually figured out that this was caused by a big .dat file from the icu package not being accessible from inside of the chroot, and this caused Swiftmailer to fail and give me the error.

To get Nextcloud to successfully send e-mail via SMTP from within the chroot, it was simply a matter of copying this file into the chroot:
/usr/local/share/icu/64.1/icudt64l.dat

That is on FreeBSD, and on Linux the path to the file should be something like this (CentOS 7.5):
/usr/share/icu/52.1/icudt52l.dat

I hope that this will be useful to anybody else trying to run Nextcloud within a chroot in the future.

Was this page helpful?
0 / 5 - 0 ratings