configure sendmail for php email()

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












Recently I installed sendmail in Ubuntu



sudo apt install sendmail
sudo sendmailconfig


When I try to send mail using php email(); function to send email



$to = "myemail@gmail.com";
$subject = "Mail Test at ".strftime("%T", time());
$message = "This is a test.";
$message = wordwrap($message, 70);
$from = "anotheremail@gmail.com";
$headers = "From: $from";
$result = mail($to, $subject, $message, $headers);
echo $result ? "sent" : "error";


Now when I browse the php site I get sent message but I don't get email (in my official email).
Can anybody help?







share|improve this question
























    up vote
    0
    down vote

    favorite












    Recently I installed sendmail in Ubuntu



    sudo apt install sendmail
    sudo sendmailconfig


    When I try to send mail using php email(); function to send email



    $to = "myemail@gmail.com";
    $subject = "Mail Test at ".strftime("%T", time());
    $message = "This is a test.";
    $message = wordwrap($message, 70);
    $from = "anotheremail@gmail.com";
    $headers = "From: $from";
    $result = mail($to, $subject, $message, $headers);
    echo $result ? "sent" : "error";


    Now when I browse the php site I get sent message but I don't get email (in my official email).
    Can anybody help?







    share|improve this question






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Recently I installed sendmail in Ubuntu



      sudo apt install sendmail
      sudo sendmailconfig


      When I try to send mail using php email(); function to send email



      $to = "myemail@gmail.com";
      $subject = "Mail Test at ".strftime("%T", time());
      $message = "This is a test.";
      $message = wordwrap($message, 70);
      $from = "anotheremail@gmail.com";
      $headers = "From: $from";
      $result = mail($to, $subject, $message, $headers);
      echo $result ? "sent" : "error";


      Now when I browse the php site I get sent message but I don't get email (in my official email).
      Can anybody help?







      share|improve this question












      Recently I installed sendmail in Ubuntu



      sudo apt install sendmail
      sudo sendmailconfig


      When I try to send mail using php email(); function to send email



      $to = "myemail@gmail.com";
      $subject = "Mail Test at ".strftime("%T", time());
      $message = "This is a test.";
      $message = wordwrap($message, 70);
      $from = "anotheremail@gmail.com";
      $headers = "From: $from";
      $result = mail($to, $subject, $message, $headers);
      echo $result ? "sent" : "error";


      Now when I browse the php site I get sent message but I don't get email (in my official email).
      Can anybody help?









      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 24 at 8:22









      maverick

      12




      12




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          You might need to add your hostname to /etc/hosts (find the line with 127.0.0.1 and append your hostname):



          127.0.0.1 localhost localhost.localdomain your_hostname_here


          Try restarting apache:



          $> sudo service apache2 restart



          Please keep in mind that:




          1. mail returns success (true) if it transported your mail successfully to the configured MTA. This does not mean, that your MTA actually sent any mail.

          2. modern mail servers might not accept your email, since spam filters (dns lookup, sender verification, ...) might be active and prevent delivery.

          You can check sendmails mail queue anytime with the command



          $> mailq





          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f419278%2fconfigure-sendmail-for-php-email%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            You might need to add your hostname to /etc/hosts (find the line with 127.0.0.1 and append your hostname):



            127.0.0.1 localhost localhost.localdomain your_hostname_here


            Try restarting apache:



            $> sudo service apache2 restart



            Please keep in mind that:




            1. mail returns success (true) if it transported your mail successfully to the configured MTA. This does not mean, that your MTA actually sent any mail.

            2. modern mail servers might not accept your email, since spam filters (dns lookup, sender verification, ...) might be active and prevent delivery.

            You can check sendmails mail queue anytime with the command



            $> mailq





            share|improve this answer
























              up vote
              0
              down vote













              You might need to add your hostname to /etc/hosts (find the line with 127.0.0.1 and append your hostname):



              127.0.0.1 localhost localhost.localdomain your_hostname_here


              Try restarting apache:



              $> sudo service apache2 restart



              Please keep in mind that:




              1. mail returns success (true) if it transported your mail successfully to the configured MTA. This does not mean, that your MTA actually sent any mail.

              2. modern mail servers might not accept your email, since spam filters (dns lookup, sender verification, ...) might be active and prevent delivery.

              You can check sendmails mail queue anytime with the command



              $> mailq





              share|improve this answer






















                up vote
                0
                down vote










                up vote
                0
                down vote









                You might need to add your hostname to /etc/hosts (find the line with 127.0.0.1 and append your hostname):



                127.0.0.1 localhost localhost.localdomain your_hostname_here


                Try restarting apache:



                $> sudo service apache2 restart



                Please keep in mind that:




                1. mail returns success (true) if it transported your mail successfully to the configured MTA. This does not mean, that your MTA actually sent any mail.

                2. modern mail servers might not accept your email, since spam filters (dns lookup, sender verification, ...) might be active and prevent delivery.

                You can check sendmails mail queue anytime with the command



                $> mailq





                share|improve this answer












                You might need to add your hostname to /etc/hosts (find the line with 127.0.0.1 and append your hostname):



                127.0.0.1 localhost localhost.localdomain your_hostname_here


                Try restarting apache:



                $> sudo service apache2 restart



                Please keep in mind that:




                1. mail returns success (true) if it transported your mail successfully to the configured MTA. This does not mean, that your MTA actually sent any mail.

                2. modern mail servers might not accept your email, since spam filters (dns lookup, sender verification, ...) might be active and prevent delivery.

                You can check sendmails mail queue anytime with the command



                $> mailq






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 24 at 11:02









                Michael Hirschler

                13910




                13910






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f419278%2fconfigure-sendmail-for-php-email%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    Peggy Mitchell

                    Palaiologos

                    The Forum (Inglewood, California)