Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

How to Suspend Incoming Emails using API2

Discussion in 'cPanel Developers' started by JAB Creations, Jun 15, 2018.

  1. JAB Creations

    JAB Creations Member

    Joined:
    Nov 21, 2009
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    51
    I need to suspend incoming email for an email account that is only designed for notifications. I tested manually suspending incoming email and the test account was still able to send emails all as desired. However I can not find the API2 documentation for suspending incoming email; how do I do this with API2?
     
  2. JAB Creations

    JAB Creations Member

    Joined:
    Nov 21, 2009
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    51
    Update: UAPI (which is effectively API version 3) documentation starts at Guide to UAPI - Developer Documentation - cPanel Documentation.

    Secondly the suspend incoming email documentation is here: UAPI Functions - Email::suspend_incoming - Developer Documentation - cPanel Documentation.

    So I tried it and received the following error:

    Fatal error: Uncaught RuntimeException: There was a problem fetching the env variablecontaining the path to the socket in /usr/local/cpanel/php/cpanel.php:146

    Which led me to an older thread of mine about this exact error: problem fetching the env variablecontaining the path to the socket.

    I added the correct cPanel user name and it's still throwing the same error.

    I ended up getting the PHP script to create legitimate email accounts in an automated fashion on behalf of users using api2_query and I still don't have a working script using UAPI any where in my code (thanks for Advanced Find and Replace).

    So here is my code with basic obfuscation:

    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', 1);

    require_once('/usr/local/cpanel/php/cpanel.php');
    $cpanel = new CPANEL();
    $result = $cpanel->uapi('Email', 'suspend_incoming', array('email' => 'somenotification@example.com'));
    echo '<pre>'.print_r($result,1).'</pre>';
    ?>

    ..and a reminder, I'm still getting the "...env variablecontaining the path to the socket..." error. What am I missing?
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,928
    Likes Received:
    1,819
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello @JAB Creations,

    Can you provide the step-by-step instructions of how to reproduce the issue so we can verify if there are any issues with the steps you are using? For instance, include where you are uploading the script to and how you are executing it.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice