PHP srnd two emails

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pablo

    #1

    PHP srnd two emails

    Hi at all

    I call this function when I fill the foot of the body of the email that I'll
    send immediately after:

    $text.=serial_n umber();

    function serial_number()

    {

    $file="serial.t xt";

    for ($try = 0; $try < 5; $try++)

    {

    $fp = fopen($file, "a+");

    if (flock($fp, LOCK_EX)) { // do an exclusive lock

    fseek($fp, 0);

    $id = fread($fp, 1024);

    $id++;

    ftruncate($fp, 0);

    fwrite($fp, strval($id));

    flock($fp, LOCK_UN); // release the lock

    break;

    }

    else

    {

    sleep(1);

    continue;

    }

    }

    fclose($fp);

    return $id;

    }

    The email is sended better and into the last line of the body there is the
    new serial number

    BUT......... IMMEDIATELY AFTER is sended a second EMPTY email without body
    that contain only the serial number (new)

    Please where wrong I?

    Thank you very much in adbance

    Pablo


  • shimmyshack

    #2
    Re: PHP srnd two emails

    On Jun 27, 9:50 pm, "Pablo" <p...@nospam.co mwrote:
    Hi at all
    >
    I call this function when I fill the foot of the body of the email that I'll
    send immediately after:
    >
    $text.=serial_n umber();
    >
    function serial_number()
    >
    {
    >
    $file="serial.t xt";
    >
    for ($try = 0; $try < 5; $try++)
    >
    {
    >
    $fp = fopen($file, "a+");
    >
    if (flock($fp, LOCK_EX)) { // do an exclusive lock
    >
    fseek($fp, 0);
    >
    $id = fread($fp, 1024);
    >
    $id++;
    >
    ftruncate($fp, 0);
    >
    fwrite($fp, strval($id));
    >
    flock($fp, LOCK_UN); // release the lock
    >
    break;
    >
    }
    >
    else
    >
    {
    >
    sleep(1);
    >
    continue;
    >
    }
    }
    >
    fclose($fp);
    >
    return $id;
    >
    }
    >
    The email is sended better and into the last line of the body there is the
    new serial number
    >
    BUT......... IMMEDIATELY AFTER is sended a second EMPTY email without body
    that contain only the serial number (new)
    >
    Please where wrong I?
    >
    Thank you very much in adbance
    >
    Pablo
    try showing us the code that does the emailing, rather than the code
    that tries 5 times to add a serial number to the end of a string.

    Comment

    • Pablo

      #3
      Re: PHP srnd two emails


      "shimmyshac k"
      wrote
      >
      try showing us the code that does the emailing, rather than the code
      that tries 5 times to add a serial number to the end of a string.
      >
      <?PHP

      function serialize()

      {

      $file="serial.t xt";

      for ($try = 0; $try < 5; $try++)

      {

      $fp = fopen($file, "a+");

      if (flock($fp, LOCK_EX)) { // do an exclusive lock

      fseek($fp, 0);

      $id = fread($fp, 1024);

      $id++;

      ftruncate($fp, 0);

      fwrite($fp, strval($id));

      flock($fp, LOCK_UN); // release the lock

      break;

      }

      else

      {

      sleep(1);

      continue;

      }

      }

      fclose($fp);

      return $id;

      }

      $mail_text="Dea r Sirs,\nthis is my question for you...........\ n\r";

      $mail_text.=$_R EQUEST['body_of_questi on']."\n\n";

      $mail_text.="Se rial n.".serialize() ."\n\n";

      $mail_subject=" Questions";

      $mail_to=$_REQU EST['mailto'];

      $mail_from=$_RE QUEST['_mailfrom'];

      $sended=@mail( $mail_to, $mail_subject, $mail_text, "From:
      {$mail_from}\n" );

      ?>


      Comment

      • Pablo

        #4
        Re: PHP srnd two emails

        "shimmyshac k"

        wrote
        >however you are encouraged to use PhpMailer
        or some other email class tp send your mail.
        Please how can I understand if the PHP version that work into my web site
        support PHPMailer?

        And if it do not support PHPMailer what can I do?

        Thank you


        Comment

        Working...