php-general Digest 12 Jan 2010 05:08:45 -0000 Issue 6534

Topics (messages 300992 through 301012):

Re: To add the final ?> or not...
        300992 by: Bipper Goes!

Re: Formatting Decimals
        300993 by: Rick Dwyer
        300996 by: Paul M Foster
        301002 by: tedd
        301005 by: Rick Dwyer
        301007 by: Mattias Thorslund
        301008 by: Adam Richardson
        301009 by: Paul M Foster

test
        300994 by: LAMP
        300995 by: LAMP
        300997 by: Daniel Brown
        300998 by: LAMP

Count the Number of Certain Elements in An Array
        300999 by: Alice Wei
        301000 by: Jonathan Tapicer
        301001 by: Alice Wei

corect way to use mail() function
        301003 by: LAMP
        301004 by: Daevid Vincent
        301010 by: Paul M Foster
        301011 by: Daevid Vincent
        301012 by: Angus Mann

Re: Clean PHP 5.2.12 Build Core Dumping / Can't Build Port - FreeBSD 6.1
        301006 by: Don O'Neil

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Ever write a string replace function on a closing ?> //somecomment here like
end junk

I have written some systems and gone back two to three years later and found
myself having to do such.  Sloppy, sure.  Minimize cost to the client?  Oh
yeah.

I keep em, and comment 'em as I feel I should.

On Mon, Jan 11, 2010 at 2:24 AM, Olav <[email protected]> wrote:

> Paul M Foster wrote:
>
> > I leave it off. I don't want to have to worry about which editor I'm
> > using or whether I accidentally left some whitespace where it shouldn't
> > be.
>
> I also use different editors in different situations, both terminal based
> and GUI. For instance I find Midnight Commander's internal editor quite
> comfortable to use but unfortunately it does leave whitespace all over
> the place.
>
> This discussion made me think. From now on, I will probably also leave
> the closing ?> off in include files. If something isn't really needed
> then there is no rational reason to insist on using it.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
I have been asked to further modify the value to the nearest half cent.

So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5. And if it 7, 8 or 9 it gets rounded up to full cents.

Can this be done fairly easily? Not knowing PHP well, I am not aware of the logic to configure this accordingly.

Thanks,
--Rick




On Jan 11, 2010, at 10:55 AM, Ryan Sun wrote:

$newprice =  sprintf("$%.2f", 15.109);

On Sun, Jan 10, 2010 at 8:36 PM, Rick Dwyer <[email protected]> wrote:
Hello List.

Probably an easy question, but I am not able to format a number to round up from 3 numbers after the decimal to just 2.

My code looks like this:

$newprice = "$".number_format($old_price, 2, ".", ",");

and this returns "$0.109" when I am looking for "$0.11".


I tried:

$newprice = "$".round(number_format($old_price, 2, ".", ","),2);
But no luck.

Any help is appreciated.

Thanks,

 --Rick



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




 --Rick



--- End Message ---
--- Begin Message ---
On Mon, Jan 11, 2010 at 02:55:33PM -0500, Rick Dwyer wrote:

> I have been asked to further modify the value to the nearest half cent.
>
> So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
> If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 it
> gets rounded up to full cents.
>
> Can this be done fairly easily?  Not knowing PHP well, I am not aware
> of the logic to configure this accordingly.

Yes, this can be done, but you'll need to write a function to do it
yourself. I'd also suggest you look into the BCMath functions, at:

http://us2.php.net/manual/en/book.bc.php

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:
I have been asked to further modify the value to the nearest half cent.

So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5. And if it 7, 8 or 9 it gets rounded up to full cents.

Can this be done fairly easily? Not knowing PHP well, I am not aware of the logic to configure this accordingly.

Thanks,
--Rick


--Rick:

The above described rounding algorithm introduces more bias than simply using PHP's round() function, which always rounds down. IMO, modifying rounding is not worth the effort.

The "best" rounding algorithm is to look at the last digit and do this:

0 -- no rounding needed.
1-4 round down.
6-9 round up.

In the case of 5, then look to the number that precedes it -- if it is even, then round up and if it is odd, then round down -- or vise versa, it doesn't make any difference as long as you are consistent.

Here are some examples:

122.4  <-- round down (122)
122.6 <-- round up (123)
122.5 <-- round up (123)

123.4  <-- round down (123)
123.6 <-- round up (124)
123.5 <-- round down (123)

There are people who claim that there's no difference, or are at odds with this method, but they simply have not investigated the problem sufficiently to see the bias that rounding up/down causes. However, that difference is very insignificant and can only be seen after tens of thousands iterations. PHP's rounding function is quite sufficient.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---

On Jan 11, 2010, at 4:56 PM, tedd wrote:

At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:
I have been asked to further modify the value to the nearest half cent.

So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5. And if it 7, 8 or 9 it gets rounded up to full cents.

Can this be done fairly easily? Not knowing PHP well, I am not aware of the logic to configure this accordingly.

Thanks,
--Rick


--Rick:

The above described rounding algorithm introduces more bias than simply using PHP's round() function, which always rounds down. IMO, modifying rounding is not worth the effort.

I understand what you are saying and I agree. But the decision to round to half cents as outlined above is a client requirement, not mine (I did try to talk them out of it but no luck).

I come from an LDML environment, not a PHP one so I don't know the actual code to make this happen. But the logic would be something like:

If 3 decimal than look at decimal in position 3.

If value = 1 or 2 set it to 0
If value = 3,4,5,6 round it to 5
If value = 7,8,9 round it to a full cent


Anybody have specific code examples to make this happen?

Thanks,

--Rick







The "best" rounding algorithm is to look at the last digit and do this:

0 -- no rounding needed.
1-4 round down.
6-9 round up.

In the case of 5, then look to the number that precedes it -- if it is even, then round up and if it is odd, then round down -- or vise versa, it doesn't make any difference as long as you are consistent.

Here are some examples:

122.4  <-- round down (122)
122.6 <-- round up (123)
122.5 <-- round up (123)

123.4  <-- round down (123)
123.6 <-- round up (124)
123.5 <-- round down (123)

There are people who claim that there's no difference, or are at odds with this method, but they simply have not investigated the problem sufficiently to see the bias that rounding up/down causes. However, that difference is very insignificant and can only be seen after tens of thousands iterations. PHP's rounding function is quite sufficient.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



 --Rick



--- End Message ---
--- Begin Message ---
tedd wrote:
At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:
I have been asked to further modify the value to the nearest half cent.

So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5. And if it 7, 8 or 9 it gets rounded up to full cents.

Can this be done fairly easily? Not knowing PHP well, I am not aware of the logic to configure this accordingly.

Thanks,
--Rick


--Rick:

The above described rounding algorithm introduces more bias than simply using PHP's round() function, which always rounds down. IMO, modifying rounding is not worth the effort.

The "best" rounding algorithm is to look at the last digit and do this:

0 -- no rounding needed.
1-4 round down.
6-9 round up.

In the case of 5, then look to the number that precedes it -- if it is even, then round up and if it is odd, then round down -- or vise versa, it doesn't make any difference as long as you are consistent.

Here are some examples:

122.4  <-- round down (122)
122.6 <-- round up (123)
122.5 <-- round up (123)

123.4  <-- round down (123)
123.6 <-- round up (124)
123.5 <-- round down (123)

There are people who claim that there's no difference, or are at odds with this method, but they simply have not investigated the problem sufficiently to see the bias that rounding up/down causes. However, that difference is very insignificant and can only be seen after tens of thousands iterations. PHP's rounding function is quite sufficient.

Cheers,

tedd


However that's not what Rick is asking for. He needs a function that rounds to the half penny with a bias to rounding up (greedy bosses):


Actual Rounded Diff
.011   .010    -.001
.012   .010    -.002
.013   .015    +.002
.014   .015    +.001
.015   .015     .000
.016   .015    -.001
.017   .020    +.003
.018   .020    +.002
.019   .020    +.001
.020   .020     .000
Bias           +.005

This could easily be implemented by getting the 3rd decimal and using it in a switch() statement.

An unbiased system could look like:

Actual Rounded Diff
.011   .010    -.001
.012   .010    -.002
.013   .015    +.002
.014   .015    +.001
.015   .015     .000
.016   .015    -.001
.017   .020    -.002
.018   .020    +.002
.019   .020    +.001
.020   .020     .000
Bias            .000

The only difference is the case where the third decimal is 7.

Cheers,

Mattias

--- End Message ---
--- Begin Message ---
On Mon, Jan 11, 2010 at 7:45 PM, Mattias Thorslund <[email protected]>wrote:

> tedd wrote:
>
>> At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:
>>
>>> I have been asked to further modify the value to the nearest half cent.
>>>
>>> So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
>>> If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 it
>>> gets rounded up to full cents.
>>>
>>> Can this be done fairly easily?  Not knowing PHP well, I am not aware of
>>> the logic to configure this accordingly.
>>>
>>> Thanks,
>>> --Rick
>>>
>>
>>
>> --Rick:
>>
>> The above described rounding algorithm introduces more bias than simply
>> using PHP's round() function, which always rounds down. IMO, modifying
>> rounding is not worth the effort.
>>
>> The "best" rounding algorithm is to look at the last digit and do this:
>>
>> 0 -- no rounding needed.
>> 1-4 round down.
>> 6-9 round up.
>>
>> In the case of 5, then look to the number that precedes it -- if it is
>> even, then round up and if it is odd, then round down -- or vise versa, it
>> doesn't make any difference as long as you are consistent.
>>
>> Here are some examples:
>>
>> 122.4  <-- round down (122)
>> 122.6 <-- round up (123)
>> 122.5 <-- round up (123)
>>
>> 123.4  <-- round down (123)
>> 123.6 <-- round up (124)
>> 123.5 <-- round down (123)
>>
>> There are people who claim that there's no difference, or are at odds with
>> this method, but they simply have not investigated the problem sufficiently
>> to see the bias that rounding up/down causes. However, that difference is
>> very insignificant and can only be seen after tens of thousands iterations.
>>  PHP's rounding function is quite sufficient.
>>
>> Cheers,
>>
>> tedd
>>
>>
> However that's not what Rick is asking for. He needs a function that rounds
> to the half penny with a bias to rounding up (greedy bosses):
>
>
> Actual Rounded Diff
> .011   .010    -.001
> .012   .010    -.002
> .013   .015    +.002
> .014   .015    +.001
> .015   .015     .000
> .016   .015    -.001
> .017   .020    +.003
> .018   .020    +.002
> .019   .020    +.001
> .020   .020     .000
> Bias           +.005
>
> This could easily be implemented by getting the 3rd decimal and using it in
> a switch() statement.
>
> An unbiased system could look like:
>
> Actual Rounded Diff
> .011   .010    -.001
> .012   .010    -.002
> .013   .015    +.002
> .014   .015    +.001
> .015   .015     .000
> .016   .015    -.001
> .017   .020    -.002
> .018   .020    +.002
> .019   .020    +.001
> .020   .020     .000
> Bias            .000
>
> The only difference is the case where the third decimal is 7.
>
> Cheers,
>
> Mattias
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Here you go, Rick.  Just send the check in the mail ;)

function round_to_half_cent($amount)
{
if (!is_numeric($amount)) throw new Exception('The amount received by the
"round_to_half_cent" function was not numeric');
 $parts = explode('.', str_replace(',', '', (string)$amount));
 if (count($parts) >= 3) throw new Exception('The amount received by the
"round_to_half_cent" function had too many decimals.');
 if (count($parts) == 1)
{
return $amount;
}
 $digit = substr($parts[1], 2, 1);
 if ($digit == 0 || $digit == 1 || $digit == 2)
{
$digit = 0;
}
elseif ($digit == 3 || $digit == 4 || $digit == 5 || $digit == 6)
{
$digit = .005;
}
elseif ($digit == 7 || $digit == 8 || $digit == 9)
{
$digit = .01;
}
else
{
throw new Exception('OK, perhaps we are talking about different types of
numbers :(  Check the input to the "round_to_half_cent" function.');
}
 return (double)($parts[0].'.'.substr($parts[1], 0, 2)) + $digit;
}

echo "5.002 = ".round_to_half_cent(5.002);
echo "<br />70,000.126 = ".round_to_half_cent("70000.126");
echo "<br />55.897 = ".round_to_half_cent(55.897);
// should cause exception
echo "<br />One hundred = ".round_to_half_cent("One hundred");

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
On Mon, Jan 11, 2010 at 04:56:03PM -0500, tedd wrote:

>
> --Rick:
>
> The above described rounding algorithm introduces more bias than
> simply using PHP's round() function, which always rounds down. IMO,
> modifying rounding is not worth the effort.
>
> The "best" rounding algorithm is to look at the last digit and do this:
>
> 0 -- no rounding needed.
> 1-4 round down.
> 6-9 round up.
>
> In the case of 5, then look to the number that precedes it -- if it
> is even, then round up and if it is odd, then round down -- or vise
> versa, it doesn't make any difference as long as you are consistent.
>
> Here are some examples:
>
> 122.4  <-- round down (122)
> 122.6 <-- round up (123)
> 122.5 <-- round up (123)
>
> 123.4  <-- round down (123)
> 123.6 <-- round up (124)
> 123.5 <-- round down (123)
>
> There are people who claim that there's no difference, or are at odds
> with this method, but they simply have not investigated the problem
> sufficiently to see the bias that rounding up/down causes. However,
> that difference is very insignificant and can only be seen after tens
> of thousands iterations.  PHP's rounding function is quite sufficient.

This is called (among other things) "banker's rounding". But PHP's
round() function won't do banker's rounding, as far as I know.

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
sorry for this - previous email didn't get through?!!?!?

--- End Message ---
--- Begin Message ---
I tried again and got this error message:

Hi. This is the qmail-send program at outbound-mail-319.bluehost.com.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

<[email protected]>:
76.75.200.58 failed after I sent the message.
Remote host said: 550 we're manly enough already


?!?!?!!??!






--- Enclosed are the original headers of the message.



LAMP wrote:
sorry for this - previous email didn't get through?!!?!?



--- End Message ---
--- Begin Message ---
On Mon, Jan 11, 2010 at 15:52, LAMP <[email protected]> wrote:
> I tried again and got this error message:
>
> Hi. This is the qmail-send program at outbound-mail-319.bluehost.com.
> I'm afraid I wasn't able to deliver your message to the following addresses.
> This is a permanent error; I've given up. Sorry it didn't work out.
>
> <[email protected]>:
> 76.75.200.58 failed after I sent the message.
> Remote host said: 550 we're manly enough already

    Sounds like a subscriber's mail server bounced your list message
because it thought it was SPAM.  Nothing to worry about.... your email
came through.

    For the future, when unsure about list messages, check
http://news.php.net/php.general/ .

-- 
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
Looking for hosting or dedicated servers?  Ask me how we can fit your budget!

--- End Message ---
--- Begin Message ---
Daniel Brown wrote:
On Mon, Jan 11, 2010 at 15:52, LAMP <[email protected]> wrote:
I tried again and got this error message:

Hi. This is the qmail-send program at outbound-mail-319.bluehost.com.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

<[email protected]>:
76.75.200.58 failed after I sent the message.
Remote host said: 550 we're manly enough already

    Sounds like a subscriber's mail server bounced your list message
because it thought it was SPAM.  Nothing to worry about.... your email
came through.

    For the future, when unsure about list messages, check
http://news.php.net/php.general/ .

But I still can't send my question!?! :-)


LL

--- End Message ---
--- Begin Message ---
Hi, 

  This seems like a pretty simple problem, but I can't seem to be able to 
figure it out. I have a lot of elements in an array, and some of them are 
duplicates, but I don't want to delete them because I have other purposes for 
it. Is it possible for me to find out the number of certain elements in an 
array? 

  For example, 

   // Create a simple array.
   $array = array(1, 2, 3, 4, 5, 3,3,4,2);
   $total = count($array);
   echo $total;
  
  If I run the code, the value of $total would be 9. However, what I really 
want to do is to get the values of the different instances of each, like:

   1 => 1
   2 => 2
   3 => 3
   4=>  2
   5=>  1

Is there a simple code that I use to find this out? 

Thanks for your help. 

Alice
                                          
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/196390707/direct/01/

--- End Message ---
--- Begin Message ---
On Mon, Jan 11, 2010 at 6:21 PM, Alice Wei <[email protected]> wrote:
>
> Hi,
>
>  This seems like a pretty simple problem, but I can't seem to be able to 
> figure it out. I have a lot of elements in an array, and some of them are 
> duplicates, but I don't want to delete them because I have other purposes for 
> it. Is it possible for me to find out the number of certain elements in an 
> array?
>
>  For example,
>
>   // Create a simple array.
>   $array = array(1, 2, 3, 4, 5, 3,3,4,2);
>   $total = count($array);
>   echo $total;
>
>  If I run the code, the value of $total would be 9. However, what I really 
> want to do is to get the values of the different instances of each, like:
>
>   1 => 1
>   2 => 2
>   3 => 3
>   4=>  2
>   5=>  1
>
> Is there a simple code that I use to find this out?
>
> Thanks for your help.
>
> Alice
>
> _________________________________________________________________
> Hotmail: Trusted email with powerful SPAM protection.
> http://clk.atdmt.com/GBL/go/196390707/direct/01/


Hi,

Try the function array_count_values.

Regards,

Jonathan

--- End Message ---
--- Begin Message ---
> Date: Mon, 11 Jan 2010 18:31:43 -0300
> Subject: Re: [PHP] Count the Number of Certain Elements in An Array
> From: [email protected]
> To: [email protected]
> CC: [email protected]
> 
> On Mon, Jan 11, 2010 at 6:21 PM, Alice Wei <[email protected]> wrote:
> >
> > Hi,
> >
> >  This seems like a pretty simple problem, but I can't seem to be able to 
> > figure it out. I have a lot of elements in an array, and some of them are 
> > duplicates, but I don't want to delete them because I have other purposes 
> > for it. Is it possible for me to find out the number of certain elements in 
> > an array?
> >
> >  For example,
> >
> >   // Create a simple array.
> >   $array = array(1, 2, 3, 4, 5, 3,3,4,2);
> >   $total = count($array);
> >   echo $total;
> >
> >  If I run the code, the value of $total would be 9. However, what I really 
> > want to do is to get the values of the different instances of each, like:
> >
> >   1 => 1
> >   2 => 2
> >   3 => 3
> >   4=>  2
> >   5=>  1
> >
> > Is there a simple code that I use to find this out?
> >
> > Thanks for your help.
> >
> > Alice
> >
> > _________________________________________________________________
> > Hotmail: Trusted email with powerful SPAM protection.
> > http://clk.atdmt.com/GBL/go/196390707/direct/01/
> 
> 
> Hi,
> 
> Try the function array_count_values.
> 
   Thanks, this is cool. There is already a function for it!

> Regards,
> 
> Jonathan
                                          
_________________________________________________________________
Hotmail: Free, trusted and rich email service.
http://clk.atdmt.com/GBL/go/196390708/direct/01/

--- End Message ---
--- Begin Message ---
Hi,
The company I work for, hosts online events registration applications. After a registered registered himself for an event he will get a confirmation email saying he registered successfully. Currently, in the header part of the mail(), in "From" it says e.g. [email protected] - because the email comes from us not from our client (e.g. ABC Assoc.). Reply-to goes to us too.

Now one of our clients (e.g. ABC Assoc.) asks us to put in the "from" field their email, to looks like the email comes from them. something like: From: ABC Assoc. <[email protected]>;

I refused to do that concerned we are going to be blacklisted for sending "spam". Because header shows one place and From field says other email address - spam way of sending emails.

Am I right or it really doesn't matter "who" sent the email?

LL



--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: LAMP [mailto:[email protected]] 
> Sent: Monday, January 11, 2010 2:17 PM
> To: PHP-General List
> Subject: [PHP] corect way to use mail() function
> 
> Hi,
> The company I work for, hosts online events registration 
> applications. 
> After a registered registered himself for an event he will get a 
> confirmation email saying he registered successfully.
> Currently, in the header part of the mail(), in "From" it says e.g. 
> [email protected] - because the email comes from us not from our 
> client (e.g. ABC Assoc.). Reply-to goes to us too.
> 
> Now one of our clients (e.g. ABC Assoc.) asks us to put in the "from" 
> field their email, to looks like the email comes from them. something 
> like: From: ABC Assoc. <[email protected]>;
> 
> I refused to do that concerned we are going to be blacklisted for 
> sending "spam". Because header shows one place and From field 
> says other 
> email address - spam way of sending emails.
> 
> Am I right or it really doesn't matter "who" sent the email?
> 
> LL

I do that sort of thing all the time and don't get RBL'd.

I think the key things are if your domain can be reverse verified, the
frequency you send (if you're just sending hundreds of emails out that's a
red flag), BCC: but no TO:, and if the content/body seems to be non-spammy.
Make sure any hyperlinks in the body are correct and non-spammy looking
too. A common phishing routine is to display one hyperlink to the user, but
the actual 'click' takes you somewhere else. I think doing one of those,
"to register, click _here_" deals is WORSE (from an automated spam filter
POV) than showing the actual hyperlink and making it a hyperlink too. Ala,
"to register, click http://www.abcaccos.org/register/fa4jar4875";. Avoid
sending HTML emails for registrations too. It has a better chance of
getting through and should have a disclaimer in it to 'whitelist this
sender' sort of dealio. Once they're setup, then you can work with HTML
emails, but you don't want to loose/frustrate customers right off the bat
by not letting them register properly despite how pretty you think the HTML
version looks.

I think you should 
[a] do what your client asks -- it's their money
[b] put in a From: that is representative of the site the user expected the
email to actually come from
[c] put a disclaimer on your web form for the person to add
"[email protected]" and "[email protected]" to their whitelist
(no-spam filter)
[d] make the SUBJ: line of the email VERY explicit about WHO and WHAT this
is concerning:
    ie SUBJ: "Registration Confirmation from ABC Assoc. for username JDOE
requested"

If I was a customer and got an email from @computility.com and I didn't
know who the heck they were, since I was expecting from @abcaccos.org, then
I would most likely delete it. I have an itchy trigger finger and tend to
delete first, ask questions later. ;-)


--- End Message ---
--- Begin Message ---
On Mon, Jan 11, 2010 at 04:17:30PM -0600, LAMP wrote:

> Hi,
> The company I work for, hosts online events registration applications.
> After a registered registered himself for an event he will get a
> confirmation email saying he registered successfully.
> Currently, in the header part of the mail(), in "From" it says e.g.
> [email protected] - because the email comes from us not from our
> client (e.g. ABC Assoc.). Reply-to goes to us too.
>
> Now one of our clients (e.g. ABC Assoc.) asks us to put in the "from"
> field their email, to looks like the email comes from them. something
> like: From: ABC Assoc. <[email protected]>;
>
> I refused to do that concerned we are going to be blacklisted for
> sending "spam". Because header shows one place and From field says other
> email address - spam way of sending emails.
>
> Am I right or it really doesn't matter "who" sent the email?

Since the mail() function doesn't have a parameter for the "From:", how
do you force it to be a certain thing in the first place?

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
 

> -----Original Message-----
> From: Paul M Foster [mailto:[email protected]] 
> Sent: Monday, January 11, 2010 8:51 PM
> To: [email protected]
> Subject: Re: [PHP] corect way to use mail() function
> 
> On Mon, Jan 11, 2010 at 04:17:30PM -0600, LAMP wrote:
> 
> > Hi,
> > The company I work for, hosts online events registration 
> applications.
> > After a registered registered himself for an event he will get a
> > confirmation email saying he registered successfully.
> > Currently, in the header part of the mail(), in "From" it says e.g.
> > [email protected] - because the email comes from us 
> not from our
> > client (e.g. ABC Assoc.). Reply-to goes to us too.
> >
> > Now one of our clients (e.g. ABC Assoc.) asks us to put in 
> the "from"
> > field their email, to looks like the email comes from them. 
> something
> > like: From: ABC Assoc. <[email protected]>;
> >
> > I refused to do that concerned we are going to be blacklisted for
> > sending "spam". Because header shows one place and From 
> field says other
> > email address - spam way of sending emails.
> >
> > Am I right or it really doesn't matter "who" sent the email?
> 
> Since the mail() function doesn't have a parameter for the 
> "From:", how
> do you force it to be a certain thing in the first place?
> 
> Paul

That's what the headers are for son! :)

        /**
         * This is the actual 'engine' that does the sending of an SMS or
Email.
         *
         * @access  static final
         * @return  void
         * @param       string $to the email address to send to
         * @param       string $subject the subject line of the message
         * @param       string $body the body of the message
         * @param       boolean $html use 'html' (true) or 'plain' (false)
         * @author  Daevid Vincent [[email protected]]
         * @date        12/22/09
         * @see send_email()
         */
        static final function email($to, $subject, $body, $html=true)
        {
                $headers  = "MIME-Version: 1.0\r\n";
                $headers .= "Content-type: text/".( ($html) ? 'html' :
'plain')."; charset=iso-8859-1\r\n";
                $headers .= "From: ".COMPANY_FULL_NAME.' '.PRODUCT_NAME."
<".PRODUCT_SUPPORT_EMAIL.">\n";
                //$headers .= "Cc: Daevid Vincent
<daevid@".COMPANY_DOMAIN.">\r\n";
                //$headers .= "Bcc: [email protected]\r\n";
                //$headers .= "Reply-To: ".$myname."
<".$myreplyemail.">\r\n";
                $headers .= "X-Priority: 1\r\n";
                $headers .= "X-MSMail-Priority: High\r\n";
                $headers .= "X-Mailer: ".COMPANY_FULL_NAME." Linux Server";

                $body .= "<p>\n\n<i>This is an automated email from host
(".$_SERVER['SERVER_NAME'].") ".$_SERVER['SERVER_ADDR'].". Do not reply to
it.</i>";
                if (!$html) $body = strip_tags($body);

                mail($to, $subject, $body, $headers);
        }


        /**
         * Send this user an HTML email.
         *
         * @access      public
         * @return      boolean
         * @author      Daevid Vincent [[email protected]]
         * @date        12/22/09
         * @see User::email()
         */
        public function send_email($subject, $body)
        {
                $to = $this->get_fullname().' <'.$this->email.'>';
                User::email($to, $subject, $body,
(strtolower($this->emailformat) == 'html') );
                add_user_log('Action', 'Email \''.$subject.'\' sent');
        }


ÐÆ5ÏÐ 
http://daevid.com

There are only 11 types of people in this world. Those that think binary
jokes are funny, those that don't, and those that don't know binary.


--- End Message ---
--- Begin Message ---
There are only 11 types of people in this world. Those that think binary
jokes are funny, those that don't, and those that don't know binary.

Er....Ummm.....shouldn't that read "...only 10 types of people..." ?



--- End Message ---
--- Begin Message ---
Ok.. just for grins I installed a new instance of 6.1, NO Patches, just
straight off the ISO...

I loaded the ports that came WITH the distro, and was able to make php 5.1.2
ok...

When I did a portsnap fetch, portsnap extract, then went into the
/usr/ports/lang/php5 and just typed make I get the same error...

SO as it seems, the port is broken, at least for working with FreeBSD 6.1.

Can anyone give me some hints on how to build this sucker by hand? Seems as
though there are a bunch of patches that are referenced in the distinfo
file.

I REALLY need to get this taken care of asap, any help is appreciated.

Thanks!

> > > I tried adding WITHOUT_X11=yes to /etc/make.conf as well as
> X11BASE=
> > and
> > > X11BASE="", but I still get the same error.
> >
> > Remove them. This makes sure they are not defined, not even
> > empty (as in "#define BLA -> symbol 'BLA' is defined").
> >
> > > Where to go from here? Do I have and old version of something that
> is
> > > causing this? I get this error _right away_ before anything is even
> > built.
> >
> > It seems to be a check by the Makefile at port's top level.
> 
> Ok... I have no definition for X11BASE anywhere, not in my env, not in
> my
> /etc/make.conf, nowhwere...
> 
> However, it's still complaining about X11BASE being deprecated. I tried
> just
> adding WITHOUT_X11=yes in /etc/make, and without it. I even searched
> all the
> Makefiles in /usr/ports, and in the /usr/ports/lang/php5 dir to find
> any
> reference to X11, or X, or X11BASE, but nada... I don't even know where
> this
> error message is being generated from.
> 
> I can't even do a basic make without it immediately spitting out the
> error:
> 
> # make
> X11BASE is now deprecated.  Unset X11BASE in make.conf and try again.
> *** Error code 1
> 
> Stop.
> 


--- End Message ---

Reply via email to