|
-
Jul 31st, 2003, 10:50 AM
#1
Thread Starter
Lively Member
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.
-
Aug 1st, 2003, 05:54 AM
#2
<?="Moderator"?>
$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
-
Aug 1st, 2003, 02:19 PM
#3
Stuck in the 80s
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.
-
Aug 3rd, 2003, 01:46 AM
#4
Frenzied Member
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.
-
Aug 11th, 2003, 05:35 AM
#5
Thread Starter
Lively Member
thanks for your help
I will remove all the unnecesery stuff,
BTW
<tr> tags do not need to be closed anymore.
Yair
-
Aug 11th, 2003, 06:03 AM
#6
Thread Starter
Lively Member
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
-
Aug 11th, 2003, 08:32 AM
#7
Frenzied Member
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>
-
Aug 11th, 2003, 08:45 AM
#8
Thread Starter
Lively Member
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
-
Aug 11th, 2003, 12:27 PM
#9
Stuck in the 80s
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.
-
Aug 11th, 2003, 09:15 PM
#10
Frenzied Member
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?
-
Aug 11th, 2003, 10:03 PM
#11
Stuck in the 80s
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.
-
Aug 12th, 2003, 01:35 AM
#12
Thread Starter
Lively Member
ok thanks
I dont know what is XHTML, I better start searching...
Yair
-
Aug 12th, 2003, 08:24 AM
#13
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|