PHP Mail() and versions

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

    #1

    PHP Mail() and versions

    I'm using PHP 5 at home w/Apache & MySQL on a test system where I
    write through a form to a database and also send an email to people on
    a drop down list. Purpose for this is an electronic log at work where
    an email goes out to let a person know an entry has been made with a
    copy of the text on that email. Works fine on my test system at home
    but not at work. I'm trying to remember which version of PHP I'm
    using there and I'm thinking it's an early 4.x version (4.1 maybe).

    A couple of questions come to mind. Assuming that it is in fact, the
    early 4.x version that's responsible (because I'm not sure when the
    mail() function came into being (which PHP version), would it be
    possible to just copy a later folder version of PHP onto the version
    at work? I suppose if I dropped version 5 folder on top of the
    existing version 4 and it didn't work, I could just reverse that
    process and put my earlier version of 4.x back to get back to where I
    was... OR, is using something like phpmailer a better option?

    thanks very much for any pointers,

    cov
  • Martin Mandl - m2m tech support

    #2
    Re: PHP Mail() and versions

    On Feb 24, 5:13 am, cover <coverlandNOSPA M...@yahoo.comw rote:
    I'm using PHP 5 at home w/Apache & MySQL on a test system where I
    write through a form to a database and also send an email to people on
    a drop down list. Purpose for this is an electronic log at work where
    an email goes out to let a person know an entry has been made with a
    copy of the text on that email. Works fine on my test system at home
    but not at work. I'm trying to remember which version of PHP I'm
    using there and I'm thinking it's an early 4.x version (4.1 maybe).
    >
    A couple of questions come to mind. Assuming that it is in fact, the
    early 4.x version that's responsible (because I'm not sure when the
    mail() function came into being (which PHP version), would it be
    possible to just copy a later folder version of PHP onto the version
    at work? I suppose if I dropped version 5 folder on top of the
    existing version 4 and it didn't work, I could just reverse that
    process and put my earlier version of 4.x back to get back to where I
    was... OR, is using something like phpmailer a better option?
    >
    thanks very much for any pointers,
    >
    cov
    Dear Cover,

    mail() exists much longer than 4.1. Only thing which changed in 4.3 is
    the support for smtp_port. Have a look at the manual:



    It's more likely that your operating system is the problem, what are
    you using? Is the path to sendmail configured correctly? Do you have
    sendmail at all? Etc....

    Good luck

    Martin


    ------------------------------------------------
    online accounting on bash bases
    Online Einnahmen-Ausgaben-Rechnung

    ------------------------------------------------
    m2m server software gmbh


    Comment

    • cover

      #3
      Re: PHP Mail() and versions

      On 23 Feb 2007 22:07:55 -0800, "Martin Mandl - m2m tech support"
      <martin.mandl@g mail.comwrote:
      >Dear Cover,
      >
      >mail() exists much longer than 4.1. Only thing which changed in 4.3 is
      >the support for smtp_port. Have a look at the manual:
      >
      >http://at.php.net/manual/en/ref.mail.php
      >
      >It's more likely that your operating system is the problem, what are
      >you using? Is the path to sendmail configured correctly? Do you have
      >sendmail at all? Etc....
      >
      >Good luck
      >
      Martin
      Thanks Martin, I'm using XP on both machines and to be honest with
      you, I'm not real familiar with 'sendmail'. Having read references to
      it in various code snips but haven't read anything comprehensive
      enough to help me understand what it is and where it is. I.e. I
      haven't located a subfolder for 'sendmail' or a sendmail.exe file for
      example.

      My php.ini look like this:
      --------------------------------------------
      [mail function]
      ; For Win32 only.
      SMTP = mail.bigfoot.co m
      smtp_port = 25

      ; For Win32 only.
      ;sendmail_from = admin@maint.com
      -------------------------------------------

      Page code looks like this:
      -----------------------------------------------------------
      /* $to = stripslashes($t o); */
      $to = stripslashes($t o)."\r\n";
      $subject = stripslashes($s ubject);
      $text = stripslashes($t ext);
      /* mail('$to',$sub ject, $text); */
      mail($to, $subject, $text, "From: admin@localhost home.com");
      }

      mysql_close();
      ------------------------------------------------------------

      Again, this code works well at my home test machine.

      Comment

      • J.O. Aho

        #4
        Re: PHP Mail() and versions

        cover wrote:
        Thanks Martin, I'm using XP on both machines and to be honest with
        you, I'm not real familiar with 'sendmail'. Having read references to
        it in various code snips but haven't read anything comprehensive
        enough to help me understand what it is and where it is. I.e. I
        haven't located a subfolder for 'sendmail' or a sendmail.exe file for
        example.
        sendmail is a mailserver program (MTA), you can find a microsoft version of it
        at http://www.indigostar.com/sendmail.htm


        My php.ini look like this:
        --------------------------------------------
        [mail function]
        ; For Win32 only.
        SMTP = mail.bigfoot.co m
        smtp_port = 25
        As microsoft don't have any MTA by default installed, it's required to use an
        external mailer, it's quite important to configure this with right smart host
        for the client, as nowadays ISPs only allows users to use their SMTP from the
        same network.

        Using mail.bigfoot.co m may work for you at home, but on the remote server
        using it as smarthost may not be possible as they aren't on the same network.


        --

        //Aho

        Comment

        • Steve

          #5
          Re: PHP Mail() and versions


          "cover" <coverlandNOSPA M914@yahoo.comw rote in message
          news:bmc3u2li9n 0p9m1oovlbnuf1n vbkj13dif@4ax.c om...
          | On 23 Feb 2007 22:07:55 -0800, "Martin Mandl - m2m tech support"
          | <martin.mandl@g mail.comwrote:
          |
          | >Dear Cover,
          | >
          | >mail() exists much longer than 4.1. Only thing which changed in 4.3 is
          | >the support for smtp_port. Have a look at the manual:
          | >
          | >http://at.php.net/manual/en/ref.mail.php
          | >
          | >It's more likely that your operating system is the problem, what are
          | >you using? Is the path to sendmail configured correctly? Do you have
          | >sendmail at all? Etc....
          | >
          | >Good luck
          | >
          | Martin
          |
          | Thanks Martin, I'm using XP on both machines and to be honest with
          | you, I'm not real familiar with 'sendmail'. Having read references to
          | it in various code snips but haven't read anything comprehensive
          | enough to help me understand what it is and where it is. I.e. I
          | haven't located a subfolder for 'sendmail' or a sendmail.exe file for
          | example.

          here's what i use. it works either on linux or on windows (iis included).
          here's how you'd call it:
          (note that your drop directory would be c:/inetpub/mailroot/pickup/ ...
          also, remove the last argument - it is using sendmail in this case)

          email::send(
          $site->adminEmail ,
          $site->adminEmail ,
          '' ,
          '' ,
          $site->title . ' - Security Alert' ,
          '' ,
          $html ,
          $site->title ,
          $site->rootDirector y . 'images/email.logo.jpg' ,
          $site->mailDropDirect ory ,
          '/usr/sbin/sendmail -ti < '
          );


          and here's the actual class...sends either plain text and/or html:
          (you can add attachments to emails with *slight* modification and, notice
          that the company logo *is* an attachment...yo u'd just add another argument,
          encode the file(s) to be attached, and add another boundry for each...no
          big.)

          hth.

          <?
          class email
          {
          static function send(
          $to ,
          $from ,
          $cc = '' ,
          $bcc = '' ,
          $subject ,
          $text = '' ,
          $html = '' ,
          $companyName = '' ,
          $logo = null ,
          $dropDirectory = '' ,
          $exec = '' ,
          $execOptions = ''
          )
          {
          $messageHtml = $html;
          $html = '
          <html>
          <style>
          body
          {
          background-color : white;
          color : black;
          font-family : verdana, tahoma, arial, times new
          roman, sans-serif;
          font-size : 8pt;
          margin : 0px;
          text-align : left;
          }
          </style>
          <body>
          ';
          if (isset($logo))
          {
          $image = file_get_conten ts($logo);
          $image = chunk_split(bas e64_encode($ima ge));
          $html .= '
          <img alt="' . $companyName . '" border="0px"
          src="cid:logo" style="float:ri ght;">
          <br>
          <br>
          <br>
          <br clear="all">
          ';
          }
          if ($messageHtml == ''){ $messageHtml = '<html><body>' . $text; }
          $html .= $messageHtml . '</body></html>';
          if ($text == ''){ $text = $html; }
          $boundry = '----=' . md5(uniqid(rand ()));
          $related = '----=' . md5(uniqid(rand ()));
          $mail = "MIME-Version: 1.0\r\n";
          $mail .= "TO: " . $to . "\r\n";
          $mail .= "FROM: " . $from . "\r\n";
          $mail .= "CC: " . $cc . "\r\n";
          $mail .= "BCC: " . $bcc . "\r\n";
          $mail .= "Subject: " . $subject . "\r\n";
          $mail .= "Content-Type: multipart/related;
          boundary=\"$rel ated\"\r\n\r\n\ r\n";
          $mail .= "--$related\r\n";
          $mail .= "Content-Type: multipart/alternative;
          boundary=\"$bou ndry\"\r\n\r\n\ r\n";
          $mail .= "--$boundry\r\n";
          $mail .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
          $mail .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
          $mail .= $text . "\r\n\r\n";
          $mail .= "--$boundry\r\n";
          $mail .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
          $mail .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
          $mail .= $html . "\r\n\r\n";
          $mail .= "--$boundry--\r\n\r\n";
          $mail .= "--$related\r\n";
          $mail .= "Content-Type: image/jpeg\r\n";
          $mail .= "Content-ID: logo\r\n";
          $mail .= "Content-Disposition: attachment;
          filename=\"logo .jpg\"\r\n";
          $mail .= "Content-Transfer-Encoding: base64\r\n\r\n" ;
          $mail .= $image . "\r\n\r\n";
          $mail .= "--$related--\r\n\r\n";
          $mail .= "-- End --\r\n";
          $fileName = $dropDirectory . strtoupper(md5( uniqid(rand())) ) . '.eml';
          file_put_conten ts($fileName, $mail);
          if (!$exec){ return $mail; }
          exec($exec . $fileName . $execOptions);
          @unlink($fileNa me);
          return $mail;
          }
          }
          ?>


          Comment

          • Steve

            #6
            Re: PHP Mail() and versions


            "J.O. Aho" <user@example.n etwrote in message
            news:54drcnF1vq c35U1@mid.indiv idual.net...
            | cover wrote:
            |
            | Thanks Martin, I'm using XP on both machines and to be honest with
            | you, I'm not real familiar with 'sendmail'. Having read references to
            | it in various code snips but haven't read anything comprehensive
            | enough to help me understand what it is and where it is. I.e. I
            | haven't located a subfolder for 'sendmail' or a sendmail.exe file for
            | example.
            |
            | sendmail is a mailserver program (MTA), you can find a microsoft version
            of it
            | at http://www.indigostar.com/sendmail.htm
            |
            |
            |
            | My php.ini look like this:
            | --------------------------------------------
            | [mail function]
            | ; For Win32 only.
            | SMTP = mail.bigfoot.co m
            | smtp_port = 25
            |
            | As microsoft don't have any MTA by default installed, it's required to use
            an
            | external mailer, it's quite important to configure this with right smart
            host
            | for the client, as nowadays ISPs only allows users to use their SMTP from
            the
            | same network.

            AHO !!! while ms might now have an mta installed by default, the ONLY
            version WITHOUT one is XP HOME EDITION. all they have to do is install IIS
            (which he already has done) and make sure they select SMTP server as a
            component of IIS to install.

            a more TRUE statement is that windows does NOT come with a POP3 service.
            there are several on the web for free...or, if they already have exchange
            installed, neither smtp nor pop3 are an issue. he'll just need to know where
            to drop his email on his system.

            | Using mail.bigfoot.co m may work for you at home, but on the remote server
            | using it as smarthost may not be possible as they aren't on the same
            network.

            again, it's all in how you configure your own server. my prototyping system
            is windows xp pro. my production servers are all linux. the only problem
            i've ever had with using php and email is when i use php's default mail
            function. you've just described one of the problems, however there is no
            need to use a remote server to do any emailing.

            cheers


            Comment

            • J.O. Aho

              #7
              Re: PHP Mail() and versions

              Steve wrote:
              all they have to do is install IIS
              (which he already has done) and make sure they select SMTP server as a
              component of IIS to install.
              Are you sure? He only mentions whats on his machine, which is apache, which
              don't need IIS to be installed to work.

              | Using mail.bigfoot.co m may work for you at home, but on the remote server
              | using it as smarthost may not be possible as they aren't on the same
              network.
              >
              again, it's all in how you configure your own server. my prototyping system
              is windows xp pro. my production servers are all linux. the only problem
              i've ever had with using php and email is when i use php's default mail
              function. you've just described one of the problems,
              Can't say the OP did provide much information, so you need to start somewhere.

              however there is no need to use a remote server to do any emailing.
              Even if it's possible to send email with telnet (sockets), it may not be the
              best solution and if you don't use sockets and you don't have a simple MTA (or
              you choose to not use one), a remote MTA is quite sensible to use.


              --

              //Aho

              Comment

              Working...