Plesk

Unable to send email via PHP on a Plesk server: Rejecting message: system user uid=’XXXX’ is not allowed to send mail

Symptoms

Cause

Product issues:

  • #PPP-52477 "The plesk repair mail <domain|mail-address> command now repairs the Outgoing Mail Control subsystem more reliably."
    Fixed in:

Resolution

Please consider updating your server so the newly created subscriptions are not affected.

For the already affected subscriptions, perform the following:

Automatic solution

  1. Connect to the server via SSH.

  2. Execute the command below to fix issues with the Outgoing mail limits database:

    # plesk repair mail

Manual solution

  1. Connect to the server via SSH.

  2. Create a backup of the outgoing mail database:

    # cp -a /var/lib/plesk/mail/outgoing/data.db{,.backup}

  3. Add the missing system users into the database:

    # plesk db -Ne "SELECT login FROM sys_users" | while read login; do sqlite3 /var/lib/plesk/mail/outgoing/data.db "SELECT * FROM sysusers WHERE name = '$login'; " | grep -q '.'; [[ $? -ne 0 ]] && echo $login; done | while read login; do plesk db -Ne "SELECT d.name, su.login FROM domains d, hosting h, sys_users su WHERE d.id=h.dom_id AND h.sys_user_id=su.id AND su.login = '$login' AND webspace_id = 0"; done | while read domain sysuser; do echo "Fixing: $domain --> $sysuser"; plesk sbin mailmng-outgoing --add-subscription --main-domain-name="$domain"; plesk sbin mailmng-outgoing --add-sysuser --main-domain-name="$domain" --sysuser="$sysuser" ; done