email sending settings

I have now updated from 7.10.4 to 7.10.5 and ask to configure email settings as if I had no SMTP configuration. I configured it again but it does not save the settings and it still asks you to configure it with the red message at the top.

Looking deeper, my old sending settings are still there, only the new ones are not being saved and this message persists.

Looking at the logs in php I have nothing other than the warnings as usual, but in suitecrm.log after the update is full with:

Mon May 21 14:15:04 2018 [1122441][1][FATAL]  Query Failed: SELECT aos_quotes.id AS id FROM aos_quotes  WHERE aos_quotes.expiration > aos_quotes.today AND aos_quotes.expiration <= DATE_ADD(aos_quotes.today, INTERVAL + 7 day) AND aos_quotes.deleted = 0 : MySQL error 1054: Unknown column 'aos_quotes.today' in 'where clause'
Mon May 21 14:15:04 2018 [1122441][1][FATAL] Mysqli_query failed.
Mon May 21 14:15:04 2018 [1122441][1][FATAL]  Query Failed: SELECT aos_quotes.id AS id FROM aos_quotes  WHERE aos_quotes.expiration > DATE_ADD(aos_quotes.today, INTERVAL + 7 day) AND aos_quotes.deleted = 0 : MySQL error 1054: Unknown column 'aos_quotes.today' in 'where clause'

It does not seem to refer to emails but to a new table not created, I may be wrong.

It seems that the problem occurs with the chrome browser, I’m not sure, but when I did the fill process with Edge, it was saved normally, not tested in other browsers.

PS.: Sorry, I forgot to mention that I also unchecked the mailbox for sending emails to the assigned one.

Hi, thank you for pointing me to this post, I do have the same issue, as mentioned here
I do not have the Edge browser, so I cannot confirm your findings, but I checked either with Safari and Firefox, and in both cases the issue is there.
I have found a list of errors in php_errors.log, they were not there before the upgrade:

[21-May-2018 18:09:42 Europe/Rome] PHP Notice:  Undefined index: mail_smtptype in /opt/SuiteCRM/modules/EmailMan/views/view.config.php on line 116
PHP Stack trace:
PHP   1. {main}() /opt/SuiteCRM/index.php:0
PHP   2. SugarApplication->execute() /opt/SuiteCRM/index.php:52
PHP   3. EmailManController->execute() /opt/SuiteCRM/include/MVC/SugarApplication.php:109
PHP   4. EmailManController->processView() /opt/SuiteCRM/include/MVC/Controller/SugarController.php:375
PHP   5. ViewConfig->process() /opt/SuiteCRM/include/MVC/Controller/SugarController.php:432
PHP   6. ViewConfig->display() /opt/SuiteCRM/include/MVC/View/SugarView.php:207
PHP Notice:  Undefined index: mail_smtpserver in /opt/SuiteCRM/modules/EmailMan/views/view.config.php on line 117
PHP Notice:  Undefined index: mail_smtpport in /opt/SuiteCRM/modules/EmailMan/views/view.config.php on line 118
[...] <-- same Stack trace here
PHP Notice:  Undefined index: mail_smtpuser in /opt/SuiteCRM/modules/EmailMan/views/view.config.php on line 119
[...]
PHP Notice:  Undefined index: mail_smtpauth_req in /opt/SuiteCRM/modules/EmailMan/views/view.config.php on line 120
[...]
PHP Notice:  Undefined index: mail_smtpssl in /opt/SuiteCRM/modules/EmailMan/views/view.config.php on line 122
[...]
PHP Notice:  Undefined index: mail_sendtype in /opt/SuiteCRM/modules/EmailMan/views/view.config.php on line 136

These errors seem related to the issue, but this is as far as I can go as I’m not a php expert. The errors refer to this file:
view.config.php
but it was modified 4 months ago, I cannot tell why they appear now.

The problem is at modules/Administration/Administration.php, in function retrieveSetting:
in Version 7.10.5

foreach ($oe->field_defs as $def) {
                // fixes installer php notice
                if (!array_key_exists($def, $this->settings)) {
                    continue;
                }

                if (strpos($def, "mail_") !== false) {
                    $this->settings[$def] = $oe->$def;
                }
                if (strpos($def, "smtp") !== false) {
                    $this->settings[$def] = $oe->$def;
                }
            }

In 7.9.5 version:

foreach ($oe->field_defs as $def) {
                if (strpos($def, "mail_") !== false)
                    $this->settings[$def] = $oe->$def;
            }

So the mail_smtpserver and other key starting with mail_ are not being added to $this->settings

i’ll try to move code

// fixes installer php notice
                if (!array_key_exists($def, $this->settings)) {
                    continue;
                }

to follow

                if (strpos($def, "smtp") !== false) {
                    $this->settings[$def] = $oe->$def;
                }
12 Likes

Had same issue, changed order in Administration.php as advised by NKA, settings now being saved.
Thank you for post.

That worked for me too - thanks!

The configuration message is gone and the configuration is saved, the only problem in my case is that the error notification in the suitecrm logs reappeared.

I had the same issue and your fix solved the problem for me. Thank you.

Same issues and it worked perfect , Thank You!

This has worked for me also, thanks.

Thank you @NKA ! work for me right away !

This is fixed for who need :

            foreach ($oe->field_defs as $def) {

                if (strpos($def, "mail_") !== false) {
                    $this->settings[$def] = $oe->$def;
                }
                if (strpos($def, "smtp") !== false) {
                    $this->settings[$def] = $oe->$def;
                }
                // fixes installer php notice at Top
                if (!array_key_exists($def, $this->settings)) {
                    continue;
                }				
            }
1 Like

It’s working in my case. Thank You :slight_smile:

Moving that bit of code to the end of the function is the same as removing it. If a certain condition happens, it “continues”, meaning it skips the rest of the code in the “for each” loop for the current iteration. If you move it to the end it will never have any effect.

I understand the move seems to work for many people as a work around, but that code (even if buggy) must be there for a reason, and I am not sure of when it can be useful and necessary.

The latest versions seem to have this updated, maybe it’s better to try the current code instead:

https://github.com/salesagility/SuiteCRM/blame/master/modules/Administration/Administration.php#L178

… although I can’t guarantee that will work, it’s just something to try.

1 Like