[PHP] mail() silly question

2007-09-01 Thread Rodrigo Poblanno Balp
I have a question that might be too silly for those of you who are PHP 
gurus.


Here it comes:

I had a mail (specifically in the headers) function call like this:

$header = ;
$header .= 'From: [EMAIL PROTECTED];
$header .= 'MIME-Version: 1.0\r\n;
$header .= 'Content-type: text/html; charset=iso-8859-1\r\n;
$header .= Reply-To: .utf8_decode($nombreVar). 
.utf8_decode($apellidosVar).$mailVar\r\n;

$header .= X-Mailer: PHP/.phpversion().\r\n;
$header .= X-Priority: 1;

and the mail(...) function always returned TRUE, but the mail was NOT sent.

After hours of... trial/error debugging, I noticed from an example that 
it should be:


$header = ;
$header .= 'From: [EMAIL PROTECTED]' . \r\n;
$header .= 'MIME-Version: 1.0' . \r\n;
$header .= 'Content-type: text/html; charset=iso-8859-1' . \r\n;
$header .= Reply-To: .utf8_decode($nombreVar). 
.utf8_decode($apellidosVar).$mailVar\r\n;

$header .= X-Mailer: PHP/.phpversion().\r\n;
$header .= X-Priority: 1;

Question:

Why? What's the real difference between
   $header .= 'From: [EMAIL PROTECTED]' . \r\n;
and
   $header .= 'From: [EMAIL PROTECTED];

?
If somebody knows, please let me know!

Thank you in advance.

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



Re: [PHP] mail() silly question

2007-09-01 Thread Ludovic André

Hi,

Question:

Why? What's the real difference between
   $header .= 'From: [EMAIL PROTECTED]' . \r\n;
and
   $header .= 'From: [EMAIL PROTECTED];

Your second declaration is incorrect: you start with a single quote ('), 
and you end with a double ().


So, you'd say ok, let's fix it:
$header .= 'From: [EMAIL PROTECTED]';

BUT, special chars like \n or \r need to be inside a double-quoted 
string in order to be taken into account.


This one is then correct:
$header .= 'From: [EMAIL PROTECTED]' . \r\n;

This one as well:
$header .= From: [EMAIL PROTECTED];


Ludovic André

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



Re: [PHP] mail() silly question

2007-09-01 Thread chris smith
On 9/1/07, Rodrigo Poblanno Balp [EMAIL PROTECTED] wrote:
 I have a question that might be too silly for those of you who are PHP
 gurus.

 Here it comes:

 I had a mail (specifically in the headers) function call like this:

 $header = ;
 $header .= 'From: [EMAIL PROTECTED];
 $header .= 'MIME-Version: 1.0\r\n;
 $header .= 'Content-type: text/html; charset=iso-8859-1\r\n;
 $header .= Reply-To: .utf8_decode($nombreVar).
 .utf8_decode($apellidosVar).$mailVar\r\n;
 $header .= X-Mailer: PHP/.phpversion().\r\n;
 $header .= X-Priority: 1;

 and the mail(...) function always returned TRUE, but the mail was NOT sent.

 After hours of... trial/error debugging, I noticed from an example that
 it should be:

 $header = ;
 $header .= 'From: [EMAIL PROTECTED]' . \r\n;
 $header .= 'MIME-Version: 1.0' . \r\n;
 $header .= 'Content-type: text/html; charset=iso-8859-1' . \r\n;
 $header .= Reply-To: .utf8_decode($nombreVar).
 .utf8_decode($apellidosVar).$mailVar\r\n;
 $header .= X-Mailer: PHP/.phpversion().\r\n;
 $header .= X-Priority: 1;

 Question:

 Why? What's the real difference between
 $header .= 'From: [EMAIL PROTECTED]' . \r\n;
 and
 $header .= 'From: [EMAIL PROTECTED];

Actually that's a parse error ;) You have a single quote at the start
and double at the end.

Anyway, the reason is interpolation. See
http://www.php.net/manual/en/language.types.string.php

Under Single quoted:

.. escape sequences for special characters will not be expanded when
they occur in single quoted strings.

So you end up with a literal '\r\n' at the end of the line, not an
actual carriage return  newline that you expect.

-- 
Postgresql  php tutorials
http://www.designmagick.com/

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



RE: [PHP] mail() silly question

2007-09-01 Thread Bastien Koert

no difference

bastien







 Date: Sat, 1 Sep 2007 08:00:11 -0500 
From: [EMAIL PROTECTED] To: php-general@lists.php.net Subject: [PHP] mail() 
silly question I have a question that might be too silly for those of you who 
are PHP gurus. Here it comes: I had a mail (specifically in the headers) 
function call like this: $header = ; $header .= 'From: [EMAIL 
PROTECTED]; $header .= 'MIME-Version: 1.0\r\n; $header .= 'Content-type: 
text/html; charset=iso-8859-1\r\n; $header .= Reply-To: 
.utf8_decode($nombreVar). .utf8_decode($apellidosVar).\r\n; $header .= 
X-Mailer: PHP/.phpversion().\r\n; $header .= X-Priority: 1; and the 
mail(...) function always returned TRUE, but the mail was NOT sent. After 
hours of... trial/error debugging, I noticed from an example that it should 
be: $header = ; $header .= 'From: [EMAIL PROTECTED]' . \r\n; $header .= 
'MIME-Version: 1.0' . \r\n; $header .= 'Content-type: text/html; 
charset=iso-8859-1' . \r\n; $header .= Reply-To: 
.utf8_decode($nombreVar). .utf8_decode($apellidosVar).\r\n; $header .= 
X-Mailer: PHP/.phpversion().\r\n; $header .= X-Priority: 1; 
Question: Why? What's the real difference between $header .= 'From: [EMAIL 
PROTECTED]' . \r\n; and $header .= 'From: [EMAIL PROTECTED]; ? If 
somebody knows, please let me know! Thank you in advance. -- PHP General 
Mailing List (http://www.php.net/) To unsubscribe, visit: 
http://www.php.net/unsub.php

_
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vistamkt=en-USform=QBRE
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] mail() silly question

2007-09-01 Thread Brian Seymour
As a general rule, use ' ' for literal strings and   for strings you want
escaped characters and such to take effect. Example:

echo 'foo\nbar' will echo foo\nbar
where as
echo foo\nbar will echo
foo
bar

Hope this helped.

Brian Seymour
Zend Certified Engineer
AeroCoreProductions
http://www.aerocore.net/
Cell: (413) 335-2656

-Original Message-
From: Rodrigo Poblanno Balp [mailto:[EMAIL PROTECTED] 
Sent: Saturday, September 01, 2007 9:00 AM
To: php-general@lists.php.net
Subject: [PHP] mail() silly question

I have a question that might be too silly for those of you who are PHP
gurus.

Here it comes:

I had a mail (specifically in the headers) function call like this:

$header = ;
$header .= 'From: [EMAIL PROTECTED]; $header .= 'MIME-Version:
1.0\r\n; $header .= 'Content-type: text/html; charset=iso-8859-1\r\n;
$header .= Reply-To: .utf8_decode($nombreVar). 
.utf8_decode($apellidosVar).$mailVar\r\n;
$header .= X-Mailer: PHP/.phpversion().\r\n; $header .= X-Priority: 1;

and the mail(...) function always returned TRUE, but the mail was NOT sent.

After hours of... trial/error debugging, I noticed from an example that it
should be:

$header = ;
$header .= 'From: [EMAIL PROTECTED]' . \r\n; $header .=
'MIME-Version: 1.0' . \r\n; $header .= 'Content-type: text/html;
charset=iso-8859-1' . \r\n; $header .= Reply-To:
.utf8_decode($nombreVar). 
.utf8_decode($apellidosVar).$mailVar\r\n;
$header .= X-Mailer: PHP/.phpversion().\r\n; $header .= X-Priority: 1;

Question:

Why? What's the real difference between
$header .= 'From: [EMAIL PROTECTED]' . \r\n; and
$header .= 'From: [EMAIL PROTECTED];

?
If somebody knows, please let me know!

Thank you in advance.

--
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