{"id":871,"date":"2022-01-14T04:04:34","date_gmt":"2022-01-13T22:04:34","guid":{"rendered":"https:\/\/mellowhost.com\/blog\/?p=871"},"modified":"2022-01-14T04:04:34","modified_gmt":"2022-01-13T22:04:34","slug":"cpanel-hosting-tries-to-send-mail-using-localhost-for-remote-relay-from-php-script","status":"publish","type":"post","link":"https:\/\/mellowhost.com\/blog\/cpanel-hosting-tries-to-send-mail-using-localhost-for-remote-relay-from-php-script.html","title":{"rendered":"Cpanel Hosting Tries to Send Mail using Localhost for Remote Relay from PHP Script"},"content":{"rendered":"\n<p>Question: When I try to send mail using a PHP script in Cpanel, it automatically switches the SMTP hostname to localhost, even if I use a remote relay like sparkpost or mailgun. How to fix this?<\/p>\n\n\n\n<p>Solution:<\/p>\n\n\n\n<p>The reason behind the behavior is, by default Cpanel doesn&#8217;t let your customers use remote SMTP using PHP. This is controlled using a feature called &#8216;SMTP Restriction&#8217;. Go to WHM, log in using root, from Security Center select &#8220;SMTP Restrictions&#8221; and now, disable this. Your script shall now be able to send mail using remote SMTP like sparkpost\/mailgun\/pepipost.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Question: When I try to send mail using a PHP script in Cpanel, it automatically switches the SMTP hostname to localhost, even if I use a remote relay like sparkpost or mailgun. How to fix this? Solution: The reason behind the behavior is, by default Cpanel doesn&#8217;t let your customers use remote SMTP using PHP. &hellip; <a href=\"https:\/\/mellowhost.com\/blog\/cpanel-hosting-tries-to-send-mail-using-localhost-for-remote-relay-from-php-script.html\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Cpanel Hosting Tries to Send Mail using Localhost for Remote Relay from PHP Script&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[6,13],"tags":[46,659,658,657],"_links":{"self":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/871"}],"collection":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/comments?post=871"}],"version-history":[{"count":1,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/871\/revisions"}],"predecessor-version":[{"id":872,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/871\/revisions\/872"}],"wp:attachment":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/media?parent=871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/categories?post=871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/tags?post=871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}