{"id":849,"date":"2016-02-14T08:53:47","date_gmt":"2016-02-14T16:53:47","guid":{"rendered":"https:\/\/www.cloudinsidr.com\/content\/?p=849"},"modified":"2016-02-14T09:04:08","modified_gmt":"2016-02-14T17:04:08","slug":"wordpress-says-your-host-may-have-disabled-the-mail-function-and-what-to-do-about-it","status":"publish","type":"post","link":"https:\/\/www.cloudinsidr.com\/content\/wordpress-says-your-host-may-have-disabled-the-mail-function-and-what-to-do-about-it\/","title":{"rendered":"WordPress Says Your Host May Have Disabled The mail() Function. Here Is How to Fix It."},"content":{"rendered":"<p>Some WordPress installations stubbornly refuse requests\u00a0for a password reset link, showing the user\u00a0this error message instead:<\/p>\n<pre>The email could not be sent.\r\nPossible reason: your host may have disabled the mail() function.<\/pre>\n<p>WordPress&#8217; error massage is anything but insightful. The underlying cause usually involves SELinux. Let us\u00a0introduce you to an\u00a0easy fix that does not involve plug-ins or external email services. Buckle up.<\/p>\n<p><!--more--><\/p>\n<p>Before you embark on your mail configuration, remember to grant yourself root privileges:<\/p>\n<pre>sudo su<\/pre>\n<h6>Step 1. Diagnostics (in case this is something entirely different)<\/h6>\n<p>In order to test your server without writing code, install mailx:<\/p>\n<pre>yum install mailx<\/pre>\n<p>To test outgoing mail, use this command after installtion:<\/p>\n<pre>echo testing | mail -s SomeTestSubject your.external@emailaddress.tld<\/pre>\n<p>Watch for errors:<\/p>\n<pre>tail \/var\/log\/maillog<\/pre>\n<p>In order for SELinux to quit blocking access to resources, use this command to switch SELinux to permissive mode (in other words, deactivate the enforcing mode) and repeat the test:<\/p>\n<pre>setenforce 0<\/pre>\n<p>If you are still getting\u00a0errors with SELinux in the permissive mode, perform the obvious\u00a0fixes.<\/p>\n<h6>Step 2. Perform any obvious fixes<\/h6>\n<p>Any number of errors could show up in the output. You could, for example, see this:<\/p>\n<pre>postfix\/local[28021]: warning: maildir access problem for UID\/GID=0\/0: create maildir file \/root\/Maildir\/tmp\/1455463988.P28021.ip-12-34-45-67.ec2.internal: Permission denied<\/pre>\n<p>One other thing: users of Postfix, don&#8217;t change the sendmail path in php.ini to the Postfix path, your mail agent will be jsut fine without you meddling with this setting, so don&#8217;t touch this line!<\/p>\n<p>This one is easy. Create the mail directory for user root:<\/p>\n<pre>mkdir \/root\/Maildir\/<\/pre>\n<p>and you won&#8217;t see this error again.<\/p>\n<h6>Step 3. Request another password reset link from WordPress<\/h6>\n<p>In your web browser, request another password reset link from your WordPress installation. You should see the success message:<\/p>\n<pre>Check your email for the confirmation link.<\/pre>\n<h6>Step 4. Verify that your web server has the permission to send emails<\/h6>\n<p>What happens when a user requests a WordPress password reset is directed by the web server (such as Apache or NGINX, whichever is running on your system). Your web server needs a permission to perform this operation. Verify if this is the case:<\/p>\n<pre>sestatus -b | grep -i sendmail<\/pre>\n<p>The output could look something like this:<\/p>\n<pre>gitosis_can_sendmail off\r\nhttpd_can_sendmail off\r\nlogging_syslogd_can_sendmail off\r\n\r\n<\/pre>\n<figure id=\"attachment_855\" aria-describedby=\"caption-attachment-855\" style=\"width: 594px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2016\/02\/selinux_sendmail-01.png\" rel=\"attachment wp-att-855\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-855 size-full\" src=\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2016\/02\/selinux_sendmail-01.png\" alt=\"SElinux: wrong sendmail permissions \" width=\"594\" height=\"75\" srcset=\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2016\/02\/selinux_sendmail-01.png 594w, https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2016\/02\/selinux_sendmail-01-300x38.png 300w\" sizes=\"(max-width: 594px) 100vw, 594px\" \/><\/a><figcaption id=\"caption-attachment-855\" class=\"wp-caption-text\">SElinux: wrong sendmail permissions<\/figcaption><\/figure>\n<h6>Step 5. Grant the web server permission to send mail<\/h6>\n<p>Allow the web server to send outgoing mail:<\/p>\n<pre>setsebool -P httpd_can_sendmail 1<\/pre>\n<p>As a result,\u00a0the command:<\/p>\n<pre>sestatus -b | grep -i sendmail<\/pre>\n<p>should deliver this output:<\/p>\n<pre>gitosis_can_sendmail off\r\nhttpd_can_sendmail on\r\nlogging_syslogd_can_sendmail off<\/pre>\n<figure id=\"attachment_856\" aria-describedby=\"caption-attachment-856\" style=\"width: 594px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2016\/02\/selinux_sendmail-02.png\" rel=\"attachment wp-att-856\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-856\" src=\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2016\/02\/selinux_sendmail-02.png\" alt=\"SElinux: sendmail permissions corrected\" width=\"594\" height=\"108\" srcset=\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2016\/02\/selinux_sendmail-02.png 594w, https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2016\/02\/selinux_sendmail-02-300x55.png 300w\" sizes=\"(max-width: 594px) 100vw, 594px\" \/><\/a><figcaption id=\"caption-attachment-856\" class=\"wp-caption-text\">SElinux: sendmail permissions corrected<\/figcaption><\/figure>\n<p>Now feel free to activate the enforcing mode in SELinux:<\/p>\n<pre>setenforce 1<\/pre>\n<p>and verify that WordPress sends. You should receive the now-familiar message &#8220;<em>Check your email for the confirmation link.<\/em>&#8221;<\/p>\n<figure id=\"attachment_850\" aria-describedby=\"caption-attachment-850\" style=\"width: 662px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2016\/02\/checkYourMail.png\" rel=\"attachment wp-att-850\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-850\" src=\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2016\/02\/checkYourMail.png\" alt=\"Success: check your mail\" width=\"662\" height=\"245\" srcset=\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2016\/02\/checkYourMail.png 662w, https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2016\/02\/checkYourMail-600x222.png 600w, https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2016\/02\/checkYourMail-300x111.png 300w\" sizes=\"(max-width: 662px) 100vw, 662px\" \/><\/a><figcaption id=\"caption-attachment-850\" class=\"wp-caption-text\">Success: check your mail<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some WordPress installations stubbornly refuse requests\u00a0for a password reset link, showing the user\u00a0this error message instead: The email could not be sent. Possible reason: your host may have disabled the mail() function. WordPress&#8217; error massage is anything but insightful. The underlying cause usually involves SELinux. Let us\u00a0introduce you to an\u00a0easy fix that does not involve [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":850,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[16,17,2,109,6],"tags":[7,5,70,84],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>WordPress Says Your Host May Have Disabled The mail() Function. Here Is How to Fix It. - CloudInsidr<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.cloudinsidr.com\/content\/wordpress-says-your-host-may-have-disabled-the-mail-function-and-what-to-do-about-it\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WordPress Says Your Host May Have Disabled The mail() Function. Here Is How to Fix It. - CloudInsidr\" \/>\n<meta property=\"og:description\" content=\"Some WordPress installations stubbornly refuse requests\u00a0for a password reset link, showing the user\u00a0this error message instead: The email could not be sent. Possible reason: your host may have disabled the mail() function. WordPress&#8217; error massage is anything but insightful. The underlying cause usually involves SELinux. Let us\u00a0introduce you to an\u00a0easy fix that does not involve [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.cloudinsidr.com\/content\/wordpress-says-your-host-may-have-disabled-the-mail-function-and-what-to-do-about-it\/\" \/>\n<meta property=\"og:site_name\" content=\"CloudInsidr\" \/>\n<meta property=\"article:published_time\" content=\"2016-02-14T16:53:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-02-14T17:04:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2016\/02\/checkYourMail.png\" \/>\n\t<meta property=\"og:image:width\" content=\"662\" \/>\n\t<meta property=\"og:image:height\" content=\"245\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#website\",\"url\":\"https:\/\/www.cloudinsidr.com\/content\/\",\"name\":\"CloudInsidr\",\"description\":\"Cyber security, infotech\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.cloudinsidr.com\/content\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/wordpress-says-your-host-may-have-disabled-the-mail-function-and-what-to-do-about-it\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.cloudinsidr.com\/content\/wp-content\/uploads\/2016\/02\/checkYourMail.png\",\"width\":662,\"height\":245,\"caption\":\"Success: check your mail\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/wordpress-says-your-host-may-have-disabled-the-mail-function-and-what-to-do-about-it\/#webpage\",\"url\":\"https:\/\/www.cloudinsidr.com\/content\/wordpress-says-your-host-may-have-disabled-the-mail-function-and-what-to-do-about-it\/\",\"name\":\"WordPress Says Your Host May Have Disabled The mail() Function. Here Is How to Fix It. - CloudInsidr\",\"isPartOf\":{\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/wordpress-says-your-host-may-have-disabled-the-mail-function-and-what-to-do-about-it\/#primaryimage\"},\"datePublished\":\"2016-02-14T16:53:47+00:00\",\"dateModified\":\"2016-02-14T17:04:08+00:00\",\"author\":{\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#\/schema\/person\/dd6ee9cb21cf05763fd7cff3d6f11b2b\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.cloudinsidr.com\/content\/wordpress-says-your-host-may-have-disabled-the-mail-function-and-what-to-do-about-it\/\"]}]},{\"@type\":[\"Person\"],\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#\/schema\/person\/dd6ee9cb21cf05763fd7cff3d6f11b2b\",\"name\":\"Cloud Insidr\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.cloudinsidr.com\/content\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8b2fa1415b3d573b97d818b8f8f83b7c?s=96&d=mm&r=g\",\"caption\":\"Cloud Insidr\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/posts\/849"}],"collection":[{"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/comments?post=849"}],"version-history":[{"count":6,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/posts\/849\/revisions"}],"predecessor-version":[{"id":858,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/posts\/849\/revisions\/858"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/media\/850"}],"wp:attachment":[{"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/media?parent=849"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/categories?post=849"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudinsidr.com\/content\/wp-json\/wp\/v2\/tags?post=849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}