Re: [PHP] RE: header data being inserted into message

2006-01-19 Thread Richard Lynch
On Tue, January 17, 2006 9:12 am, ET Support wrote:
> I am having a problem using PHP's mail function to send mail via BCC
> to
> multiple recipients. Here's my code;
> --
> $get_emails = pg_exec($dbh,"SELECT email FROM mailing_list WHERE conf
> = 1");
> $count = pg_numrows($get_emails);
> $bcc_count = $envelope_count = 0;
> $bcc_limit = 200;
> $subject = $body = 'test message';
> $from = '[EMAIL PROTECTED]';
> $header = "From: $from\r\n";

You probably want Reply-to: here as well...

> for($x = 0; $x < $count; $x++) {
>   $email = pg_result($get_emails,$x,0);
>   if($bcc_count >= $bcc_limit) {
>   if($x > 0) {
>   $envelope_count++;
>   mail($from,$subject,$body,$headers);
>   }
>   $headers = $header . "Bcc: $email\r\n";

>   $bcc_count = 1;
>   } else {
>   $headers .= "Bcc: $email\r\n";
>   $bcc_count++;
>   }
> }
> # send the last envelope
> mail($from,$subject,$body,$headers);
> --
>
> The problem is that for some recipients they get a message body like
> this;
>
> --
> Message-Id: <[EMAIL PROTECTED]>
> Date: Mon, 16 Jan 2006 17:06:40 + (GMT)
>
> test message
> --
>
> Any idea why those headers are being inserted into the message body
> and how
> that can be prevented?

If $email contains a newline, or a \r\n, then you might see that...

Because your Bcc: $email\r\n turns into:

Bcc: junk\n
\r\n
Message-Id: <>


At which point you're not in the heades any more because your 'email'
forced you out of them with a blank line.

How 'clean' are the emails in your database?... :-)

If they've come from a web signup form, and you weren't validating the
input, then I guarantee you've got spammers trying to use your form to
send out junk by forcing newlines and the headers THEY want into your
'email' field...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



RE: [PHP] RE: header data being inserted into message

2006-01-18 Thread ET Support
That did not work, however what does seem to work is changing all my \r\n to
just \n ... which I found after going over the php docs again at
http://www.php.net/manual/en/function.mail.php ... "Note:  If messages are
not received, try using a LF (\n) only. Some poor quality Unix mail transfer
agents replace LF by CRLF automatically (which leads to doubling CR if CRLF
is used). This should be a last resort, as it does not comply with RFC
2822."

... we're using FreeBSD 4.11-STABLE so that must be in the category of one
of the "poor quality Unix mail transfer agents"

Thanks for the input!


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 18, 2006 11:29 AM
To: ET Support
Subject: RE: [PHP] RE: header data being inserted into message


what you're showing indicates that an MTA is getting confused about
the structure of the message and putting the message-id into the
body, rather than header.

you need to have a cr/lf (null line) between the header and the body,
otherwise the/an MTA can get things mixed up. so, when you exit your
bcc loop write out (another) "\n".


 Original Message 
> Date: Wednesday, January 18, 2006 10:52:10 AM -0400
> From: ET Support <[EMAIL PROTECTED]>
> To: Richard Correia <[EMAIL PROTECTED]>
> Cc: php-general@lists.php.net
> Subject: RE: [PHP] RE: header data being inserted into message
>
> Hi Richard,
>
> Thanks for the response, however I do not want to have to use any
> special classes or other software... I want to get it working just
> using the basic php functions, which should be possible as far as I
> understand the php documentation... if I keep finding that I can't
> get it working then maybe I'll go to majordomo2.
>
> Anyone else have some advice for me here?
>
> Thanks,
> Ben
>
> -Original Message-
> From: Richard Correia [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, January 17, 2006 12:37 PM
> To: ET Support
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] RE: header data being inserted into message
>
>
> Hey,
>
> You can use the readymase mailer class from
> http://www.weberdev.com/get_example-462.html
>
> and
>
> http://www.weberdev.com/get_example-3724.html
>
> Thanks
> Richard
>
>
> On 1/17/06, ET Support <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I am having a problem using PHP's mail function to send mail via
> BCC to multiple recipients. Here's my code;
> --
> $get_emails = pg_exec($dbh,"SELECT email FROM mailing_list WHERE
> conf = 1"); $count = pg_numrows($get_emails);
> $bcc_count = $envelope_count = 0;
> $bcc_limit = 200;
> $subject = $body = 'test message';
> $from = '[EMAIL PROTECTED]';
> $header = "From: $from\r\n";
> for($x = 0; $x < $count; $x++) {
>$email = pg_result($get_emails,$x,0);
>if($bcc_count >= $bcc_limit) {
>if($x > 0) {
>$envelope_count++;
>mail($from,$subject,$body,$headers);
>}
>$headers = $header . "Bcc: $email\r\n";
>$bcc_count = 1;
>} else {
>$headers .= "Bcc: $email\r\n";
>$bcc_count++;
>}
> }
># send the last envelope
> mail($from,$subject,$body,$headers);
> --
>
> The problem is that for some recipients they get a message body
> like this;
>
> --
> Message-Id: < [EMAIL PROTECTED]>
> Date: Mon, 16 Jan 2006 17:06:40 + (GMT)
>
> test message
> --
>
> Any idea why those headers are being inserted into the message body
> and how that can be prevented?
>
> Thanks,
> Ben King
> [EMAIL PROTECTED]
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- End Original Message --

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



RE: [PHP] RE: header data being inserted into message

2006-01-18 Thread ET Support
Hi Richard,

Thanks for the response, however I do not want to have to use any special
classes or other software... I want to get it working just using the basic
php functions, which should be possible as far as I understand the php
documentation... if I keep finding that I can't get it working then maybe
I'll go to majordomo2.

Anyone else have some advice for me here?

Thanks,
Ben

-Original Message-
From: Richard Correia [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 17, 2006 12:37 PM
To: ET Support
Cc: php-general@lists.php.net
Subject: Re: [PHP] RE: header data being inserted into message


Hey,

You can use the readymase mailer class from
http://www.weberdev.com/get_example-462.html

and

http://www.weberdev.com/get_example-3724.html

Thanks
Richard


On 1/17/06, ET Support <[EMAIL PROTECTED]> wrote:
Hello all,

I am having a problem using PHP's mail function to send mail via BCC to
multiple recipients. Here's my code;
--
$get_emails = pg_exec($dbh,"SELECT email FROM mailing_list WHERE conf = 1");
$count = pg_numrows($get_emails);
$bcc_count = $envelope_count = 0;
$bcc_limit = 200;
$subject = $body = 'test message';
$from = '[EMAIL PROTECTED]';
$header = "From: $from\r\n";
for($x = 0; $x < $count; $x++) {
   $email = pg_result($get_emails,$x,0);
   if($bcc_count >= $bcc_limit) {
   if($x > 0) {
   $envelope_count++;
   mail($from,$subject,$body,$headers);
   }
   $headers = $header . "Bcc: $email\r\n";
   $bcc_count = 1;
   } else {
   $headers .= "Bcc: $email\r\n";
   $bcc_count++;
   }
}
# send the last envelope
mail($from,$subject,$body,$headers);
--

The problem is that for some recipients they get a message body like this;

--
Message-Id: < [EMAIL PROTECTED]>
Date: Mon, 16 Jan 2006 17:06:40 + (GMT)

test message
--

Any idea why those headers are being inserted into the message body and how
that can be prevented?

Thanks,
Ben King
[EMAIL PROTECTED]

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

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



Re: [PHP] RE: header data being inserted into message

2006-01-17 Thread Richard Correia
Hey,

You can use the readymase mailer class from
http://www.weberdev.com/get_example-462.html

and

http://www.weberdev.com/get_example-3724.html

Thanks
Richard


On 1/17/06, ET Support <[EMAIL PROTECTED]> wrote:
>
> Hello all,
>
> I am having a problem using PHP's mail function to send mail via BCC to
> multiple recipients. Here's my code;
> --
> $get_emails = pg_exec($dbh,"SELECT email FROM mailing_list WHERE conf =
> 1");
> $count = pg_numrows($get_emails);
> $bcc_count = $envelope_count = 0;
> $bcc_limit = 200;
> $subject = $body = 'test message';
> $from = '[EMAIL PROTECTED]';
> $header = "From: $from\r\n";
> for($x = 0; $x < $count; $x++) {
>$email = pg_result($get_emails,$x,0);
>if($bcc_count >= $bcc_limit) {
>if($x > 0) {
>$envelope_count++;
>mail($from,$subject,$body,$headers);
>}
>$headers = $header . "Bcc: $email\r\n";
>$bcc_count = 1;
>} else {
>$headers .= "Bcc: $email\r\n";
>$bcc_count++;
>}
> }
> # send the last envelope
> mail($from,$subject,$body,$headers);
> --
>
> The problem is that for some recipients they get a message body like this;
>
> --
> Message-Id: <[EMAIL PROTECTED]>
> Date: Mon, 16 Jan 2006 17:06:40 + (GMT)
>
> test message
> --
>
> Any idea why those headers are being inserted into the message body and
> how
> that can be prevented?
>
> Thanks,
> Ben King
> [EMAIL PROTECTED]
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] RE: header data being inserted into message

2006-01-17 Thread ET Support
Hello all,

I am having a problem using PHP's mail function to send mail via BCC to
multiple recipients. Here's my code;
--
$get_emails = pg_exec($dbh,"SELECT email FROM mailing_list WHERE conf = 1");
$count = pg_numrows($get_emails);
$bcc_count = $envelope_count = 0;
$bcc_limit = 200;
$subject = $body = 'test message';
$from = '[EMAIL PROTECTED]';
$header = "From: $from\r\n";
for($x = 0; $x < $count; $x++) {
$email = pg_result($get_emails,$x,0);
if($bcc_count >= $bcc_limit) {
if($x > 0) {
$envelope_count++;
mail($from,$subject,$body,$headers);
}
$headers = $header . "Bcc: $email\r\n";
$bcc_count = 1;
} else {
$headers .= "Bcc: $email\r\n";
$bcc_count++;
}
}
# send the last envelope
mail($from,$subject,$body,$headers);
--

The problem is that for some recipients they get a message body like this;

--
Message-Id: <[EMAIL PROTECTED]>
Date: Mon, 16 Jan 2006 17:06:40 + (GMT)

test message
--

Any idea why those headers are being inserted into the message body and how
that can be prevented?

Thanks,
Ben King
[EMAIL PROTECTED]

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