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

The caller of rcmail_send_mdn function doesn't accept a string as smtp_error #7475

Closed
gajeitos opened this issue Jul 6, 2020 · 5 comments
Closed

Comments

@gajeitos
Copy link

gajeitos commented Jul 6, 2020

I'm writing a plugin that uses the message_before_send hook. The plugin needs to return an internationalized error so I'm returning the error as a string. The documentation indicates it is allowed:

error: Error message as string or arguments to be passed to rcube::gettext(). Used with abort=true

But in the particular case that a read receipt submission fails I get a PHP warning when the error is shown:

PHP Warning: Illegal string offset 'vars' in /srv/www/htdocs/roundcube/program/steps/mail/show.inc on line 124
PHP Warning: Illegal string offset 'label' in /srv/www/htdocs/roundcube/program/steps/mail/show.inc on line 124

I think the problems is that program/steps/mail/show.inc is not expecting the function rcmail_send_mdn returns an error string and it should work in the same way that rcmail_sendmail->deliver_message.

@alecpl
Copy link
Member

alecpl commented Jul 8, 2020

We indeed do not support string error in all places that use deliver_message() method. This will need to be fixed.

You can return an array containing 'label' and 'vars' instead, this should be supported everywhere.

@alecpl alecpl added this to the 1.5-beta milestone Jul 8, 2020
@gajeitos
Copy link
Author

You can return an array containing 'label' and 'vars' instead, this should be supported everywhere.

I tried but I'm not able to get it to work, when I use the array with label and vars the translation is not done, I only get the label as the translated text.
I think it is because the translations are in a file in the localization directory of my plugin.
I found that the function text_exists is being called without a domain (plugin name) so the text is not found.
I'm doing or interpreting something wrong?

@alecpl
Copy link
Member

alecpl commented Jul 11, 2020

Your label should be in a form of <plugin-name>.<label> and of course you're responsible for loading the plugin localization.

@gajeitos
Copy link
Author

Thank you, it works!

@alecpl
Copy link
Member

alecpl commented Jul 18, 2020

Fixed.

@alecpl alecpl closed this as completed Jul 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants