{"id":9411,"date":"2026-06-02T07:22:59","date_gmt":"2026-06-02T05:22:59","guid":{"rendered":"https:\/\/mybox.com\/help\/?post_type=manual_kb&#038;p=9411"},"modified":"2026-06-02T07:23:00","modified_gmt":"2026-06-02T05:23:00","slug":"cum-sa-testati-functia-php-mail-folosind-un-script-simplu","status":"publish","type":"manual_kb","link":"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-test-the-php-mail-function-using-a-simple-script\/","title":{"rendered":"Cum s\u0103 testa\u021bi func\u021bia PHP mail() utiliz\u00e2nd un script simplu"},"content":{"rendered":"<div class=\"translation-block translation-block-merged\">\n<p class=\"wp-block-paragraph\">If you want to check whether the PHP <code>mail()<\/code> function works correctly, you can upload a simple test file to your server using FTP (for example FileZilla).<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_86 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-test-the-php-mail-function-using-a-simple-script\/#Step_1_Create_the_test_file\" >Step 1: Create the test file<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-test-the-php-mail-function-using-a-simple-script\/#Step_2_Add_the_test_script\" >Step 2: Add the test script<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-test-the-php-mail-function-using-a-simple-script\/#Step_3_Run_the_test\" >Step 3: Run the test<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-test-the-php-mail-function-using-a-simple-script\/#Expected_result\" >Expected result<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/mybox.com\/help\/ro\/knowledgebase\/how-to-test-the-php-mail-function-using-a-simple-script\/#Notes\" >Notes<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_1_Create_the_test_file\"><\/span>Step 1: Create the test file<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Upload a file to your <code>\/public_html<\/code> directory.<\/p>\n\n\n\n<\/div>\n\n<div id=\"mybox-3522406943\" class=\"mybox-content mybox-entity-placement\"><div class=\"early-access-banner-inpost\">\r\n  <div class=\"banner-left-inpost\">\r\n    <div class=\"icon-box-inpost\">\r\n      <img decoding=\"async\" src=\"https:\/\/mybox.com\/help\/wp-content\/uploads\/2026\/02\/square-info-icon.svg\" alt=\"Info\">\r\n    <\/div>\r\n    <div class=\"text-box-inpost\">\r\n      <span class=\"label-inpost\"><span class=\"translation-block translation-block-banner-text\">Acces timpuriu<\/span><\/span>\r\n      <h4><span class=\"translation-block translation-block-banner-text\">Mai ave\u021bi nevoie de ajutor?<\/span><\/h4>\r\n      <p><span class=\"translation-block translation-block-banner-text\">Contacta\u021bi echipa noastr\u0103 de servicii pentru clien\u021bi.<\/span><\/p>\r\n    <\/div>\r\n  <\/div>\r\n\r\n  <div class=\"banner-right-inpost\">\r\n    <a href=\"https:\/\/panel.mybox.com\/helpdesk2\/v\/list\/\" class=\"banner-button-inpost\"><span class=\"translation-block translation-block-banner-text\">Trimite mesaj<\/span><\/a>\r\n  <\/div>\r\n<\/div><\/div>\n\n<div class=\"translation-block translation-block-merged\"><p class=\"wp-block-paragraph\">Example filename:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">phpmail.php<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_2_Add_the_test_script\"><\/span>Step 2: Add the test script<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Paste the following code into the file and replace the sender and recipient email addresses with your own values: &lt;?php $sender = &#8216;sender@example.com&#8217;; $recipient = &#8216;recipient@example.com&#8217;; $subject = &#8220;Test message&#8221;; $message = &#8220;PHP mail function test&#8221;; $headers = &#8216;From:&#8217; . $sender; if (mail($recipient, $subject, $message, $headers)) { echo &#8220;Message sent successfully&#8221;; } else { echo &#8220;Error: Message could not be sent&#8221;; } ?&gt;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_3_Run_the_test\"><\/span>Step 3: Run the test<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Open the file in your browser:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a>http:\/\/yourdomain.com\/phpmail.php<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Expected_result\"><\/span>Expected result<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If everything is working correctly:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Message sent successfully<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If there is an issue:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Error: Message could not be sent<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Notes\"><\/span>Notes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ensure the PHP <code>mail()<\/code> function is enabled on the server<\/li>\n\n\n\n<li>Some hosting providers require valid SMTP configuration even if <code>mail()<\/code> is available<\/li>\n\n\n\n<li>Always include <code>&lt;?php<\/code> at the beginning and <code>?><\/code> at the end of standalone PHP files<\/li>\n\n\n\n<li>Make sure sender and recipient addresses are valid to avoid delivery issues<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"template":"","format":"standard","manualknowledgebasecat":[39],"manual_kb_tag":[415,516,794,795,1715,2323,2427,5494,5495,5496],"class_list":["post-9411","manual_kb","type-manual_kb","status-publish","format-standard","hentry","manualknowledgebasecat-php-operations","manual_kb_tag-ftp-client","manual_kb_tag-filezilla","manual_kb_tag-mail-function","manual_kb_tag-php-mail","manual_kb_tag-file-upload","manual_kb_tag-php-script","manual_kb_tag-public-html","manual_kb_tag-mail-testing","manual_kb_tag-test-script","manual_kb_tag-test-file"],"_links":{"self":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/9411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":1,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/9411\/revisions"}],"predecessor-version":[{"id":9416,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb\/9411\/revisions\/9416"}],"wp:attachment":[{"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/media?parent=9411"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manualknowledgebasecat?post=9411"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/mybox.com\/help\/ro\/wp-json\/wp\/v2\/manual_kb_tag?post=9411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}