Problems send MIME multipart/alternative mail with php

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Problems send MIME multipart/alternative mail with php

    I have had no success sending multipart/alternative emails with php. I have
    tried everyone's various code snippets with no luck. I test the results with
    Outlook and Outlook Express. Everytime my boundary tag ends up showing as
    part of my message and thus the plain text and html portions show up as one
    long blob of unformatted text. Below is the code I am currently using. Any
    suggestions would be greatly appreciated.

    Thanks,

    Dan

    The code:

    <?php
    error_reporting(E_ALL);
    //FUNCTION future
    multipartmailer($to,$from,$subject,$plaintextsourc e,$htmlsource);
    //$boundry="**=-=-=D-=-=-=-MIME-A-Boundry-=-=-N=-=-=-**";
    $boundry= "---=".uniqid("MAILDIVIDERS");
    //set mime type

    $headers="From: Person <ppersom@mail.com>\n";
    $headers.= "MIME-Version: 1.0\n";
    $headers.="Content-Type: multipart/alternative;
    boundary=\"$boundry\"\n";
    //these files have the raw message content
    $plaintext = file("plaintextcontent.txt");
    $html = file("htmlcontent.txt");
    //warning for non-MIME lovin' clients

    $headers .= "This message is in MIME format. Since your mail reader does not
    understand this format, some or all of this message may not be
    legible.\n\r\n\r";

    // CHOP
    $message .= $boundry."\n";
    $message .= "Content-Type: text/plain; charset=ISO-8859-1\n";
    $message .= "Content-Transfer-Encoding: 8bit\n\r";
    foreach($plaintext as $line) {
    ****$message .=$line;
    }
    $message .="\n".$boundry."\n";
    $message .= "Content-Type: text/html; charset=ISO-8859-1\n";
    $message .= "Content-Transfer-Encoding: 8bit\n";
    foreach($html as $line) {
    ****$message .=$line;
    }
    $message .="\n".$boundry."\n";
    mail("me@me.com","Welcome to the Website",$message,$headers);
    print $headers."".$message."<br>";

    ?>
    </body>
    </html
    Dan Van Derveer Guest

  2. Similar Questions and Discussions

    1. Mail::Bulkmail - multipart breaks when doing mail merge
      Hi, I've been using Mail::Bulkmail for a while now but never had to do both a mail merge and mutlipart togeather. I recently wrote a program that...
    2. [PHP] mail mime attachment
      I've been working on a simple mail attachment script, that is now working. Its pretty well documented in the code. You can download it at...
    3. send multipart alternative mails using MIME::Entity
      Can someone send me some examples on how to send multipart alternative mails using MIME::Entity Thanks Ram
    4. the script hangs up when i try to send mail with attachments using MAIL::Sender...???
      As said in the topic... when i try to send an e-mail message using Mail::Sender the script hangs up before execution of $sender ->...
    5. CDONTS multipart/alternative text content
      I'm using CDONTS and am trying to send an email out which displays in HTML for HTML-enabled clients, and plain text for non-HTML clients. ...
  3. #2

    Default Re: Problems send MIME multipart/alternative mail with php

    Hello,

    On 08/19/2003 04:56 PM, Dan Van Derveer wrote:
    > I have had no success sending multipart/alternative emails with php. I have
    > tried everyone's various code snippets with no luck. I test the results with
    > Outlook and Outlook Express. Everytime my boundary tag ends up showing as
    > part of my message and thus the plain text and html portions show up as one
    > long blob of unformatted text. Below is the code I am currently using. Any
    > suggestions would be greatly appreciated.
    That looks like a bug of the mail() function. You may want to try this
    class that provides an easy interface for composing and sending
    multipart/alternative MIME messages and has workarounds for some of the
    mail() function problems:

    [url]http://www.phpclasses.org/mimemessage[/url]

    --

    Regards,
    Manuel Lemos

    Free ready to use OOP components written in PHP
    [url]http://www.phpclasses.org/[/url]

    Manuel Lemos Guest

  4. #3

    Exclamation Re: Problems send MIME multipart/alternative mail with php

    I also hav the same problem while sending mail.... Thanks in advance for any good solutions........
    Dragonbaki Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139