mail() function sending two emails

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jesse Burns aka jburns131

    #1

    mail() function sending two emails

    Here's my code:

    $today = getdate();

    $to = someone@somewhe re.com;

    $subject = "New Application: ".$userdata["username"]." -
    ".$today['mon']."/".$today['mday']."/".$today['year'];

    $message_header = "New Application: ".$userdata["username"];


    $message = $message_header ."\n

    Hello, is this working?";


    mail($to, $subject, $message);

    It's not located in a loop, so I don't understand why it would send 2 emails
    to the reciever?

    Any idea's?


  • Jerry Stuckle

    #2
    Re: mail() function sending two emails

    Jesse Burns aka jburns131 wrote:
    Here's my code:
    >
    $today = getdate();
    >
    $to = someone@somewhe re.com;
    >
    $subject = "New Application: ".$userdata["username"]." -
    ".$today['mon']."/".$today['mday']."/".$today['year'];
    >
    $message_header = "New Application: ".$userdata["username"];
    >
    >
    $message = $message_header ."\n
    >
    Hello, is this working?";
    >
    >
    mail($to, $subject, $message);
    >
    It's not located in a loop, so I don't understand why it would send 2 emails
    to the reciever?
    >
    Any idea's?
    >
    >
    >
    If it's sending 2 emails, it's because:

    a) You are calling the mail() function twice
    b) Your To: header specifies two addresses, or
    c) Your MTA is configured to copy someone automatically.

    The most probably reason is you are calling mail() twice.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Sanders Kaufman

      #3
      Re: mail() function sending two emails

      "Jesse Burns aka jburns131" <jburns131@jbwe bware.comwrote in message
      news:J42dncuPMq deHNXanZ2dnUVZ_ hCdnZ2d@comcast .com...
      It's not located in a loop, so I don't understand why it would send 2
      emails to the reciever?
      >
      Any idea's?
      I had the *exact* same problem - weird as hell, ain't it?
      It didn't happen on all pages, just the one - and even stepping through it
      in my code editor showed that I was not calling twice.
      But still - two friggin mails.

      I think it has something to do with the way the server administrator sets up
      the mail system.
      In my case, sending to a bad email address didn't just return false - it
      crashed PHP.
      I called the ISP and they immediately "fixed" it, so that bad sends returned
      false.
      But then - this problem cropped up.

      The way I "solved" (for lack of a better word) was to, in that page, not put
      the mail() command in a function.
      Instead, I put it inline with an if-then.

      So... instead of this.
      function fnDo() {
      mail();
      }

      I used this:
      function fnDo(){
      $bDo = true;
      }
      if($bDo){
      mail();
      }




      Comment

      • Jesse Burns aka jburns131

        #4
        Re: mail() function sending two emails

        Thanks for the input :-)

        ok, here's where it gets really odd. Out of the 2 email sent, only one has
        the $_POST data that I'm sending. The other doesn't?

        Any idea's?


        "Jesse Burns aka jburns131" <jburns131@jbwe bware.comwrote in message
        news:J42dncuPMq deHNXanZ2dnUVZ_ hCdnZ2d@comcast .com...
        Here's my code:
        >
        $today = getdate();
        >
        $to = someone@somewhe re.com;
        >
        $subject = "New Application: ".$userdata["username"]." -
        ".$today['mon']."/".$today['mday']."/".$today['year'];
        >
        $message_header = "New Application: ".$userdata["username"];
        >
        >
        $message = $message_header ."\n
        >
        Hello, is this working?";
        >
        >
        mail($to, $subject, $message);
        >
        It's not located in a loop, so I don't understand why it would send 2
        emails to the reciever?
        >
        Any idea's?
        >
        >

        Comment

        • Jerry Stuckle

          #5
          Re: mail() function sending two emails

          Jesse Burns aka jburns131 wrote:
          Thanks for the input :-)
          >
          ok, here's where it gets really odd. Out of the 2 email sent, only one has
          the $_POST data that I'm sending. The other doesn't?
          >
          Any idea's?
          >
          >
          "Jesse Burns aka jburns131" <jburns131@jbwe bware.comwrote in message
          news:J42dncuPMq deHNXanZ2dnUVZ_ hCdnZ2d@comcast .com...
          >Here's my code:
          >>
          >$today = getdate();
          >>
          >$to = someone@somewhe re.com;
          >>
          >$subject = "New Application: ".$userdata["username"]." -
          >".$today['mon']."/".$today['mday']."/".$today['year'];
          >>
          >$message_heade r = "New Application: ".$userdata["username"];
          >>
          >>
          >$message = $message_header ."\n
          >>
          >Hello, is this working?";
          >>
          >>
          >mail($to, $subject, $message);
          >>
          >It's not located in a loop, so I don't understand why it would send 2
          >emails to the reciever?
          >>
          >Any idea's?
          >>
          >>
          >
          >
          >
          Yep, you're probably calling mail() somewhere else. Or calling it twice
          - i.e. after reloading the page.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • FFMG

            #6
            Re: mail() function sending two emails


            Jesse Burns aka jburns131;10512 5 Wrote:
            Thanks for the input :-)
            >
            ok, here's where it gets really odd. Out of the 2 email sent, only one
            has
            the $_POST data that I'm sending. The other doesn't?
            >
            Any idea's?
            >
            >
            It really looks like the page is reloaded.
            Do you have some kind of redirect in your code?, something to reload
            the page?

            FFMG


            --

            'webmaster forum' (http://www.httppoint.com) | 'Free Blogs'
            (http://www.journalhome.com/) | 'webmaster Directory'
            (http://www.webhostshunter.com/)
            'Recreation Vehicle insurance'
            (http://www.insurance-owl.com/other/car_rec.php) | 'Free URL
            redirection service' (http://urlkick.com/)
            ------------------------------------------------------------------------
            FFMG's Profile: http://www.httppoint.com/member.php?userid=580
            View this thread: http://www.httppoint.com/showthread.php?t=22557

            Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

            Comment

            • Michael Fesser

              #7
              Re: mail() function sending two emails

              ..oO(Jesse Burns aka jburns131)
              >Thanks for the input :-)
              >
              >ok, here's where it gets really odd. Out of the 2 email sent, only one has
              >the $_POST data that I'm sending. The other doesn't?
              >
              >Any idea's?
              What does the server logfile say? Is the page requested twice?

              Micha

              Comment

              • Jesse Burns aka jburns131

                #8
                Re: mail() function sending two emails

                Hello :-)

                I'm not very familiar with what and where the server logfile is. I have full
                control of my server, and cpanel/whm. Could you please point me to where the
                logfile might be?

                Thanks in advance.

                "Michael Fesser" <netizen@gmx.de wrote in message
                news:s18jk3d2pe 0a5f0bkrb8kmec7 mrtlim3f5@4ax.c om...
                .oO(Jesse Burns aka jburns131)
                >
                >>Thanks for the input :-)
                >>
                >>ok, here's where it gets really odd. Out of the 2 email sent, only one has
                >>the $_POST data that I'm sending. The other doesn't?
                >>
                >>Any idea's?
                >
                What does the server logfile say? Is the page requested twice?
                >
                Micha

                Comment

                • Michael Fesser

                  #9
                  Re: mail() function sending two emails

                  ..oO(Jesse Burns aka jburns131)
                  >I'm not very familiar with what and where the server logfile is. I have full
                  >control of my server, and cpanel/whm. Could you please point me to where the
                  >logfile might be?
                  Usually on *nix systems it's somewhere in /var/log, but dependent on the
                  system and server setup the location might differ. I'm not familiar with
                  cPanel (usually I either use a direct SSH login or my host's own admin
                  software) - does it have an option to access the server logs? Sometimes
                  you might also be able to reach them via FTP. If you still can't get
                  them, ask your host.

                  Micha

                  Comment

                  • Darko

                    #10
                    Re: mail() function sending two emails

                    On Nov 25, 5:56 pm, "Jesse Burns aka jburns131"
                    <jburns...@jbwe bware.comwrote:
                    Hello :-)
                    >
                    I'm not very familiar with what and where the server logfile is. I have full
                    control of my server, and cpanel/whm. Could you please point me to where the
                    logfile might be?
                    >
                    Thanks in advance.
                    >
                    "Michael Fesser" <neti...@gmx.de wrote in message
                    >
                    news:s18jk3d2pe 0a5f0bkrb8kmec7 mrtlim3f5@4ax.c om...
                    >
                    .oO(Jesse Burns aka jburns131)
                    >
                    >Thanks for the input :-)
                    >
                    >ok, here's where it gets really odd. Out of the 2 email sent, only one has
                    >the $_POST data that I'm sending. The other doesn't?
                    >
                    >Any idea's?
                    >
                    What does the server logfile say? Is the page requested twice?
                    >
                    Micha
                    Smells to me you're require-ing this file from somewhere and your code
                    gets
                    required twice. Try doing the require_once, or organize your code
                    better.

                    Just an idea, though.

                    Darko

                    Comment

                    • Norman Peelman

                      #11
                      Re: mail() function sending two emails

                      Jerry Stuckle wrote:
                      Jesse Burns aka jburns131 wrote:
                      >Here's my code:
                      >>
                      >$today = getdate();
                      >>
                      >$to = someone@somewhe re.com;
                      >>
                      >$subject = "New Application: ".$userdata["username"]." -
                      >".$today['mon']."/".$today['mday']."/".$today['year'];
                      >>
                      >$message_heade r = "New Application: ".$userdata["username"];
                      >>
                      >>
                      >$message = $message_header ."\n
                      >>
                      >Hello, is this working?";
                      >>
                      >>
                      >mail($to, $subject, $message);
                      >>
                      >It's not located in a loop, so I don't understand why it would send 2
                      >emails to the reciever?
                      >>
                      >Any idea's?
                      >>
                      >>
                      >>
                      >
                      If it's sending 2 emails, it's because:
                      >
                      a) You are calling the mail() function twice
                      b) Your To: header specifies two addresses, or
                      c) Your MTA is configured to copy someone automatically.
                      >
                      The most probably reason is you are calling mail() twice.
                      >
                      Had the same problem once... it's a good chance that the script is
                      being called twice. Usually caused by a page reload somewhere else in
                      the HTML/Javascript. In my case I had a FORM that was getting posted
                      twice but I can't remember what was causing the page to reload. I think
                      it was some bad logic in conjunction with a header() call.

                      Norm

                      Comment

                      Working...