How to Suspend Incoming Emails using API2

JAB Creations

Member
Nov 21, 2009
18
0
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?
 

JAB Creations

Member
Nov 21, 2009
18
0
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' => '[email protected]'));
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?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,917
2,248
363
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' => '[email protected]'));
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?
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.