Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 10 of 10
  1. #1
    Member blue_francis14's Avatar
    Join Date
    May 2007
    Location
    Philippines
    Posts
    83
    Member #
    15276
    i can't make my email form to work!!! could someone please help me out with this code...

    i included the html form.
    just ask me anything you need.

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    Do you get any errors?
    Does it just not send?
    Does it send, but the attachment isn't there?

    Describe the problem in better detail.


  4. #3
    Member blue_francis14's Avatar
    Join Date
    May 2007
    Location
    Philippines
    Posts
    83
    Member #
    15276
    oh, sorry about. I didn't know where to start. Well, first I can receive an email from the form. But the problem is, I doesn't display the way I want. It displays just text and not html. It displays the MIME part.

    I have been tinkering with the MIME and it's boundary but I have no idea what it the right way of doing it. I managed to get the first MIME for the header part, the one that says

    Code:
    $headers ='Mime-Version: 1.0\n';
    $headers .='Content-Type: multipart/mixed; boundary=\"$mime_boundary\"\n';
    That's what I did.

  5. #4
    Junior Member
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    25
    Member #
    15371
    So you can receive the form email but only text not HTML - what email program are you using to read the email? Are you sure you have it's HTML enabled? That could be why you can't view it in HTML.
    If you do have HTML enabled, does your form email actually send HTML email? Did you code the email body with HTML?

  6. #5
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    You might want to try the text/html content type.

  7. #6
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    PHP Code:
    $headers  "MIME-Version: 1.0\r\n";  
    $headers .= "Content-type: text/html; ";  
    $headers .= "charset=iso-8859-1\r\n";  
    $headers .= "From: $from\r\n"
    S. Rosland

  8. #7
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    I'm awaiting the answer to rfresh's question ...

    I think he might onto something there.


  9. #8
    ljm
    ljm is offline
    Senior Member ljm's Avatar
    Join Date
    Aug 2006
    Location
    Manchester, England
    Posts
    284
    Member #
    13684
    Liked
    1 times
    Quote Originally Posted by rosland
    PHP Code:
    $headers  "MIME-Version: 1.0\r\n";  
    $headers .= "Content-type: text/html; ";  
    $headers .= "charset=iso-8859-1\r\n";  
    $headers .= "From: $from\r\n"
    I reckon that's the solution. I've noticed that using '\n' alone means the headers don't all show up. I don't know why; maybe I should research it.

  10. #9
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Oh yes, deary me, how did I miss that. The reason it doesn't work is because the RFCs that define email and HTTP communications (and some others) typically specify carriage-return-line-feed as the separator between protocol-relevant lines, and a double carriage-return-line-feed as the separator between headers, body, and, possibly, footer.

  11. #10
    Member blue_francis14's Avatar
    Join Date
    May 2007
    Location
    Philippines
    Posts
    83
    Member #
    15276
    It was supposed to be simple script for sending email with attachment

    I think I went OC with the codes and forgot that it's already tuesday!

    Thanks for the suggestion guys. I got to work it how I wanted. The MIME's were the reason why I didn't work. I have to fix how it is printed by PHP.

    I attached the script in this post. FYI, the file is messy like my cubicle filled with clutters. Ehehehe....

    Anyway, here's what I did.

    PHP Code:
    $attachment $_FILES['userfile']['tmp_name'];
    $file_type $_FILES['userfile']['type'];
    $attachment_name $_FILES['userfile']['name']; 
        if (
    is_uploaded_file($attachment)) { //Do we have a file uploaded?
          
    $fp fopen($attachment"rb"); //Open it
          
    $data fread($fpfilesize($attachment)); //Read it
          
    $data chunk_split(base64_encode($data)); //Chunk it up and encode it as base64 so it can emailed
            
    fclose($fp);
        } 
    well, I didn't make this code, I just found it on the net. I just wanted how php uploads the picture. I didn't even removed his comments.

    Reason why the first one didn't work was that my boundarys for the MIME isn't made well and very inconsistent. I didn't even know what's the boundaries purpose is until I researched on it.

    To have it work, it has to be
    PHP Code:
    $headers "From:".$pname."<".$email.">".$eol;
    $headers .="Mime-Version: 1.0\n";
    $headers .="Content-Type: multipart/mixed"."; boundary=\"$mime_boundary\"\r\n"
    I have to end the headers part here. I think I need to be until the Content-Type: multipart/mixed. Why? Because it is the only one I can see when I check the full headers in Outlook and my Yahoo mail. For the real reason, I have no idea. I could probably a declaration for what type of email, and multipart/mixed means that I contains plain text, html and an image.
    PHP Code:
    $message "somethng you want to put here to warn the receiver he needs a mime enabled email client";
    $message .= "--$mime_boundary".$eol
    I figured that the boundary there is used to declare the boundary for each MIME.
    Another example would be:

    Quote Originally Posted by rosland
    PHP Code:
    $message  .= "MIME-Version: 1.0\r\n";  
    $message .= "Content-type: text/html; ";  
    $message .= "charset=iso-8859-1\r\n";  
    $message .= "From: $from\r\n"
    PHP Code:
    $message .= "insert your message here";
    $message .= "--$mime_boundary".$eol
    ok... now that the email can now be viewed as an email. I added another MIME for the image part.
    PHP Code:
    $message .= "Content-Type:".$file_type.";\n\tname=\"" $attachment_name "\"\n";
    $message .= "Content-Transfer-Encoding: base64\n";
    $message .= "Content-ID: zendimg1\n";
    $message .= "Content-Disposition: inline;\n\tfilename=\"" $attachment_name "\"\n\n";
    $message .= $data;
    $message .= "--$mime_boundary".$eol
    I wanted to make the image to be embedded, not attached. Meaning, you don't have to click on the little paper clip icon to view the image. It just shows it to you immediately.

    See the "Content-ID: zendimg1\n";"? It would serve as the source for the image tag in your html email.

    which is then placed here.

    PHP Code:
    $message .= "Content-type: text/html; ";  
     
    $message .= "charset=iso-8859-1\r\n";  
    $message .= "Content-Transfer-Encoding: 7bit\r\n";
     
    $message .='
    <html>
    <body>
    <table border="0" cellpadding="0" cellspacing="5">
       </tr>
        <tr>
        <td><img src="cid:zendimg1" border=0> </td>
      </tr>
    </table>
    </body>
    </html>'
    ;
    $message .="\r\n";
    $message .= "--$mime_boundary".$eol
    This frankenstien of a script finally worked! Well... for me and one my friend who is actually working on this. I volunteered to work on the PHP part because my programming thingie is craving for some program work. So.. did I good job?

    Quote Originally Posted by rfresh
    So you can receive the form email but only text not HTML - what email program are you using to read the email? Are you sure you have it's HTML enabled? That could be why you can't view it in HTML.
    If you do have HTML enabled, does your form email actually send HTML email? Did you code the email body with HTML?
    I am using Outlook 2003 with its default settings and my Yahoo email account.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:31 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com