• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question Question: allow_sendmail subscription status cli

Klaas

New Pleskian
Server operating system version
CentOS Linux 7
Plesk version and microupdate number
18.0.51.1
In certain situations we disable the option to allow websites to send e-mails, by disallowing use of sendmail.
We use a script to automate this. The primary command of the script is:
Code:
/usr/sbin/plesk bin subscription_settings -u domain.tld -outgoing_messages_enable_sendmail false
This disables the ability to send e-mail through the website, while the mail accounts keep working.

With Plesk Obsidian 18.0.36.0 I can view the status through:
Code:
plesk sbin mailmng-outgoing --fetch-statistics --with-limits | sed -e 's|"name"|\n"name"|g' | grep domain.tld
example output:
Code:
 plesk sbin mailmng-outgoing --fetch-statistics --with-limits | sed -e 's|"name"|\n"name"|g' | grep domain.tld
"name":"domain.tld","is_main":true}],"out_limit":100,"allow_sendmail":false,"stats":[]},{"domains":[{"mails":[],"out_limit":50,"stats":[],
Output shows 'allow_sendmail":false' for disabled, true for enabled.

When using Plesk Obsidian 18.0.51.1:
Code:
 plesk sbin mailmng-outgoing --fetch-statistics --with-limits | sed -e 's|"name"|\n"name"|g' | grep domain.tld
"name":"domain.tld","is_main":true,"out_limit":500,"stats":[],"mails":[{
The allow_sendmail part is missing.
I am unable to find an alternative route of finding the status. I've looked at different options with mailmng-outgoing and plesk bin subscription information.
Does anyone here know where to find the status of 'allow_sendmail' for an individual subscription?
 
I never used the plesk sbin mailmng-outgoing --fetch-statistics --with-limits command before so I am not entirety sure why the output results are different for version 18.0.36 and 18.0.51. However I suspect that the output format might have changed. The allow_sendmail property is still present in the output though. Currently in 18.0.51 the output object looks like this:

JSON:
{
    "subscriptions": [{
        "out_limit": 100,
        "allow_sendmail": true,
        "stats": [{
            "passed": 1,
            "time": "2023-04-21 16:34"
        }],
        "domains": [{
            "name": "example.com",
            "is_main": true,
            "out_limit": 100,
            "stats": [{
                "passed": 1,
                "time": "2023-04-21 16:34"
            }],
            "mails": [{
                "name": "user",
                "out_limit": 100,
                "stats": [{
                    "passed": 1,
                    "time": "2023-04-21 16:34"
                }]
            }]
        }] 
    }]
}

Do you still have an Plesk server running with version 18.0.36? I am curious to see what the output format for plesk sbin mailmng-outgoing --fetch-statistics --with-limits looks like on version 18.0.36.
 
Hi Kasper,

Thanks for the reply!

For clarity's sake I'll post the results from both
Code:
plesk sbin mailmng-outgoing --fetch-statistics --with-limits
as well as the JSON format you've used which I believe is retrieved through:
Code:
plesk sbin mailmng-outgoing --pretty-print --fetch-statistics --with-limits  --with-zero-counters

Version: 18.0.36.0 allow_sendmail enabled:
Code:
  {
                    "mails": [],
                    "out_limit": -1,
                    "stats": [],
                    "name": "domain.tld",
                    "is_main": true
                }
            ],
            "out_limit": 100,
            "allow_sendmail": true,
            "stats": []
        },

Code:
"name":"domain.tld","is_main":true}],"out_limit":100,"allow_sendmail":true,"stats":[]},{"domains":[{"mails":[],"out_limit":50,"stats":[],

Version: 18.0.36.0 allow_sendmail disabled:
Code:
  {
                    "mails": [],
                    "out_limit": -1,
                    "stats": [],
                    "name": "domain.tld",
                    "is_main": true
                }
            ],
            "out_limit": 100,
            "allow_sendmail": false,
            "stats": []
        },

Code:
"name":"domain.tld","is_main":true}],"out_limit":100,"allow_sendmail":false,"stats":[]},{"domains":[{"mails":[],"out_limit":50,"stats":[],

Version: 18.0.51.1 allow_sendmail enabled:
Code:
"name":"domain.tld","is_main":true,"out_limit":500,"stats":[],"mails":[]},{

Code:
        {
            "out_limit": 500,
            "allow_sendmail": true,
            "stats": [],
            "domains": [
                {
                    "name": "domain.tld",
                    "is_main": true,
                    "out_limit": 500,
                    "stats": [],
                    "mails": []
                }
            ]
        },


Version: 18.0.51.1 allow_sendmail disabled:

Code:
{
            "out_limit": 500,
            "allow_sendmail": false,
            "stats": [],
            "domains": [
                {
                    "name": "domain.tld",
                    "is_main": true,
                    "out_limit": 500,
                    "stats": [],
                    "mails": []
                }
            ]
        },

Code:
"name":"domain.tld","is_main":true,"out_limit":500,"stats":[],"mails":[{

Result
The JSON styled output is different on the newer server allow_sendmail comes before the domain.
I think this explains the output of my command too. My command cuts the lines based on the 'name' field. In previous versions this was the first field mentioned. If I read through the raw data without adding sed I see this confirmed too. The data I need is before the name field.

As far as I'm concerned this resolves my issues with this. Thanks for the second pair of eyes. If you have further questions about this please let me know too!
 
Thank you for posting back the output result for version 18.0.36. My suspicion was right, the output format got changed around a bit.

Good to hear you've got your issue resolved.
 
Hmm, there is an issue still.
I'm working in multiple environments and I want a universal solution to this... Yay legacy.

A JSON parser is not an option within my environments and due to the differences grabbing it from 'plesk sbin mailmng-outgoing'.

My options right now are
1) Get the information out of psa database, based on the assumption that this is stored in a database
2) Find the actual file/configuration that gets changed when disabling sendmail for a subscription.

I haven't had luck with option one, so starting on option two.
If you have any recommendations that avoid using 'plesk sbin mailmng-outgoing', I'd love to hear it.
 
That's a tough one. The CLI doesn't seem to have many options for getting the send_mail status. Nor does the XML API (Although it might, but I could not find any conclusive documentation on it.)

Perhaps you can amend your script to run the plesk sbin mailmng-outgoing command based on the Plesk version (plesk -v)? That way you still have one script that you can use for multiple environments. Not the nicest solution, but a practical one.
 
Went for another solution. I generally want to avoid software but I've installed 'jq' on our servers.

Code:
plesk sbin mailmng-outgoing --fetch-statistics --with-limits  --with-zero-counters | jq -c '.[] | .[] | select(.domains[].name=="domainname.tld")'

This shows everything I need for the relevant domain:
Version: 18.0.51.1
Code:
{"out_limit":500,"allow_sendmail":false,"stats":[],"domains":[{"name":"domain.tld","is_main":true,"out_limit":500,"stats":[],"mails":[]},{"name":"test.domain.tld","is_main":false,"out_limit":500,"stats":[],"mails":[]}]}

Version: 18.0.36.0
Code:
{"domains":[{"mails":[],"out_limit":50,"stats":[],"name":"domain.tld","is_main":true}],"out_limit":100,"allow_sendmail":false,"stats":[]}
Thanks for all the suggestions! Definitely helped to look for different solutions!
 
Back
Top