PHP, mail and multi-mime types

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

    PHP, mail and multi-mime types

    I'm tring to send out a dual encoded message in html and text message.
    From everything that I have read and seen as incoming messages this
    should work but it doesn't. Any ideas?

    TIA,

    Gary Smith

    <?php
    // generate MIME boundary
    echo uniqid(time()). "<br>";
    $boundary = "----=".md5(uniqid(t ime()))."";

    // set email headers
    $header = "Return-Path: jack_t1234@adnd realm.net\r\n";
    $header.= "From: Theo <jack_t1234@adn drealm.net>\r\n ";
    $header.= "MIME-Version: 1.0\r\n";
    $header.= "Content-Type: multipart/alternative;\r\ n
    boundary=\"$bou ndary\"\r\n";
    // set text section
    $txt_head = $boundary."\r\n ";
    $txt_head.= "Content-Type: text/plain;\r\n
    charset=\"iso-8859-1\"\r\n";
    $txt_head.= "Content-Transfer-Encoding: quoted-printable\r\n\r \n";
    $txt_head.= "some simple text\r\n";
    // set html section
    $htm_head = $boundary."\r\n ";
    $htm_head.= "Content-Type: text/html;\r\n
    charset=\"iso-8859-1\"\r\n";
    $htm_head.= "Content-Transfer-Encoding: quoted-printables\r\n\ r\n";
    $htm_head.= "<html><body><f ont
    size=3>Hello</font></body></html>\r\n\r\n";
    // combine headers & message
    $mesg = $txt_head.$htm_ head.$boundary. "--";
    // send email out
    mail ("jack_t1234@ad ndrealm.net","t est with dual
    encoding",$mesg ,$header);

    ?>
  • John Dunlop

    #2
    Re: PHP, mail and multi-mime types

    Gary Smith wrote:
    [color=blue]
    > I'm tring to send out a dual encoded message in html and text message.
    > From everything that I have read and seen as incoming messages this
    > should work but it doesn't. Any ideas?[/color]

    [Snip code]

    From the typos, misunderstandin gs, or just plain mistakes -- I can't
    discern which is which -- I'd suggest you either (re)read RFCs 2045-
    49 or use a purpose-built class[1]. If I were you, I'd reconsider
    using pseudo-HTML at all in email.


    [1] I can't vouch for it, but


    --
    Jock

    Comment

    • CountScubula

      #3
      Re: PHP, mail and multi-mime types

      "Gary Smith" <gary.smith@pri meexalia.com> wrote in message
      news:2e75b13e.0 401271824.7033b 161@posting.goo gle.com...[color=blue]
      > I'm tring to send out a dual encoded message in html and text message.
      > From everything that I have read and seen as incoming messages this
      > should work but it doesn't. Any ideas?
      >
      > TIA,
      >
      > Gary Smith
      >
      > <?php
      > // generate MIME boundary
      > echo uniqid(time()). "<br>";
      > $boundary = "----=".md5(uniqid(t ime()))."";
      >
      > // set email headers
      > $header = "Return-Path: jack_t1234@adnd realm.net\r\n";
      > $header.= "From: Theo <jack_t1234@adn drealm.net>\r\n ";
      > $header.= "MIME-Version: 1.0\r\n";
      > $header.= "Content-Type: multipart/alternative;\r\ n
      > boundary=\"$bou ndary\"\r\n";
      > // set text section
      > $txt_head = $boundary."\r\n ";
      > $txt_head.= "Content-Type: text/plain;\r\n
      > charset=\"iso-8859-1\"\r\n";
      > $txt_head.= "Content-Transfer-Encoding: quoted-printable\r\n\r \n";
      > $txt_head.= "some simple text\r\n";
      > // set html section
      > $htm_head = $boundary."\r\n ";
      > $htm_head.= "Content-Type: text/html;\r\n
      > charset=\"iso-8859-1\"\r\n";
      > $htm_head.= "Content-Transfer-Encoding: quoted-printables\r\n\ r\n";
      > $htm_head.= "<html><body><f ont
      > size=3>Hello</font></body></html>\r\n\r\n";
      > // combine headers & message
      > $mesg = $txt_head.$htm_ head.$boundary. "--";
      > // send email out
      > mail ("jack_t1234@ad ndrealm.net","t est with dual
      > encoding",$mesg ,$header);
      >
      > ?>[/color]

      Look at the complete email that is sent, and look for errors there.

      try this also:



      --
      Mike Bradley
      http://www.gzentools.com -- free online php tools


      Comment

      • Gary Smith

        #4
        Re: PHP, mail and multi-mime types

        I found my bug prior to your posting (it was the boundary requiring an
        additional "--" prior to each segment. Just something I overlooked I
        guess.

        The sample in the link is much better than mine so I'll just
        snippet... :)

        [color=blue]
        >
        > try this also:
        > http://www.gzentools.com/snippetview...send-email.php[/color]

        Thanks,

        Gary

        Comment

        Working...