Created by: Knut Sparhell
🕸️ By WebFacing™. Read, send, show, manage, list, create, add, remove or delete email accounts, old messages, forwarders and autoresponders.
One click read, send and manage all your emails without a login step. Update notification recipients. Backup and download your complete cPanel® account.
This plugin requires your site is hosted on a cPanel® equipped server.
It uses it’s UAPI through shell access by default, or via HTTP API. Using without shell_exec
initially requires a temporary access token generated in the cPanel® native interface.
[wf_cpanel_email_webmail]
or as [wf_cpanel_email_webmail]
My Email[/wf_cpanel_email_webmail]
for frontend access user’s own Webmailshell_exec
is not available or when accessing a remote servercpanel
capability (Use custom code or a Roles/Capabilities Manager plugin)Support for subdomain email addresses when the main domain is a subdomain (only)
In case the shell_exec
function is disabled in your server PHP configuration, create a token in native cPanel® interface and add one of these lines to your wp-config.php
file, functions.php
in your child theme, in Must-use plugin or a custom regular plugin
const WF_CPANEL_API_TOKEN = 'my-temp-api-token';
define( 'WF_CPANEL_API_TOKEN', 'my-temp-api-token' );
WF_CPANEL_API_TOKEN
constant may be removed when a new token is created and activated from the plugin admin pageOption to set the default visibility for users on New Email screen (users may still set their own preferences):
add_filter( 'wf-cpanel-email-new-email_user-option', static function( bool $default, string $option, int $user_id ) {
if ( $option === 'wc-show-new-blackhole' /*or by $user_id*/ ) {
$default = true/*false*/;
}
return $default;
}, 10, 3 );
Option to allow other users than those with manage_options
capability to manage email adresses, single- or multisite, one of the following:
add_filter( 'wf_cpanel_email_capability', static fn( string $cap ): string => $my_cpanel_email_cap );
add_filter( 'wf_cpanel_email_capability', static fn( string $cap ) => 'edit_published_pages' );
Option to allow other users than those with manage_options
capability to see the dashboard widget, or remove it, one of the following:
add_filter( 'wf_cpanel_email_widget_capability', static fn( string $cap ): string => $my_cpanel_widget_cap );
add_filter( 'wf_cpanel_email_widget_capability', static fn( string $cap ) => 'edit_published_pages' );
add_filter( 'wf_cpanel_email_widget_capability', static fn( string $cap ) => 'do_not_allow' );
Option to alter the refresh interval in seconds for the dashboard widget, one of the following:
add_filter( 'wf_cpanel_email_widget_interval', static fn( int $interval ): int => $my_cpanel_widget_interval );
add_filter( 'wf_cpanel_email_widget_interval', static fn( int $interval ) => 45 );
Option to limit email addresses to current site domain, even for single site admins, one of the following
const WF_CPANEL_EMAIL_SITE_DOMAIN_ONLY = true;
define( 'WF_CPANEL_EMAIL_SITE_DOMAIN_ONLY', true );
add_filter( 'wf_cpanel_email_site_domain_only', '__return_true' );
add_filter( 'wf_cpanel_email_site_domain_only', fn() => true );
Multisite Network: Option not to limit email addresses to current subsite domain, for site admins that are not network (super) admins, one of the following:
const WF_CPANEL_EMAIL_SITE_DOMAIN_ONLY = false;
define( 'WF_CPANEL_EMAIL_SITE_DOMAIN_ONLY', false );
add_filter( 'wf_cpanel_email_site_domain_only', '__return_false' );
add_filter( 'wf_cpanel_email_site_domain_only', fn() => false );
Many optional parameters and API filters for the shortcode output, see includes/ShortCode.php
until further tested and documented
If you want to access another user on the server, use one of the following
const WF_CPANEL_USER = 'my-username';
define( 'WF_CPANEL_USER', 'my-username' );
If you want to access a remote server, use one of the following
const WF_CPANEL_HOST = 'my-host';
define( 'WF_CPANEL_HOST', 'my-host' );
WF_CPANEL_HOST
requires WF_CPANEL_USER
to also be definedAutomaticallly create new accounts when a new user is registered?
add_action( ‘user_register’, static function( int $user_id, array $userdata ): void {
// What to do just after the registraton here, like this (adds an email address that forwards to all users, a mailing list):
if ( method_exists( ‘WebFacing\cPanel\UAPI’, ‘add_forwarder’ ) ) {
\WebFacing\cPanel\UAPI::add_forwarder( ‘all-users@yoursite.tld, ‘$userdata[‘user_email’] );
}
}, 2 );
Site Health
shell_exec
is disabled in php.ini
cpanel
capability and email on site domain (so far)