How to turn Mail Service off for new subscriptions by default

Created:

2016-11-16 13:24:10 UTC

Modified:

2017-04-24 11:36:52 UTC

0

Was this article helpful?


Have more questions?

Submit a request

How to turn Mail Service off for new subscriptions by default

Applicable to:

  • Plesk 10.4 for Linux

Question

How to turn Mail Service off for new subscriptions by default? Even if I set Mailboxes to in the Service Plan, Mail Service is still turned on.

Answer

It is possible to work around the problem using Event Manager:

  1. Create a Service Plan which you want to use as a plan without mail service. Let us assume it is called Mail off .

  2. Go to Tools & Setting > Event Manager > Add New Event Handler .

  3. Select Event - Default domain (the first domain added to a subscription/webspace) created.

  4. Set needed Priority.

  5. Set User: root .

  6. Specify the Command, e.g, /tmp/mailservice_off.sh .

  7. Create a script named /tmp/mailservice_off.sh in a shell, and set the necessary permissions for it. The script should contain this code:

    #!/bin/bash

    MYSQL_PWD=`cat /etc/psa/.psa.shadow`
    logdir="/var/log/plesk"
    logfile="${logdir}/debug.log"

    mkdir -p $logdir
    sleep 2

    i=`echo "select name from Templates where id =(select plan_id from PlansSubscriptions where subscription_id =(select id from Subscriptions where object_id =(select id from domains where name='${NEW_DOMAIN_NAME}')))" | mysql -uadmin psa | awk '{if (NR!=1) {print}}'`

    echo "`date` - Plan Template name is: $i" >>$logfile

    echo "`date` - Called for ${NEW_DOMAIN_NAME}" >>$logfile
    `if [ $i=='Mail off' ];`
    then
            #sleep 5 && /usr/local/psa/bin/subscription -u ${NEW_DOMAIN_NAME} -mail_service false 1>>$logfile 2>>$logfile
            /usr/local/psa/bin/subscription -u ${NEW_DOMAIN_NAME} -mail_service false 1>>$logfile 2>>$logfile
            echo "`date` - Executed for subscription ${NEW_DOMAIN_NAME}" >>$logfile
    fi

where Mail off is the name of the Service Plan.

After taking these steps, Mail Service will be turned off for all subscriptions created using this Service Plan.

Have more questions? Submit a request
Please sign in to leave a comment.