SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2001
    Posts
    478
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Creating/Sending PHP form in html mail

    Jack's PHP formmail script ( http://www.dtheatre.com/scripts/formmail) works fine on my web site, however I can't get it to work when sending html mail.

    Please advise.

    Thank you,
    Herman
    Herman Drost
    http://www.isitebuild.com
    Affordable Web Site Design
    and Web Site Hosting

  2. #2
    SitePoint Wizard Crowe's Avatar
    Join Date
    Nov 2001
    Location
    Huntsville
    Posts
    1,117
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    That's because it does't sent HTML emails. On line 162 of the script you'll see the call to the php mail function:

    PHP Code:
    mail($recipient$subject$content"From: $email\r\nReply-To: $email\r\nX-Mailer: DT_formmail"); 
    It doesn't tell it anywhere that the mail is html.

    You would need to tweak the script just a little to get it to send html mail. You should take a look at this tutorial by SP's PHP guru Kevin Yank.
    Chrispian H. Burks
    Nothing To Say

  3. #3
    SitePoint Evangelist
    Join Date
    Jan 2001
    Posts
    478
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot - I 'll try and figure out what I need to do to alter the script ( a new one for me).

    I'll check out your great resource.

    Herman
    Herman Drost
    http://www.isitebuild.com
    Affordable Web Site Design
    and Web Site Hosting

  4. #4
    SitePoint Wizard Crowe's Avatar
    Join Date
    Nov 2001
    Location
    Huntsville
    Posts
    1,117
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Good deal. If you get stuck or need help post and I'll see wht I can do!
    Chrispian H. Burks
    Nothing To Say

  5. #5
    SitePoint Evangelist
    Join Date
    Jan 2001
    Posts
    478
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I did read thru Kevin's article, however it's a little too technical for someone new at PHP.

    What exactly would I need to change in the script http://www.dtheatre.com/scripts/formmail

    to make it work as an html mailer?

    Here's the test URL that works as a web page (but not as html email).

    http://www.ihost-websites.com/Herman.htm

    Thanks for your patience.

    Herman
    Herman Drost
    http://www.isitebuild.com
    Affordable Web Site Design
    and Web Site Hosting

  6. #6
    SitePoint Wizard Crowe's Avatar
    Join Date
    Nov 2001
    Location
    Huntsville
    Posts
    1,117
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    No problem. Why are you trying to send a simple form like that AS html? (Just curious).

    And do you want to send ALL mail as html, or just certain ones?
    Chrispian H. Burks
    Nothing To Say

  7. #7
    SitePoint Wizard Crowe's Avatar
    Join Date
    Nov 2001
    Location
    Huntsville
    Posts
    1,117
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I'm going to be gone for the next couple of days so I wanted to post this just in case. If you want this script to send ALL email as html email, change line 162 from this:

    PHP Code:
    mail($recipient$subject$content"From: $email\r\nReply-To: $email\r\nX-Mailer: DT_formmail" ); 
    To this:

    PHP Code:
    mail($recipient$subject$content"From: $email\r\nReply-To: $email\r\nX-Mailer: DT_formmail" "MIME-Version: 1.0\n" "Content-type: text/html; charset=iso-8859-1"); 
    And that should do it.
    Chrispian H. Burks
    Nothing To Say

  8. #8
    SitePoint Evangelist
    Join Date
    Jan 2001
    Posts
    478
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I tried this and got errors - apparently this script has a security feature to prevent it being emailed.

    Here's a script that works with html email:
    http://members.rogers.com/mail4donpro/

    Here's the web page (that works) with the script
    http://www.ihost-websites.com/Herman2.htm however I got these errors when sending the page as html email:

    [Sorry, but I cannot figure out who sent you here. Your browser is not sending an HTTP_REFERER. If you are using Norton Firewall (any version), please see the Norton support site.
    Please use the back button to correct these errors.]


    Please advise.

    Thank you,
    Herman
    Herman Drost
    http://www.isitebuild.com
    Affordable Web Site Design
    and Web Site Hosting

  9. #9
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doubtful the script it's self would have a security feature such as this ? Yet to look at the PHP manual myself on this though maybe you should look there ?

    Another problem could be your web host ? Have a word with them to see that you can send/recieve email w/ PHP.

  10. #10
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's the script I use to send html emails, just like any other else I guess.

    PHP Code:
    <?php
     
    $to 
    "any[email=any@email.com]@email.com[/email]";
    $subject "HTML Email";
    $message "
    <html>
    <head>
     <title></title>

    </head>
    <body>
    <font style=\"font-family:tahoma, arial, verdana;font-size:10pt\">
    content goes here like in any other html page.  
    </font>
    </body>
    </html>
     "
    ;

    $headers  "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .="From:My name <[email=whatever@email.com>rn]whatever@email.com>\r\n[/email]";

     
    mail($to$subject$message$headers);
    ?>
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine

  11. #11
    SitePoint Evangelist
    Join Date
    Jan 2001
    Posts
    478
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The script is working!

    http://www.ihost-websites.com/Herman2.htm

    I found the answer in another forum:

    I changed this line: Code:define('CHECK_REFERER', true);to look like this Code:define('CHECK_REFERER', false);

    Thanks for your input!

    BTW I tried the above script since it looked so simple however couldn't get it to work (I saved it as html file).
    Herman Drost
    http://www.isitebuild.com
    Affordable Web Site Design
    and Web Site Hosting

  12. #12
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vision2000
    BTW I tried the above script since it looked so simple however couldn't get it to work (I saved it as html file).
    You mean you saved it as file.html? It needs to be saved as file.php.
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine


Bookmarks

Posting Permissions

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