Can't add protonmail account to mail app. "Host protonmail-bridge was not connected to because it violates local access rules"

Hello guys,

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 31.0.2
  • Operating system and version (e.g., Ubuntu 24.04):
    • Debian 12.1
  • Web server and version (e.g, Apache 2.4.25):
    • Apache2
  • PHP version (e.g, 8.3):
    • 8.3.2
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes
  • When did this problem seem to first start?
    • When configuring protonmail account
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Docker image (nextcloud:31.0.2 )
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • no

Summary of the issue you are facing:

I’m trying to configure a protonmail account within the NC mail app. But i can’t get it to work.

My Nextcloud instance is in a docker container and is working fine overall.

I have another container on my server where Proton Bridge is installed. I logged in the Proton Bridge and it is working well (i configured Thunderbird on my phone with the Proton Bridge data and it works perfectly).
The name of that container is Proton-Bridge

But on the Nextcloud mail app, i can’t get to configure the protonmail account.
After entering all the info (in the manual conf tab) like this :

imap
Host : proton-bridge (without capital because Docker normalize)
imap security : none
Port : 143
user : my email
password : the password given by proton bridge

smtp
Host : proton-bridge (without capital because Docker normalize)
smtp security : none
Port : 25
user : my email
password : the password given by proton bridge

I’ve tried many different configurations in those settings but always when i click on “connect” i got that error saying : “IMAP server not reachable”.

I confirm that both Proton Bridge container and Nextcloud container are connected to the same docker Network.

So i captured a log of what happened when clicking that connect button and here is what i got so far :

Log entries

Nextcloud

{
  "reqId": "hWvlfFYVnVzqb4vkBob2",
  "level": 2,
  "time": "2025-04-29T08:37:00+00:00",
  "remoteAddr": "192.168.1.10",
  "user": "Matthieu",
  "app": "no app in context",
  "method": "POST",
  "url": "/apps/mail/api/accounts",
  "message": "Host protonmail-bridge was not connected to because it violates local access rules",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0",
  "version": "31.0.2.1",
  "data": []
}

Configuration

Nextcloud

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "maintenance": false,
        "maintenance_window_start": "3",
        "maintenance_window_end": "5",
        "version": "31.0.2.1",
        "trusted_domains": [
            "192.168.1.2",
            "localhost"
        ],
        "htaccess.RewriteBase": "\/",
        "overwrite.cli.url": "http:\/\/192.168.1.2:8080",
        "dbtype": "pgsql",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.locking": "\\OC\\Memcache\\APCu",
        "preview_concurrency_all": 2,
        "preview_concurrency_new": 2,
        "session.encrypt": false,
        "loglevel": 0,
        "debug": true,
        "mail_smtpmode": "smtp",
        "mail_smtpstreamoptions": {
            "ssl": {
                "allow_self_signed": true,
                "verify_peer": false,
                "verify_peer_name": false
            }
        },
        "mail_imapstreamoptions": {
            "ssl": {
                "allow_self_signed": true,
                "verify_peer": false,
                "verify_peer_name": false
            }
        },
        "connectivity": {
            "allow_local_address": true,
            "allow_local_remote_servers": [
                "172.23.0.2"
            ],
            "check_local_address": false,
            "allow_untrusted_certificate": true
        },
        "app_install_overwrite": [
            "occweb"
        ],
        "upgrade.disable-web": true,
        "memories.db.triggers.fcu": true,
        "memories.exiftool": "\/var\/www\/html\/custom_apps\/memories\/bin-ext\/exiftool-amd64-glibc",
        "memories.vod.path": "\/var\/www\/html\/custom_apps\/memories\/bin-ext\/go-vod-amd64",
        "default_phone_region": "FR"
    }
}

Apps

Enabled:
  - activity: 4.0.0
  - app_api: 5.0.2
  - bruteforcesettings: 4.0.0
  - calendar: 5.2.2
  - circles: 31.0.0
  - cloud_federation_api: 1.14.0
  - comments: 1.21.0
  - contacts: 7.0.6
  - contactsinteraction: 1.12.0
  - cospend: 3.0.11
  - dashboard: 7.11.0
  - dav: 1.33.0
  - deck: 1.15.0
  - federatedfilesharing: 1.21.0
  - federation: 1.21.0
  - files: 2.3.1
  - files_downloadlimit: 4.0.0
  - files_pdfviewer: 4.0.0
  - files_reminders: 1.4.0
  - files_sharing: 1.23.1
  - files_trashbin: 1.21.0
  - files_versions: 1.24.0
  - firstrunwizard: 4.0.0
  - logreader: 4.0.0
  - lookup_server_connector: 1.19.0
  - mail: 5.0.2
  - nextcloud_announcements: 3.0.0
  - notes: 4.12.0
  - notifications: 4.0.0
  - oauth2: 1.19.1
  - password_policy: 3.0.0
  - photos: 4.0.0-dev.1
  - privacy: 3.0.0
  - profile: 1.0.0
  - provisioning_api: 1.21.0
  - recommendations: 4.0.0
  - related_resources: 2.0.0
  - richdocuments: 8.6.4
  - richdocumentscode: 24.4.1303
  - serverinfo: 3.0.0
  - settings: 1.14.0
  - sharebymail: 1.21.0
  - support: 3.0.0
  - survey_client: 3.0.0
  - systemtags: 1.21.1
  - text: 5.0.0
  - theming: 2.6.1
  - twofactor_backupcodes: 1.20.0
  - updatenotification: 1.21.0
  - user_status: 1.11.0
  - viewer: 4.0.0
  - weather_status: 1.11.0
  - webhook_listeners: 1.2.0
  - workflowengine: 2.13.0
Disabled:
  - admin_audit: 1.21.0
  - encryption: 2.19.0
  - files_external: 1.23.0
  - memories: 7.5.2 (installed 7.5.2)
  - suspicious_login: 9.0.1
  - twofactor_nextcloud_notification: 5.0.0
  - twofactor_totp: 13.0.0-dev.0
  - user_ldap: 1.22.0.

Thanks for your answer and do not hesitate to ask me if you need further informations :slight_smile:

You need to use the allow_local_remote_servers configuration value: Configuration Parameters — Nextcloud latest Administration Manual latest documentation

Hello and thanks for your answer.

I’ve added that line in my config.php as you mentioned.

Now my connectivity part looks like this :

    // Connectivity settings (to allow connections to protonmail-bridge)
    'connectivity' => array(
        'allow_local_address' => true,
        'allow_local_remote_servers' => true,
        'allow_local_remote_servers' => array(
            '172.23.0.2',  // Updated to match the normalized name of Protonmail-Bridge
        ),
        'check_local_address' => false,
        'allow_untrusted_certificate' => true,
    ),

Unfortunately, i still have the same error about “IMAP server unreachable”, and the same logs :

"Host protonmail-bridge was not connected to because it violates local access rules"

Thanks

There is no such thing as a connectivity section. The mentioned config value is a global config parameter.

ok thanks. So what should i do then ?

Just add the mentioned parameter according to the docs to your config.

My point was that it appears you’re trying to add the parameter inside a connectivity section. I’m not sure where you got connectivity, but it’s not a Nextcloud configuration parameter AFAIK.

Ok i removed all the connectivity part and only left the parameter as you said and it looks like it is working now.

Thanks for your help.

actually i’m still having trouble with the smtp server admin config part.

when trying to send a test email (test email button), i got this error

AxiosError: Request failed with status code 400

Here is the logs :

{
  "reqId": "RuhNvVj63B96p2YAIGIx",
  "level": 0,
  "time": "2025-04-29T14:29:20+00:00",
  "remoteAddr": "192.168.1.10",
  "user": "Admin",
  "app": "core",
  "method": "POST",
  "url": "/settings/admin/mailtest",
  "message": "Sending mail to \"Array\n(\n    [xxxxx@protonmail.com] => Admin\n)\n\" with subject \"Test des paramètres de messagerie\" failed",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0",
  "version": "31.0.2.1",
  "exception": {
    "Exception": "Symfony\\Component\\Mailer\\Exception\\TransportException",
    "Message": "Unable to connect with STARTTLS: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:\nerror:0A000086:SSL routines::certificate verify failed",
    "Code": 0,
    "Trace": [
      {
        "function": "Symfony\\Component\\Mailer\\Transport\\Smtp\\Stream\\{closure}",
        "class": "Symfony\\Component\\Mailer\\Transport\\Smtp\\Stream\\SocketStream",
        "type": "->",
        "args": ["*** sensitive parameters replaced ***"]
      },
      {
        "file": "/var/www/html/3rdparty/symfony/mailer/Transport/Smtp/Stream/SocketStream.php",
        "line": 174,
        "function": "stream_socket_enable_crypto",
        "args": [null, true]
      },
      {
        "file": "/var/www/html/3rdparty/symfony/mailer/Transport/Smtp/EsmtpTransport.php",
        "line": 152,
        "function": "startTLS",
        "class": "Symfony\\Component\\Mailer\\Transport\\Smtp\\Stream\\SocketStream",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/3rdparty/symfony/mailer/Transport/Smtp/EsmtpTransport.php",
        "line": 118,
        "function": "doEhloCommand",
        "class": "Symfony\\Component\\Mailer\\Transport\\Smtp\\EsmtpTransport",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/3rdparty/symfony/mailer/Transport/Smtp/SmtpTransport.php",
        "line": 254,
        "function": "executeCommand",
        "class": "Symfony\\Component\\Mailer\\Transport\\Smtp\\EsmtpTransport",
        "type": "->",
        "args": ["HELO [192.168.1.2]\r\n", [250]]
      },
      {
        "file": "/var/www/html/3rdparty/symfony/mailer/Transport/Smtp/SmtpTransport.php",
        "line": 277,
        "function": "doHeloCommand",
        "class": "Symfony\\Component\\Mailer\\Transport\\Smtp\\SmtpTransport",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/3rdparty/symfony/mailer/Transport/Smtp/SmtpTransport.php",
        "line": 210,
        "function": "start",
        "class": "Symfony\\Component\\Mailer\\Transport\\Smtp\\SmtpTransport",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/3rdparty/symfony/mailer/Transport/AbstractTransport.php",
        "line": 69,
        "function": "doSend",
        "class": "Symfony\\Component\\Mailer\\Transport\\Smtp\\SmtpTransport",
        "type": "->",
        "args": [
          {"__class__": "Symfony\\Component\\Mailer\\SentMessage"}
        ]
      },
      {
        "file": "/var/www/html/3rdparty/symfony/mailer/Transport/Smtp/SmtpTransport.php",
        "line": 137,
        "function": "send",
        "class": "Symfony\\Component\\Mailer\\Transport\\AbstractTransport",
        "type": "->",
        "args": [
          {"__class__": "Symfony\\Component\\Mime\\Email"},
          {"__class__": "Symfony\\Component\\Mailer\\DelayedEnvelope"}
        ]
      },
      {
        "file": "/var/www/html/3rdparty/symfony/mailer/Mailer.php",
        "line": 42,
        "function": "send",
        "class": "Symfony\\Component\\Mailer\\Transport\\Smtp\\SmtpTransport",
        "type": "->",
        "args": [
          {"__class__": "Symfony\\Component\\Mime\\Email"},
          null
        ]
      },
      {
        "file": "/var/www/html/lib/private/Mail/Mailer.php",
        "line": 206,
        "function": "send",
        "class": "Symfony\\Component\\Mailer\\Mailer",
        "type": "->",
        "args": [
          {"__class__": "Symfony\\Component\\Mime\\Email"}
        ]
      },
      {
        "file": "/var/www/html/apps/settings/lib/Controller/MailSettingsController.php",
        "line": 137,
        "function": "send",
        "class": "OC\\Mail\\Mailer",
        "type": "->",
        "args": [
          {"__class__": "OC\\Mail\\Message"}
        ]
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 200,
        "function": "sendTestMail",
        "class": "OCA\\Settings\\Controller\\MailSettingsController",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 114,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          {"__class__": "OCA\\Settings\\Controller\\MailSettingsController"},
          "sendTestMail"
        ]
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/App.php",
        "line": 161,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          {"__class__": "OCA\\Settings\\Controller\\MailSettingsController"},
          "sendTestMail"
        ]
      },
      {
        "file": "/var/www/html/lib/private/Route/Router.php",
        "line": 307,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::",
        "args": [
          "OCA\\Settings\\Controller\\MailSettingsController",
          "sendTestMail",
          {"__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer"},
          {"_route": "settings.mailsettings.sendtestmail"}
        ]
      },
      {
        "file": "/var/www/html/lib/base.php",
        "line": 1025,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->",
        "args": ["/settings/admin/mailtest"]
      },
      {
        "file": "/var/www/html/index.php",
        "line": 24,
        "function": "handleRequest",
        "class": "OC",
        "type": "::",
        "args": []
      }
    ],
    "File": "/var/www/html/3rdparty/symfony/mailer/Transport/Smtp/Stream/SocketStream.php",
    "Line": 171,
    "message": "Sending mail to \"Array\n(\n    [xxxxx@protonmail.com] => Admin\n)\n\" with subject \"Test des paramètres de messagerie\" failed",
    "exception": {},
    "CustomMessage": "Sending mail to \"Array\n(\n    [xxxxx@protonmail.com] => Admin\n)\n\" with subject \"Test des paramètres de messagerie\" failed"
  }
}

EDIT

As mentioned in the NC docs, i’ve added that part to the config.php :

'mail_smtpstreamoptions' => 
  array (
    'ssl' => 
    array (
      'allow_self_signed' => true,
      'verify_peer' => false,
      'verify_peer_name' => false,
    ),
  ),

But still not working

EDIT

It is working. My mistake was in my sender email adress.

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.