Results 1 to 13 of 13

Thread: email via php [RESOLVED]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    74

    email via php [RESOLVED]

    hello,
    I am using this script to send HTML email via PHP but all I get is a number 479$...


    <?
    //add From: header
    $headers = "From:ybweb order form <> \n";
    $headers .= "Reply-To:[email protected]\n";

    //specify MIME version 1.0
    $headers .= "MIME-Version: 1.0\n";

    //unique boundary
    $boundary = uniqid("HTMLEMAIL");

    //tell e-mail client this e-mail contains//alternate versions
    $headers .= "Content-Type: multipart/alternative"."; boundary = $boundary \n\n";

    //message to people with clients who don't
    //understand MIME
    $headers .= "This is a MIME encoded message.\n\n";

    //plain text version of message
    $headers .= "--$boundary \n"."Content-Type: text/plain; charset=ISO-8859-1\n"."Content-Transfer-Encoding: base64\n\n";
    $headers .= chunk_split(base64_encode("Plain Text Message Goes HERE"));

    //HTML version of message
    $headers .= "--$boundary\n"."Content-Type: text/html;\n"."Content-Transfer-Encoding: base64\n\n";
    $HTML_SAVE =
    "<HTML><body><table cellpadding=4 cellspacing=1><tr><th>Seplementals</th><th>Amount</th><th>Price</th><th>ddd</th><tr><td>Extra pages</td><td>".$numPages."</td><td>".$pagePrice." $</td><td>".$numPages*$pagePrice." $</td><tr><td>Extra Forms</td><td>".$numForms."</td><td>".$formPrice." $</td><td>".$numForms*$formPrice." $</td><tr><td>Extra Server Forms</td><td>".$numSForms."</td><td>".$sformPrice." $</td><td>".$numSForms*$sformPrice." $</td><tr><td>Basic Package</td><td>1</td><td>".$packPrice." $</td><td>".$packPrice." $</td><tr><td>Total</td><td></td><td></td><td>".$numPages*$pagePrice + $numForms*$formPrice + $numSForms*$sformPrice + $packPrice." $</td></table></body></HTML>";
    $headers .= chunk_split(base64_encode($HTML_SAVE));

    //send message
    mail ("[email protected]", "test php mail", "", $headers);
    ?>


    the long line you see is a table that I try to send.
    iso I put it as a long long string and used some variables in it.
    all this table should be send to me to my email but I recive only 1 number which is 479$ isnt that the way to send HTML tables?


    Yair
    Last edited by yair24; Sep 8th, 2003 at 01:15 AM.
    -------------------------------------
    http://www.ybweb.com

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    $headers = "From:ybweb order form <> \n";
    hey im not 100% sure about this but try using '\n\r' on the end of each header line rather than just '\n'. hope it does something

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    You might also want to consider putting an email address between then <>'s, as I have come across several servers that will not accept the email without it.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    if all you are doing is sending html email why are you adding all that not necassary stuff in the headers??

    that stuff is for attachments, you don't need them for html email.
    PHP Code:
    <?
    //add From: header
    $headers = "From:ybweb order form <> \n";
    $headers .= "Reply-To:[email protected]\n";

    //HTML version of message
    $headers .= "Content-Type: text/html;\r\n";
    $HTML_SAVE =
    "<HTML><body><table cellpadding=4 cellspacing=1>
    <tr><th>Seplementals</th>
    <th>Amount</th>
    <th>Price</th>
    <th>ddd</th>
    <tr>
    <td>Extra pages</td>
    <td>".$numPages."</td>
    <td>".$pagePrice." $</td>
    <td>".$numPages*$pagePrice." $</td>
    <tr>
    <td>Extra Forms</td>
    <td>".$numForms."</td>
    <td>".$formPrice." $</td>
    <td>".$numForms*$formPrice." $</td>
    <tr>
    <td>Extra Server Forms</td>
    <td>".$numSForms."</td>
    <td>".$sformPrice." $</td><td>".$numSForms*$sformPrice." $</td>
    <tr><td>Basic Package</td>
    <td>1</td>
    <td>".$packPrice." $</td>
    <td>".$packPrice." $</td>
    <tr>
    <td>Total</td>
    <td></td>
    <td></td>
    <td>".$numPages*$pagePrice + $numForms*$formPrice + $numSForms*$sformPrice + $packPrice." $</td>
    </table></body></HTML>";

    //send message
    mail ("[email protected]", "test php mail", $HTML_SAVE, $headers);
    ?>
    tha tis all you need to send html emails. it will/should work on most servers. plus you have a lot html errors in there as you forgot to close you <tr> tags. and you have empty table cells too.
    Last edited by phpman; Aug 3rd, 2003 at 01:50 AM.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    74

    thanks for your help

    I will remove all the unnecesery stuff,

    BTW

    <tr> tags do not need to be closed anymore.

    Yair
    -------------------------------------
    http://www.ybweb.com

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    74

    ok I found out the problem:

    it is in this line:

    <td>".$numPages*$pagePrice + $numForms*$formPrice + $numSForms*$sformPrice + $packPrice." $</td>

    I probably cannot make calculation inside a string...
    with this line I recive the end of the table only

    without it I recive the full table.

    Thanks

    Yair
    -------------------------------------
    http://www.ybweb.com

  7. #7
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337

    Re: thanks for your help

    Originally posted by yair24
    I will remove all the unnecesery stuff,

    BTW

    <tr> tags do not need to be closed anymore.

    Yair
    but if you want browsers to work properly then it is suggested to close them. you will be surprised what difference it makes.

    just do this
    PHP Code:
    <td></td>
     
    $calc = ($numPages*$pagePrice) + ($numForms*$formPrice) + ($numSForms*$sformPrice) + $packPrice;
    <
    td>$calc $</td

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    74

    thanks,

    I fixed it already but thanks anyway,

    about the TR tag:
    what is the advantages that you mean when you close them?
    I know that the new standard allowes you to keep them opened.

    do you mean that if you close them then the performance of the browzers are better? for example: will a page be loaded faster if the TRs are closed?

    as much as I understand it is just making the page heavier:
    lets say you have a dynamic table that is build via PHP or Javascript, if you ad the </tr> and then create something like 1000 cells in the table then the page will be much heavier then if it will be without the closing TR... dont you agree?
    its saving on the file size. and I dont think that the parser will work any faster if you add them...
    unless you correct me...

    Yair
    -------------------------------------
    http://www.ybweb.com

  9. #9
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Not all browsers support HTML or the standard the same. If somebody views a page in an old browser and expects to see a </tr> tag, there could be display problems if it's not there.

    If you want to deliver to IE6 and NS6 only, then feel free to leave it out. I just consider it better coding to include it.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  10. #10
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    that the new standard? there is no new standard. it has been this way for years. if you want to get technical XHTML requires a closing tag. and that is what you really should be coding as regular html will go away.

    and hobo is correct, although it is good coding practices to close them.

    have you check the validator to see if you are correct about not closing them? does it validate without them?

  11. #11
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by phpman
    have you check the validator to see if you are correct about not closing them? does it validate without them?
    I don't know if it validates without them, but on on w3.org, for HTML 4.01, it says that the closing tag is optional.

    But as for XHTML, it is required, and I do agree that we should all start moving towards XHTML.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    74

    ok thanks

    I dont know what is XHTML, I better start searching...

    Yair
    -------------------------------------
    http://www.ybweb.com

  13. #13
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    Originally posted by The Hobo
    I don't know if it validates without them, but on on w3.org, for HTML 4.01, it says that the closing tag is optional.

    But as for XHTML, it is required, and I do agree that we should all start moving towards XHTML.
    yeah I know but I think it will still show you left them out.

    best to move on

Posting Permissions

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



Click Here to Expand Forum to Full Width