{"id":17,"date":"2019-09-17T16:57:05","date_gmt":"2019-09-17T16:57:05","guid":{"rendered":"https:\/\/www.resellerslot.com\/blog\/2019\/09\/17\/how-to-disable-ability-of-sending-email-through-smtp-and-php-in-cpanel-for-a-particular-account\/"},"modified":"2019-09-17T23:35:01","modified_gmt":"2019-09-17T23:35:01","slug":"disable-smtp-email-cpanel","status":"publish","type":"post","link":"https:\/\/www.resellerslot.com\/blog\/disable-smtp-email-cpanel\/","title":{"rendered":"How to disable smtp email sending ability for a specific user in cpanel\/whm"},"content":{"rendered":"<div class=\"site_wrapper\">\n<div class=\"container\">\n<div class=\"content_left\">\n<div class=\"blog_post\">\n<div class=\"blog_postcontent\">\n<div class=\"post_info_content\" style=\"margin: 10px 0px;\">\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-116\" src=\"https:\/\/www.resellerslot.com\/blog\/wp-content\/uploads\/2019\/09\/disable-smtp-mail-abaility.jpg\" alt=\"disable smtp mail ability cpanel\" width=\"548\" height=\"365\" srcset=\"https:\/\/www.resellerslot.com\/blog\/wp-content\/uploads\/2019\/09\/disable-smtp-mail-abaility.jpg 548w, https:\/\/www.resellerslot.com\/blog\/wp-content\/uploads\/2019\/09\/disable-smtp-mail-abaility-300x200.jpg 300w\" sizes=\"auto, (max-width: 548px) 100vw, 548px\" \/><\/p>\n<p>Most of the wordpress sites victimized by hackers due to too many vulnerabilities in different plugins and themes, through which hackers inserted whatever they want, in most cases the worst spamming scripts. In that scenario, how a server admin can secure its server mail ips from being black listed and server overloading without making changes in client\u2019s website and without suspending client\u2019s account on cpanel servers.<\/p>\n<p><span style=\"font-weight: bold;\">First consider restricting smtp authenticated emails<\/span><\/p>\n<p>Update client\u2019s domain package through <span style=\"font-weight: bold;\">Home \u00bbAccount Information \u00bbList Accounts<\/span><\/p>\n<p>Locate client\u2019s domain, click left side <span style=\"font-weight: bold;\">+<\/span> icon and the click on &#8220;Modify Account\u201d and set both below given features with value of \u201d1\u201d, it will not allow vulnerable domain to send more than 1 email in an hour.<\/p>\n<p><span style=\"font-weight: bold;\">Maximum Hourly Email by Domain Relayed 1<\/span><\/p>\n<p><span style=\"font-weight: bold;\">Maximum percentage of failed or deferred messages a domain may send per hour. 1<\/span><\/p>\n<p>Then<\/p>\n<p>Create a file via ssh, called \/etc\/ blockeddomains and add the list of domains to block email from to this file, one line at a time.<\/p>\n<p><span style=\"font-weight: bold;\">vi \/etc\/blockeddomains<\/span><\/p>\n<p>add the domain name whose email sending ability is required to be disabled, one per line, as<\/p>\n<p>domain1.com<\/p>\n<p>domain2.com<\/p>\n<p>then save it with QQ<\/p>\n<p>to view whether your domains has been added to this file, run<\/p>\n<p><span style=\"font-weight: bold;\">cat \/etc\/blockeddomains<\/span><\/p>\n<p>Now the next part is with your WHM\/cpanel<\/p>\n<p>Log into WHM and navigate to <span style=\"font-weight: bold;\">&#8220;Service Configuration \u00bbExim Configuration Manager\u201d<\/span><\/p>\n<p>Just above <span style=\"font-weight: bold;\">&#8220;BEGINACL\u201d<\/span> click add configuration<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" title=\"Disable Email Function\" src=\"https:\/\/www.resellerslot.com\/images\/disable-email-function.jpg\" alt=\"Disable Email Function\" border=\"0px\"><\/p>\n<p>In the first box enter <span style=\"font-weight: bold;\">&#8220;domainlist blocked_domains\u201d<\/span> without the quotes and in the second box enter without the quotes <span style=\"font-weight: bold;\">&#8220;lsearch;\/etc\/blockeddomains\u201d<\/span><\/p>\n<p>Then I scrolled down to <span style=\"font-weight: bold;\">&#8220;Section: ROUTERSTART\u201d<\/span> and entered the following<\/p>\n<p>reject_domains:<\/p>\n<p>driver = redirect<\/p>\n<p># RBL Blacklist incoming hosts<\/p>\n<p>domains = +blocked_domains<\/p>\n<p>allow_fail<\/p>\n<p>data = :fail: Connection rejected: SPAM source $domain is manually blacklisted.<\/p>\n<p>and then scrolled down and click Save.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" title=\"\" src=\"https:\/\/www.resellerslot.com\/images\/disable-email-specific-user.jpg\" alt=\"\" border=\"0px\"><\/p>\n<p>This will block all emails that are sent and authenticated as a user with the mentioned domain. If an email uses PHP mail() then the email may possibly be sent as user@serverhostname.tld instead of the domain itself. If this is a concern then you may want to disable the PHP mail function for that user. This would be done using a custom php.ini file.<\/p>\n<p>=======================================<\/p>\n<h2>How to disable PHP mail() sending ability\/function for a particular domain in cpanel\/whm<\/h2>\n<p>Before initiating how to stop php email functionality for a specific user, I wish you to check your <span style=\"font-weight: bold;\">&#8220;php and suEXEC\u201d<\/span> configuration because php.ini needs to be setup according to the php and suEXEC configuration.<\/p>\n<p>For that login to WHM, go to <span style=\"font-weight: bold;\">Home \u00bbService Configuration \u00bbConfigure PHP and suEXEC<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"font-weight: bold;\"><img decoding=\"async\" title=\"php and suEXEC\" src=\"https:\/\/www.resellerslot.com\/images\/suEXEC-php-handler.jpg\" alt=\"php and suEXEC\" border=\"0px\"><\/span><\/p>\n<p><\/p>\n<p>suEXEC must be complied with Apache and suphp should be phphandler, view the below image. If it is not so php.ini may not load correctly.<\/p>\n<p>Then go to <span style=\"font-weight: bold;\">Home \u00bbService Configuration \u00bbPHP Configuration Editor<\/span><\/p>\n<p>Scroll down the page and click on \u201dSave\u201d button without making any changes, when it will save, it will show you off all the content of server\u2019s php.ini file, simply copy the whole text and save it in a text file in your local system as &#8220;php.ini\u201d file. Then search this <span style=\"font-weight: bold;\">&#8220;disable_functions\u201d<\/span>, after locating it edit this line as<\/p>\n<p><span style=\"font-weight: bold;\">disable_functions = mail, sendmail, other features<\/span><\/p>\n<p>there should not any quotes on sides like<\/p>\n<p><span style=\"font-weight: bold;\">;disable_functions = &#8220;mail, sendmail, other features\u201d<\/span> but it must look like <span style=\"font-weight: bold;\">disable_functions = mail, sendmail, <\/span>other features<\/p>\n<p>Also while finding the above line in server\u2019s php.ini, verify whether those quotes inserted on sides, if yes then you also need to un-comment that line too using this file \/usr\/local\/lib\/php.ini through command line shell.<\/p>\n<p><span style=\"font-weight: bold;\">vi \/usr\/local\/lib\/php.ini<\/span><\/p>\n<p>locate disable_functions and uncomment it and it should look like <span style=\"font-weight: bold;\">disable_functions = all disable functions<\/span>, so that your default php.ini could load.<\/p>\n<p>Now open the cpanel of particular user and create two files in its root directory before public_html<\/p>\n<h3>1) php.ini<\/h3>\n<h3>2) .htaccess<\/h3>\n<p>Insert whole the text you save in your system after updating your server\u2019s php.ini file here which have incremental list of disabled functions as mail, sendmail and then save it.<\/p>\n<p>Then open .htaccess file and insert as below (we are creating this .htaccess file because we have configure suPHP) as your \/home\/username\/public_html\/.htaccess is being overwritten so we place the suPHP setting into \/home\/username\/.htaccess instead.<\/p>\n<p>suPHP_ConfigPath \/home\/username\/<\/p>\n<h2>Why we create .htaccess file?<\/h2>\n<p>If \u2018suPHP_ConfigPath \/home\/username\/\u2019 is in .htaccess, only 1 custom php.ini needs to be placed in \/home\/username. If \u2018suPHP_ConfigPath \/home\/username\/\u2019 is not used, a custom php.ini must reside in each directory containing .php files that require the php.ini<\/p>\n<p>Now you may verify whether your php.ini file of current user is loading correctly or not just by uploading phpinfo.php file on any path of this domain and loading that file via browser and then searching <span style=\"font-weight: bold;\">disable_functions<\/span>, keep one thing in mind that you should not add &#8220;phpinfo\u201d function in your clients php.ini file if you want to load phpinfo.php file otherwise that file phpinfo.php will not load but if you want to hide your phpinfo.php, you may after checking can update your user\u2019s php.ini file as<\/p>\n<p><span style=\"font-weight: bold;\">disable_functions = mail, sendmail, phpinfo, other features<\/span> (this will not allow loading your php info file via browser).<\/p>\n<p>This all will then not allow sending emails for that particular user from your php.<\/p>\n<p>There could be worst cases when even after disabling email sending ability of a user through smtp authentication as well as php mailing but emails are still being queued in case if the injected script by a hacker use your php mailer and also a TCP connection to an smtp server, in that scenario you may achieve your goal by disabling <span style=\"font-weight: bold;\">stream_socket_client and fsockopen<\/span> through your client\u2019s php.ini file.<\/p>\n<p>Add <span style=\"font-weight: bold;\">stream_socket_client and fsockopen in disable_functions list<\/span> and switch <span style=\"font-weight: bold;\">allow_url_fopen = On<\/span> within that php.ini file (it will disable fsockopen)<\/p>\n<p>Now your disable function list for client\u2019s php.ini file will look like<\/p>\n<p><span style=\"font-weight: bold;\">disable_functions = mail, sendmail, phpinfo, stream_socket_client, fsockopen, other default disabled functions<\/span><\/p>\n<p>This is the most clearly and widely written article regarding preventing a user from sending emails in cpanel\/whm, hopefully it will help you.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most of the wordpress sites victimized by hackers due to too many vulnerabilities in different plugins and themes, through which hackers inserted whatever they want, in most cases the worst spamming scripts. In that scenario, how a server admin can secure its server mail ips from being black listed and server overloading without making changes [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-17","post","type-post","status-publish","format-standard","hentry","category-hosting"],"_links":{"self":[{"href":"https:\/\/www.resellerslot.com\/blog\/wp-json\/wp\/v2\/posts\/17","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.resellerslot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.resellerslot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.resellerslot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.resellerslot.com\/blog\/wp-json\/wp\/v2\/comments?post=17"}],"version-history":[{"count":5,"href":"https:\/\/www.resellerslot.com\/blog\/wp-json\/wp\/v2\/posts\/17\/revisions"}],"predecessor-version":[{"id":159,"href":"https:\/\/www.resellerslot.com\/blog\/wp-json\/wp\/v2\/posts\/17\/revisions\/159"}],"wp:attachment":[{"href":"https:\/\/www.resellerslot.com\/blog\/wp-json\/wp\/v2\/media?parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.resellerslot.com\/blog\/wp-json\/wp\/v2\/categories?post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.resellerslot.com\/blog\/wp-json\/wp\/v2\/tags?post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}