Duplicate system emails?

What is System Overide email account? It’s basically a duplicate of system email account. Did I set up something wrong, or is there a purpose?

Hello Vincent,

this system override outbound mailer is being displayed / created, when you untick the box in the email settings:

Now, the system messages would be sent from the users outgoing mail account, not the system mail account anymore.

There are some more details in the code:

but not in the documentation so far.

Is everything working or do some emails not go through?

1 Like

I don’t want users to be able to use the “system” account only their own account or group account. So it IS unchecked

It’s confusing because when the user goes to send an email, the FROM dropdown STILL SHOWS 2 system email accounts. Since the box is unchecked they should not even see them at all. If the user attempts to send using those two CRM (system) email accounts, there is an error. They CAN use the TEAM (group) account.

I don’t see any settings how to just hide those from users.

Thanks

Are you possibly using SuiteCRM 8 after upgrading a SuiteCRM 7 instance?
In SuiteCRM 7 > Admin > Email Settings there were these 2 options:

The first one’s name is is notify_allow_default_outbound
the second field’s name is mail_allowusersend

:one: mail_allowusersend

  • This is the name of the form field (checkbox) that the administrator selects in Admin → Email Settings.
  • It’s linked to the HTTP request ($_REQUEST['mail_allowusersend']) when the form is submitted.
  • It serves as a temporary input and is not saved directly in config.php.

:two: email_allow_send_as_user

  • This is the actual configuration key in SuiteCRM ($configurator->config['email_allow_send_as_user']).
  • It defines whether users can send emails using their personal SMTP account or only the system-wide SMTP.
  • It’s saved in config.php and read by the system to determine email-sending behavior.

In practice

  • When the admin selects the “Allow users to send email” checkbox:
    1. The form sends mail_allowusersend = '1'.
    2. SuiteCRM reads $_REQUEST['mail_allowusersend'].

For any further details please have a look at: [public/legacy/modules/EmailMan/controller.php](SuiteCRM-Core/public/legacy/modules/EmailMan/controller.php at 65f09ce2f05eab5720648cc609318472df062710 · SuiteCRM/SuiteCRM-Core · GitHub you’ll find
$configurator->config['email_allow_send_as_user'] = (isset($_REQUEST['mail_allowusersend']) && $_REQUEST['mail_allowusersend'] == '1') ? true : false;

No I started with 8.81 and am now running 8.9.0

Only “Users may send as this account’s identity” is there.

Since it’s unchecked, they cannot actually send from system email, but the two system email account still show in dropdown. If they attempt to send from any of those two, there is an error message. They should NOT see those system email options at all.

Hi @creativologist,
I’ve gone through your same path from a 8.8 to 8.9.
I was able to notice the difference between the current and the previous view of the Email Settings page

8.8

Maybe there was something different in your instance than in a vanilla one (as i used) in fact i’m not able to reproduce the issue;

have you tried to save again your Email Settings?
Check-save-uncheck-save
Normally a regular user shouldn’t be able to see the system Outgoing account if that option is unchecked:
image

In addition, if you can access your DB directly, you can delete the unwanted Outgoing system record from this table:
outbound_email

I went into DB and deleted the System Override Account

Now I use 1 system, 1 group, 1 personal

To reproduce:
I EDITED my personal profile, scrolled all the bottom
My personal email account is there, set to use suitecrm client. Clicked settings, and closed the box

Then the SYSTEM OVERRIDE account reappeared

And users can see both the GROUP ,System and System override account in the send to dropdown

I can live with the bug of the system override account showing up but I can’t have users see the accounts since the box is unchecked and they are not allowed.

Hi @creativologist, have you check the legacy_email_behaviour option in config.php ?
Compose Email 'From' Dropdown Behaviour :: SuiteCRM Documentation.
Is it disabled?

By the way the responsible for populating the selectable Outgoing Accounts is this function:

public function action_getFromFields()

in

public/legacy/modules/Emails/EmailsController.php

Hi @LionSolution Nice to meet you here!

1 Like

I changed that to true but had no effect. Are you sure it’s not THIS file?
EmailsControllerActionGetFromFields.php ?

I can’t code php myself.

“I n addition to the above it will also show the System Email if the Users may send as this account’s identity option is enabled in the Administration > Email Settings page.”

The frustrating part is that above is DISABLED. Plus that duplicate CRM System Override account keeps popping up in there.

please in

/public/legacy/include/OutboundEmail/OutboundEmail.php

try to replace

    /**
     *  Determine if the user is allowed to use the current system outbound connection.
     */
    public function isAllowUserAccessToSystemDefaultOutbound()
    {
        $allowAccess = false;

        // first check that a system default exists
        $q = "SELECT id FROM outbound_email WHERE type = 'system'";
        $r = $this->db->query($q);
        $a = $this->db->fetchByAssoc($r);
        if (!empty($a)) {
            // next see if the admin preference for using the system outbound is set
            $admin = BeanFactory::newBean('Administration');
            $admin->retrieveSettings('', true);
            if (isset($admin->settings['notify_allow_default_outbound'])
                && $admin->settings['notify_allow_default_outbound'] == 2
            ) {
                $allowAccess = true;
            }
        }

        return $allowAccess;
    }

with

   /**
     *  Determine if the user is allowed to use the current system outbound connection.
     */
    public function isAllowUserAccessToSystemDefaultOutbound()
    {
        $allowAccess = false;

        // first check that a system default exists
        $q = "SELECT id FROM outbound_email WHERE type = 'system'";
        $r = $this->db->query($q);
        $a = $this->db->fetchByAssoc($r);
		$authenticatedUser = get_authenticated_user();
        if (!empty($a)) {
            // next see if the admin preference for using the system outbound is set
            $admin = BeanFactory::newBean('Administration');
            $admin->retrieveSettings('', true);
            if (isset($admin->settings['notify_allow_default_outbound'])
                && $admin->settings['notify_allow_default_outbound'] == 2
				&& !is_admin($authenticatedUser)
            ) {
                $allowAccess = true;
            }
        }

        return $allowAccess;
    }

I’ve added a check:
&& !is_admin($authenticatedUser)
This will force the controller to allow the User to select system Outgoing Accounts only if he’s an admin

Sorry, still persists.

As a reminder, the user just SEES the system accounts in the dropdown.

If they attempt to send they cannot and get this error

“Unexpected error when calling action”

So it’s not about “selecting” and more about “hiding” accounts they don’t have access to.

Plus every time I log in as user and edit the settting in email account it creates another system override account which appears in the dropdown. Now there are 4 system accounts

@LionSolution Are you out of ideas on this one?

Hi @creativologist, please edit in
/public/legacy/modules/Emails/EmailUI.php this function:

public function getFromAllAccountsArray($ie, $ret)
    {
        global $current_user;
        global $app_strings;

        $ret['fromAccounts'] = array();
        if (!isset($ret['to']) && !empty($ret['from'])) {
            $ret['fromAccounts']['status'] = false;

            return $ret;
        }
        $ieAccountsFull = $ie->retrieveAllByGroupIdWithGroupAccounts($current_user->id);
        $foundInPersonalAccounts = false;
        $foundInGroupAccounts = false;
        $foundInSystemAccounts = false;

        //$toArray = array();
        if ($ret['type'] == "draft") {
            $toArray = explode(",", $ret['from']);
        } else {
            $toArray = $ie->email->email2ParseAddressesForAddressesOnly($ret['to']);
        } // else
        foreach ($ieAccountsFull as $k => $v) {
            $storedOptions = sugar_unserialize(base64_decode($v->stored_options));
            if (array_search_insensitive($storedOptions['from_addr'], $toArray)) {
                if ($v->is_personal) {
                    $foundInPersonalAccounts = true;
                    break;
                } else {
                    $foundInGroupAccounts = true;
                } // else
            } // if
        } // foreach

        $oe = new OutboundEmail();
        $system = $oe->getSystemMailerSettings();

        $return = $current_user->getUsersNameAndEmail();
        $return['name'] = from_html($return['name']);
        $useMyAccountString = true;

        if (empty($return['email'])) {
            $systemReturn = $current_user->getSystemDefaultNameAndEmail();
            $return['email'] = $systemReturn['email'];
            $return['name'] = from_html($systemReturn['name']);
            $useMyAccountString = false;
        } // if

        $myAccountString = '';
        if ($useMyAccountString) {
            $myAccountString = " - {$app_strings['LBL_MY_ACCOUNT']}";
        } // if

        if (!empty($system->id)) {
            $admin = BeanFactory::newBean('Administration');
            $admin->retrieveSettings(); //retrieve all admin settings.
            if (in_array(trim($return['email']), $toArray)) {
                $foundInSystemAccounts = true;
            } // if
        } // if

        if (!$foundInPersonalAccounts && !$foundInGroupAccounts && !$foundInSystemAccounts) {
            $ret['fromAccounts']['status'] = false;

            return $ret;
        } // if

        $ieAccountsFrom = array();
        foreach ($ieAccountsFull as $k => $v) {
            $storedOptions = sugar_unserialize(base64_decode($v->stored_options));
            $storedOptionsName = from_html($storedOptions['from_name']);

            $selected = false;
            if (array_search_insensitive($storedOptions['from_addr'], $toArray)) {
                //if ($ret['to'] == $storedOptions['from_addr']) {
                $selected = true;
            } // if
            if ($foundInPersonalAccounts) {
                if ($v->is_personal) {
                    $ieAccountsFrom[] = array(
                        "value" => $v->id,
                        "selected" => $selected,
                        "text" => "{$storedOptionsName} ({$storedOptions['from_addr']})"
                    );
                } // if
            } else {
                $ieAccountsFrom[] = array(
                    "value" => $v->id,
                    "selected" => $selected,
                    "text" => "{$storedOptionsName} ({$storedOptions['from_addr']}) - {$app_strings['LBL_EMAIL_UPPER_CASE_GROUP']}"
                );
            } // else
        } // foreach

        if (!empty($system->id)) {
            if (!$foundInPersonalAccounts && !$foundInGroupAccounts && $foundInSystemAccounts) {
                $ieAccountsFrom[] = array(
                    "value" => $system->id,
                    "selected" => true,
                    "text" =>
                        "{$return['name']} ({$return['email']}){$myAccountString}"
                );
            } else {
                $ieAccountsFrom[] = array(
                    "value" => $system->id,
                    "text" =>
                        "{$return['name']} ({$return['email']}){$myAccountString}"
                );
            } // else
        } // if

        $ret['fromAccounts']['status'] = ($foundInPersonalAccounts || $foundInGroupAccounts || $foundInSystemAccounts) ? true : false;
        $ret['fromAccounts']['data'] = $ieAccountsFrom;

        return $ret;
    } // fn

change it to

public function getFromAllAccountsArray($ie, $ret)
{
    global $current_user;
    global $app_strings;

    $ret['fromAccounts'] = array();
    if (!isset($ret['to']) && !empty($ret['from'])) {
        $ret['fromAccounts']['status'] = false;
        return $ret;
    }

    $ieAccountsFull = $ie->retrieveAllByGroupIdWithGroupAccounts($current_user->id);
    $foundInPersonalAccounts = false;
    $foundInGroupAccounts = false;
    $foundInSystemAccounts = false;

    if ($ret['type'] == "draft") {
        $toArray = explode(",", $ret['from']);
    } else {
        $toArray = $ie->email->email2ParseAddressesForAddressesOnly($ret['to']);
    }

    foreach ($ieAccountsFull as $k => $v) {
        $storedOptions = sugar_unserialize(base64_decode($v->stored_options));
        if (array_search_insensitive($storedOptions['from_addr'], $toArray)) {
            if ($v->is_personal) {
                $foundInPersonalAccounts = true;
                break;
            } else {
                $foundInGroupAccounts = true;
            }
        }
    }

    $oe = new OutboundEmail();
    $system = $oe->getSystemMailerSettings();

    $return = $current_user->getUsersNameAndEmail();
    $return['name'] = from_html($return['name']);
    $useMyAccountString = true;

    if (empty($return['email'])) {
        $systemReturn = $current_user->getSystemDefaultNameAndEmail();
        $return['email'] = $systemReturn['email'];
        $return['name'] = from_html($systemReturn['name']);
        $useMyAccountString = false;
    }

    $myAccountString = '';
    if ($useMyAccountString) {
        $myAccountString = " - {$app_strings['LBL_MY_ACCOUNT']}";
    }

    if (!empty($system->id)) {
        $admin = BeanFactory::newBean('Administration');
        $admin->retrieveSettings();
        if (in_array(trim($return['email']), $toArray)) {
            $foundInSystemAccounts = true;
        }
    }

    // đźš« Prevent non-admins from accessing system accounts
    if (!$current_user->is_admin) {
        $foundInSystemAccounts = false;
    }

    if (!$foundInPersonalAccounts && !$foundInGroupAccounts && !$foundInSystemAccounts) {
        $ret['fromAccounts']['status'] = false;
        return $ret;
    }

    $ieAccountsFrom = array();
    foreach ($ieAccountsFull as $k => $v) {
        $storedOptions = sugar_unserialize(base64_decode($v->stored_options));
        $storedOptionsName = from_html($storedOptions['from_name']);

        $selected = false;
        if (array_search_insensitive($storedOptions['from_addr'], $toArray)) {
            $selected = true;
        }

        if ($foundInPersonalAccounts) {
            if ($v->is_personal) {
                $ieAccountsFrom[] = array(
                    "value" => $v->id,
                    "selected" => $selected,
                    "text" => "{$storedOptionsName} ({$storedOptions['from_addr']})"
                );
            }
        } else {
            $ieAccountsFrom[] = array(
                "value" => $v->id,
                "selected" => $selected,
                "text" => "{$storedOptionsName} ({$storedOptions['from_addr']}) - {$app_strings['LBL_EMAIL_UPPER_CASE_GROUP']}"
            );
        }
    }

    // âś… Only admins can see system outgoing accounts
    if (!empty($system->id) && $current_user->is_admin) {
        if (!$foundInPersonalAccounts && !$foundInGroupAccounts && $foundInSystemAccounts) {
            $ieAccountsFrom[] = array(
                "value" => $system->id,
                "selected" => true,
                "text" => "{$return['name']} ({$return['email']}){$myAccountString}"
            );
        } else {
            $ieAccountsFrom[] = array(
                "value" => $system->id,
                "text" => "{$return['name']} ({$return['email']}){$myAccountString}"
            );
        }
    }

    $ret['fromAccounts']['status'] = ($foundInPersonalAccounts || $foundInGroupAccounts || $foundInSystemAccounts) ? true : false;
    $ret['fromAccounts']['data'] = $ieAccountsFrom;

    return $ret;
}

it’s updated so that only admin users can see and use system outgoing email accounts, while normal users will see only their personal and group accounts.

I appreciate the effort but no change

This is strange… have you already tried to empty the cache folder and to delete the browser history?

I’ve done rebuilds, and tried a different browser.
I’ve run bin/console cache:clear and $ rm -r cache.

No luck.