Success when sharing the file
Error message even though it's been successfully shared so it creates confusion
Operating system:
Web server:
Database:
PHP version:
Nextcloud version: (see Nextcloud admin page) 13.0.0
)
Updated from an older Nextcloud/ownCloud or fresh install: Updated
Where did you install Nextcloud from: Web
Signing status:
Signing status
Login as admin user into your Nextcloud and access
http://example.com/index.php/settings/integrity/failed
paste the results here.
No errors have been found.

List of activated apps:
App list
If you have access to your command line run e.g.:
sudo -u www-data php occ app:list
from within your Nextcloud installation folder
Nextcloud configuration:
Config report
If you have access to your command line run e.g.:
sudo -u www-data php occ config:list system
from within your Nextcloud installation folder
or
Insert your config.php content here.
Make sure to remove all sensitive content such as passwords. (e.g. database password, passwordsalt, secret, smtp password, …)
Are you using external storage, if yes which one: local/smb/sftp/...
Are you using encryption: yes/no
Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...
LDAP config
With access to your command line run e.g.:
sudo -u www-data php occ ldap:show-config
from within your Nextcloud installation folder
Without access to your command line download the data/owncloud.db to your local
computer or access your SQL server remotely and run the select query:
SELECT * FROM `oc_appconfig` WHERE `appid` = 'user_ldap';
Eventually replace sensitive data as the name/IP-address of your LDAP server or groups.
Browser:
Operating system:
Web server error log
Insert your webserver log here
Nextcloud log
Insert your Nextcloud log here
Browser log
Insert your browser log here, this could for example include:
a) The javascript console log
b) The network log
c) ...

Nobody?
Could you please fill out the template? These information are requested for a good reason.
So for sharing you entered
admin@
as an email address to share a file/ folder?
Or was the email address really like
[email protected]
?
I changed the following lines to fix the email sending issue. I've added !defined('INTL_IDNA_VARIANT_UTS46') to the condition.
File: lib/private/Mail/Mailer.php
Line: 207
Code:
if (!function_exists('idn_to_ascii') || !defined('INTL_IDNA_VARIANT_UTS46') || strpos($email, '@') === false) {
File: lib/private/Mail/Message.php
Line: 68
Code:
if (!function_exists('idn_to_ascii') || !defined('INTL_IDNA_VARIANT_UTS46')) {
It also fixed #8409 for me. Got the idea from #239. 😉
@denunv I don't know how you did that, but thanks, that fixed all my issues on a vps. Man I was getting fustrated. lol
You can also fix the error by uploading these two files from previous OwnCloud version 9.1.7.
https://owncloud.org/download/
lib/private/Mail/Mailer.php
lib/private/Mail/Mail.php
@peter-parker I assume next cloud and own cloud are similar or based off each other?
@LukasReschke @nickvergessen Please review my PR https://github.com/nextcloud/server/pull/9095 based on the change suggested by @denunv above.
if i understand this correct, #9095 should fix this for NC13 (released via 13.0.2) and #9100 in master (for NC14+)...
but why do i still get this error after updating to 13.0.2.1 (build 2018-04-26)???
--> quick info about my setup: i haven't setup a mail-server for notifications, and use the IMAP-backend for user-management. - activity-notifications still work as ever.
btw: it seems (#6744) this issue already appeared in NC12 (at least with LDAP-backend).
@DJCrashdummy It would be helpful if you could give some more details. When does the error occur?What message appears in your log (including the destination email address)?
@JaredBoone thanks for your reply!
this issue still occur as mentioned by the OP when sharing a folder with an other user.
the log only shows
Failed to send share by email: Address in mailbox given
[SHORT [email protected]]does not comply with RFC 2822, 3.6.2.
where SHORT NAME is _"the short name of the software"_ (also containing a space) given in the defaults.php via the active theme.
--> after some testing i'm sure it hast to do with the theming, because without a theme, everything seems to work.
another thing i can confirm is, that getName() is displayed in the error-message (although getHTMLName() with the same name is available)... also using a wherever didn't change anything.
for the record: at both users personal page a valid email-address is entered. and also the activity-mails work for for all users as ever!
PS: with the theme active it gets even worse if you try to share by mail; you only get the message/info _"Failed to send share by mail."_ instead and nothing gets shared.
@DJCrashdummy I suspect the error is caused by the "From:" field, not the "To:" field. On my server, that "From:" field is populated with "noreply@[my.company].com". Here are some questions that might help debug this: Have you tested the mailer configuration (Admin->Additional Settings->Test email settings)? Does your config.php file have a reasonable value (with no spaces) in the 'mail_from_address' field (eg 'noreply')? Do you have Nextcloud configured to send mail using php, smtp, or sendmail ('mail_smtpmode' in config.php)? What surrounding log statements do you see if you enable debug level logging ('loglevel' => 0 in config.php) and enable the mail_smtpdebug parameter in config.php? Since you mention that it seems to be related to the theme, are you using the official Nextcloud Theming App or a custom theme ('theme' in config.php)? Also, you may want to read the Troubleshooting section here: https://docs.nextcloud.com/server/13/admin_manual/configuration_server/email_configuration.html Hope this helps.
@JaredBoone thanks for responding and hopefully getting this little nasty bug!
Since you mention that it seems to be related to the theme, are you using the official Nextcloud Theming App or a custom theme ('theme' in config.php)?
yes, i'm using a theme via 'theme' => 'theme-folder', in the config.php. - i haven't checked if this error also occurs with the theming-app.
I suspect the error is caused by the "From:" field, not the "To:" field.
i'm pretty sure about this, since all users still get mails from the nextcloud-server (e.g. activity-messages still work as ever in every setting), just the sharing makes problems.
On my server, that "From:" field is populated with "noreply@[my.company].com".
well... the addresser from my server without a theme look like Nextcloud <[email protected]> and with an active theme (where the error occurs) SHORT NAME <[email protected]> (but no idea if for the SHORT NAME the getName() or getHTMLName() sting is used).
Have you tested the mailer configuration (Admin->Additional Settings->Test email settings)?
interesting... again without a theme everything works as it should and the addresser is Nextcloud <[email protected]>, but with the theme active no mail is sent and i just get an error:
A problem occurred while sending the email. Please revise your settings. (Error: Address in mailbox given [SHORT [email protected]] does not comply with RFC 2822, 3.6.2.)
Does your config.php file have a reasonable value (with no spaces) in the 'mail_from_address' field (eg 'noreply')? Do you have Nextcloud configured to send mail using php, smtp, or sendmail ('mail_smtpmode' in config.php)?
no, i just use php for mails... so there aren't any mail-setting in the config.php.
What surrounding log statements do you see if you enable debug level logging ('loglevel' => 0 in config.php) and enable the mail_smtpdebug parameter in config.php?
unfortunately i guess nothing really useful... in case everything works i get 3 entries in the log:
Level | App | Message | Time
-- | -- | -- | --
Debug | share | Send share notification to [email protected] for share with ID 24 | 2018-06-07T06:00:00+0000
Debug | core | Sent mail to "Array ( [[email protected]] => ) " with subject "[email protected] hat „Notes“ mit Dir geteilt" | 2018-06-07T06:00:00+0000
Info | admin_audit | The folder "/Notes" with ID "17" has been shared to the user "[email protected]" with permissions "15" (Share ID: 24) | 2018-06-07T06:00:00+0000
and with the error while sharing, just 2 of them are missing, but nothing else shows up:
Level | App | Message | Time
-- | -- | -- | --
Info | admin_audit | The folder "/Notes" with ID "17" has been shared to the user "[email protected]" with permissions "15" (Share ID: 25) | 2018-06-07T06:10:00+0000
i tested some additional things and i'm pretty sure it has to do with the getName() and/or getHTMLName() and how they are used:
getName() everything seems to work.getHTMLName() seems to have no relevance at all... in this case.SHORT NAME) in both of them!getName(). --> no idea for now if there are other apps with this problem...!?@DJCrashdummy I agree that you seem to have found a bug - I don't think the mailer should be using the "short name" field from a Theme as part of the email address at all and if it does then it should do something about whitespace. However I don't feel comfortable attempting to fix this myself. Since this GitHub Issue has already been closed against a Pull Request, I think you'll need to create a new Github Issue. I recommend filling out all of the details in the template, summarizing the information from our thread, pasting a link to this issue, and also providing steps to reproduce, for example:
1) Create a theme with a getName() function that returns a string with whitespace
2) Share a file with a user
3) Observe RFC mail error in logs
I know this seems like a lot of work, but that's how open source software gets better. Thanks for participating.
Most helpful comment
I changed the following lines to fix the email sending issue. I've added
!defined('INTL_IDNA_VARIANT_UTS46')to the condition.File: lib/private/Mail/Mailer.php
Line: 207
Code:
if (!function_exists('idn_to_ascii') || !defined('INTL_IDNA_VARIANT_UTS46') || strpos($email, '@') === false) {File: lib/private/Mail/Message.php
Line: 68
Code:
if (!function_exists('idn_to_ascii') || !defined('INTL_IDNA_VARIANT_UTS46')) {It also fixed #8409 for me. Got the idea from #239. 😉