[solved] Problem sending test E-Mail

Hi,

Iā€™m trying to setup my Nextcloud E-Mail server for E-Mail notifications. The problem is, after i setup all settings in Admin-Settings (Basic Settings) i get the error after clicking on send test E-Mail like this:

A problem occurred while sending the email. Please revise your settings. (Error: Expected response code 354 but got code "554", with message "554 5.5.1 Error: no valid recipients ")

I have tried all possible settings for my Mail-Server which is in my home network. I also updated the E-Mail address of my admin user to a vaild E-Mail. I tried to send an E-Mail to this address with my thunderbird setup towards my E-Mail server and it worked.

  • send mode is always SMTP
  • authentication methods: none, login
  • ports: 25 (no encryption), 465 (SSL, TLS), 587 (STARTTLS)
  • host: domainname, IP-Address

My E-Mail server is an Synology mail server, that does not require authentication on LAN connections.

My Nextcloud instance is running on a ubuntu 18.04 LTS inside a docker container. I am using the official image with the tag 16 (nextcloud:16), which is actually the apache image.
I am using the following environment variables to initialize the mail setup. All settings are applied after the container has been setup by the startup script:

- SMTP_HOST=mydomain.de
- SMTP_SECURE=tls
- SMTP_PORT=587
- SMTP_AUTHTYPE=login
- MAIL_FROM_ADDRESS=info
- MAIL_DOMAIN=mydomain.de

Does anybody have an idea what could be the problem?

The log file does not contain anything. When i click on send test e-mail the log remains emtpy (i was using tail -f while sending the e-mail).

BR,

Michael

The error message you posted says ā€œno valid recipientā€.
Can you check if the email-adress you are sending to is a real world adress you can receive emails on.
Nextcloud is sending the email to the email-adress you set for your account.

Also in your config ā€œMAIL_FROM_ADDRESS=infoā€ should be ā€œMAIL_FROM_ADDRESS=info@domain.deā€

Can you send email directly from docker server (not from inside container)? If it is linux: something around:
echo "content" | mail "test <test@mydomain.de>" -s "subject"

I think nextcloud already contacted the mail server successfully, then the mail server couldnā€™t find the email you inputted at settings > personal info, hence returning code 554.

Maybe try reading the log in the mail server?

Hi,

thank you for your hints! After doing some ā€˜RTFMā€™ here Nextcloud admin docs i found out that smtp-settings can be store in a seperate config.php file :sweat:. Furthermore this config file then overwrites the settings in the main config.php. This was super confusing to me, because i desperately tried to change and add values in the main config.php without any effect. And something that confused me even more was that the settings i was updating via admin gui disappeared right after i reloaded the settings page.

After taking a look into the container i found that the ā€¦/config/ subfolder contained not only one config.php, but also several other and a smtp.config.php file.

After opening it i found out, that all values are beeing set from the EVN variables defined during container installation like this:

<?php
if (getenv('SMTP_HOST') && getenv('MAIL_FROM_ADDRESS') && getenv('MAIL_DOMAIN')) {
  $CONFIG = array (
    'mail_smtpmode' => 'smtp',
    'mail_smtphost' => getenv('SMTP_HOST'),
    'mail_smtpport' => getenv('SMTP_PORT') ?: (getenv('SMTP_SECURE') ? 465 : 25),
    'mail_smtpsecure' => getenv('SMTP_SECURE') ?: '',
    'mail_smtpauth' => getenv('SMTP_NAME') && getenv('SMTP_PASSWORD'),
    'mail_smtpauthtype' => getenv('SMTP_AUTHTYPE') ?: 'LOGIN',
    'mail_smtpname' => getenv('SMTP_NAME') ?: '',
    'mail_smtppassword' => getenv('SMTP_PASSWORD') ?: '',
    'mail_from_address' => getenv('MAIL_FROM_ADDRESS'),
    'mail_domain' => getenv('MAIL_DOMAIN'),
  );
}

After updating the values to my values i was successfully able to sent out a test e-mail :clap:.

Now, the interesting part is that iā€™m thinking about moving the smtp.config.php outside of the container and then bind mounting it. This was i donā€™t have to configure the E-Mail settings via ENV variables during container installation - but i guess this is just a flavor of how to set up the email settings.

Thanks a lot for the Help!

after trying it out it seems that the domain and the username must be provided seperate like this:

'mail_from_address' => 'info',
'mail_domain' => 'mydomain.de',

when i provide the full address to mail_from_address, i get an error message while sending the test e-mail.

Hello,

I have the same problem.

ā€˜mail_smtpmodeā€™ => ā€˜smtpā€™,
ā€˜mail_sendmailmodeā€™ => ā€˜smtpā€™,
ā€˜mail_from_addressā€™ => ā€˜halloā€™,
ā€˜mail_domainā€™ => ā€˜domain.deā€™,
ā€˜mail_smtphostā€™ => ā€˜xx6.serverdomain.orgā€™,
ā€˜mail_smtpportā€™ => ā€˜25ā€™,
ā€˜mail_smtpsecureā€™ => ā€˜tlsā€™,
ā€˜mail_smtpauthā€™ => 1,
ā€˜mail_smtpnameā€™ => ā€˜hallo@domain.deā€™,
ā€˜mail_smtppasswordā€™ => ā€˜*******ā€™,
ā€˜mail_smtpauthtypeā€™ => ā€˜LOGINā€™,

This doensnā€™t works in Nextcloud, but I have no problems with my E-Mailprogramm. Is there another config, what I have to configure.

Thanks,
Lars

Hi,

have you tried the TLS port 587? Alternatively you may want to try SSL with port 465.