FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Trouble with sending e-mail from simple php script
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Trouble with sending e-mail from simple php script [message #176458] Sat, 07 January 2012 19:01 Go to next message
C is currently offline  C
Messages: 24
Registered: January 2012
Karma: 0
Junior Member
I have a simple form which is handled in a *.htm file by

<FORM METHOD="POST" ACTION="send_msg.php">
<PRE>
Your name <INPUT TYPE="text" NAME="name" MAXLENGTH=35 SIZE=50>
Company <INPUT TYPE="text" NAME="orgn" MAXLENGTH=60 SIZE=50>
City and country <INPUT TYPE="text" NAME="locn"
MAXLENGTH=60 SIZE=50>
Your e-mail address <INPUT TYPE="text" NAME="emad" MAXLENGTH=60
SIZE=50>
Your message <TEXTAREA NAME="question" WRAP=VIRTUAL
ROWS=5 COLS=45></TEXTAREA>
<INPUT TYPE="submit" VALUE="Send message">
</PRE>
</FORM>

Then the send_msg.php should send the e-mail by the following code
(but does not send e-mail). What am I doing wrong?

<?php
$date = date("F jS Y, h:iA");
if ($name == "" && $question == "") {exit;}
$host=@gethostbyaddr($REMOTE_ADDR);
$headers = "From: postmaster(at)domainname1(dot)org \r\n";
$headers .= "X-Mailer: PHP \r\n";
if(mail("myusernamehere(at)gmail(dot)com", "Comments from someone.",
"$host on the contacts page at $date \n
--- \n
$name from $orgn, $locn ($emad) wrote:\n\n
$question", $headers)) { $msg = "Thank you"; } else { $msg = "Message
not sent"; }
echo $msg;
?>

<html>
<head>
<title>Test form to email</title>
</head>

<body>
<?php echo $msg ?>


</body>
</html>

<?php
echo "<HTML>";
echo '<BODY bgcolor="#E0FFE0" text="#008000" leftmargin="30"
topmargin="20">';
echo '<FONT face="Arial" size=1> <B>';
echo $msg ;
echo "Thank you. Your message has been sent.";
echo "</B> </FONT> </HTML>";
?>

Thanks for all help/replies.

By the way, PHP.INI contained the following but suspecting this to be
a problem, I removed the file, and it still does not work.

register_globals = off
allow_url_fopen = off

expose_php = Off
max_input_time = 60
variables_order = "EGPCS"
extension_dir = ./
upload_tmp_dir = /tmp
precision = 12
SMTP = relay-hosting.secureserver.net
url_rewriter.tags =
"a=href,area=href,frame=src,input=src,form=,fieldset="

; Only uncomment zend optimizer lines if your application requires
Zend Optimizer support

;[Zend]
;zend_optimizer.optimization_level=15
;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/
Optimizer_TS-3.3.3
;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/
ZendExtensionManager.so
;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/
ZendExtensionManager_TS.so


; -- Be very careful to not to disable a function which might be
needed!
; -- Uncomment the following lines to increase the security of your
PHP site.

;disable_functions =
"highlight_file,ini_alter,ini_restore,openlog,passthru,
; phpinfo, exec, system, dl, fsockopen, set_time_limit,
; popen, proc_open,
proc_nice,shell_exec,show_source,symlink"
Re: Trouble with sending e-mail from simple php script [message #176460 is a reply to message #176458] Sat, 07 January 2012 19:42 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 07-01-2012 20:01, C wrote:
> (but does not send e-mail). What am I doing wrong?

you forgot to say which errors are in your logfiles.... ;)

--
Luuk
Re: Trouble with sending e-mail from simple php script [message #176466 is a reply to message #176458] Sat, 07 January 2012 21:06 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 1/7/2012 2:01 PM, C wrote:
> I have a simple form which is handled in a *.htm file by
>
> <FORM METHOD="POST" ACTION="send_msg.php">
> <PRE>
> Your name<INPUT TYPE="text" NAME="name" MAXLENGTH=35 SIZE=50>
> Company<INPUT TYPE="text" NAME="orgn" MAXLENGTH=60 SIZE=50>
> City and country<INPUT TYPE="text" NAME="locn"
> MAXLENGTH=60 SIZE=50>
> Your e-mail address<INPUT TYPE="text" NAME="emad" MAXLENGTH=60
> SIZE=50>
> Your message<TEXTAREA NAME="question" WRAP=VIRTUAL
> ROWS=5 COLS=45></TEXTAREA>
> <INPUT TYPE="submit" VALUE="Send message">
> </PRE>
> </FORM>
>
> Then the send_msg.php should send the e-mail by the following code
> (but does not send e-mail). What am I doing wrong?
>
> <?php
> $date = date("F jS Y, h:iA");
> if ($name == ""&& $question == "") {exit;}
> $host=@gethostbyaddr($REMOTE_ADDR);
> $headers = "From: postmaster(at)domainname1(dot)org \r\n";
> $headers .= "X-Mailer: PHP \r\n";
> if(mail("myusernamehere(at)gmail(dot)com", "Comments from someone.",
> "$host on the contacts page at $date \n
> --- \n
> $name from $orgn, $locn ($emad) wrote:\n\n
> $question", $headers)) { $msg = "Thank you"; } else { $msg = "Message
> not sent"; }
> echo $msg;
> ?>
>
> <html>
> <head>
> <title>Test form to email</title>
> </head>
>
> <body>
> <?php echo $msg ?>
>
>
> </body>
> </html>
>
> <?php
> echo "<HTML>";
> echo '<BODY bgcolor="#E0FFE0" text="#008000" leftmargin="30"
> topmargin="20">';
> echo '<FONT face="Arial" size=1> <B>';
> echo $msg ;
> echo "Thank you. Your message has been sent.";
> echo "</B> </FONT> </HTML>";
> ?>
>
> Thanks for all help/replies.
>
> By the way, PHP.INI contained the following but suspecting this to be
> a problem, I removed the file, and it still does not work.
>
> register_globals = off
> allow_url_fopen = off
>
> expose_php = Off
> max_input_time = 60
> variables_order = "EGPCS"
> extension_dir = ./
> upload_tmp_dir = /tmp
> precision = 12
> SMTP = relay-hosting.secureserver.net
> url_rewriter.tags =
> "a=href,area=href,frame=src,input=src,form=,fieldset="
>
> ; Only uncomment zend optimizer lines if your application requires
> Zend Optimizer support
>
> ;[Zend]
> ;zend_optimizer.optimization_level=15
> ;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
> ;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/
> Optimizer_TS-3.3.3
> ;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/
> ZendExtensionManager.so
> ;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/
> ZendExtensionManager_TS.so
>
>
> ; -- Be very careful to not to disable a function which might be
> needed!
> ; -- Uncomment the following lines to increase the security of your
> PHP site.
>
> ;disable_functions =
> "highlight_file,ini_alter,ini_restore,openlog,passthru,
> ; phpinfo, exec, system, dl, fsockopen, set_time_limit,
> ; popen, proc_open,
> proc_nice,shell_exec,show_source,symlink"

In addition to what LUUK said - there can be a lot of problems -
anywhere from your SMTP server rejecting the message for any of a number
of reasons to the client machine rejecting the message.

P.S. unless you are E. Mousa from time Advertising Agency, you should
not be using his domain name in your code. You should instead use
example.com, example.org, etc., which are specifically reserved for such
uses.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Trouble with sending e-mail from simple php script [message #176471 is a reply to message #176460] Sun, 08 January 2012 09:17 Go to previous messageGo to next message
C is currently offline  C
Messages: 24
Registered: January 2012
Karma: 0
Junior Member
On Jan 7, 9:42 pm, Luuk <L...@invalid.lan> wrote:
> On 07-01-2012 20:01, C wrote:
>
>> (but does not send e-mail). What am I doing wrong?
>
> you forgot to say which errors are in your logfiles.... ;)
>
> --
> Luuk

Where do I find the logfiles? There seems to be a logs directory which
I cannot read from, and anyway seems to be empty.

When I click send, I get only a blank frame with nothing in it. No
errors or complaints either.
Re: Trouble with sending e-mail from simple php script [message #176473 is a reply to message #176466] Sun, 08 January 2012 09:20 Go to previous messageGo to next message
C is currently offline  C
Messages: 24
Registered: January 2012
Karma: 0
Junior Member
On Jan 7, 11:06 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 1/7/2012 2:01 PM, C wrote:
>
>
>
>
>
>> I have a simple form which is handled in a *.htm file by
>
>> <FORM METHOD="POST" ACTION="send_msg.php">
>> <PRE>
>>      Your name<INPUT TYPE="text" NAME="name" MAXLENGTH=35 SIZE=50>
>>      Company<INPUT TYPE="text" NAME="orgn"  MAXLENGTH=60 SIZE=50>
>>      City and country<INPUT TYPE="text" NAME="locn"
>> MAXLENGTH=60 SIZE=50>
>>      Your e-mail address<INPUT TYPE="text" NAME="emad"  MAXLENGTH=60
>> SIZE=50>
>>      Your message<TEXTAREA NAME="question" WRAP=VIRTUAL
>> ROWS=5 COLS=45></TEXTAREA>
>>                            <INPUT TYPE="submit" VALUE="Send message">
>> </PRE>
>> </FORM>
>
>> Then the send_msg.php should send the e-mail by the following code
>> (but does not send e-mail). What am I doing wrong?
>
>> <?php
>> $date = date("F jS Y, h:iA");
>> if ($name == ""&&  $question == "") {exit;}
>> $host=@gethostbyaddr($REMOTE_ADDR);
>> $headers = "From: postmas...@domainname1.org \r\n";
>> $headers .= "X-Mailer: PHP \r\n";
>> if(mail("myusernameh...@gmail.com", "Comments from someone.",
>> "$host on the contacts page at $date \n
>> --- \n
>> $name from $orgn, $locn ($emad) wrote:\n\n
>> $question", $headers)) { $msg = "Thank you"; } else { $msg = "Message
>> not sent"; }
>> echo $msg;
>> ?>
>
>> <html>
>> <head>
>>    <title>Test form to email</title>
>> </head>
>
>> <body>
>> <?php echo $msg ?>
>
>> </body>
>> </html>
>
>> <?php
>> echo "<HTML>";
>> echo '<BODY bgcolor="#E0FFE0" text="#008000" leftmargin="30"
>> topmargin="20">';
>> echo '<FONT face="Arial" size=1>  <B>';
>> echo $msg ;
>> echo "Thank you. Your message has been sent.";
>> echo "</B>  </FONT>  </HTML>";
>> ?>
>
>> Thanks for all help/replies.
>
>> By the way, PHP.INI contained the following but suspecting this to be
>> a problem, I removed the file, and it still does not work.
>
>> register_globals = off
>> allow_url_fopen = off
>
>> expose_php = Off
>> max_input_time = 60
>> variables_order = "EGPCS"
>> extension_dir = ./
>> upload_tmp_dir = /tmp
>> precision = 12
>> SMTP = relay-hosting.secureserver.net
>> url_rewriter.tags =
>> "a=href,area=href,frame=src,input=src,form=,fieldset="
>
>> ; Only uncomment zend optimizer lines if your application requires
>> Zend Optimizer support
>
>> ;[Zend]
>> ;zend_optimizer.optimization_level=15
>> ;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
>> ;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/
>> Optimizer_TS-3.3.3
>> ;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/
>> ZendExtensionManager.so
>> ;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/
>> ZendExtensionManager_TS.so
>
>> ; -- Be very careful to not to disable a function which might be
>> needed!
>> ; -- Uncomment the following lines to increase the security of your
>> PHP site.
>
>> ;disable_functions =
>> "highlight_file,ini_alter,ini_restore,openlog,passthru,
>> ;                phpinfo, exec, system, dl, fsockopen, set_time_limit,
>> ;                     popen, proc_open,
>> proc_nice,shell_exec,show_source,symlink"
>
> In addition to what LUUK said - there can be a lot of problems -
> anywhere from your SMTP server rejecting the message for any of a number
> of reasons to the client machine rejecting the message.

Even if the message were rejected, I would still see something in that
frame, but I get only a blank frame. Client machine rejecting the
message should not even be noticed by this PHP script, or would it?

>
> P.S. unless you are E. Mousa from time Advertising Agency, you should
> not be using his domain name in your code.

Which domain name does he have? I can of course use example.***.

You should instead use
> example.com, example.org, etc., which are specifically reserved for such
> uses.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================- Hide quoted text -
>
> - Show quoted text -
Re: Trouble with sending e-mail from simple php script [message #176481 is a reply to message #176473] Sun, 08 January 2012 14:09 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 1/8/2012 4:20 AM, C wrote:
> On Jan 7, 11:06 pm, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>> On 1/7/2012 2:01 PM, C wrote:
>>
>>
>>
>>
>>
>>> I have a simple form which is handled in a *.htm file by
>>
>>> <FORM METHOD="POST" ACTION="send_msg.php">
>>> <PRE>
>>> Your name<INPUT TYPE="text" NAME="name" MAXLENGTH=35 SIZE=50>
>>> Company<INPUT TYPE="text" NAME="orgn" MAXLENGTH=60 SIZE=50>
>>> City and country<INPUT TYPE="text" NAME="locn"
>>> MAXLENGTH=60 SIZE=50>
>>> Your e-mail address<INPUT TYPE="text" NAME="emad" MAXLENGTH=60
>>> SIZE=50>
>>> Your message<TEXTAREA NAME="question" WRAP=VIRTUAL
>>> ROWS=5 COLS=45></TEXTAREA>
>>> <INPUT TYPE="submit" VALUE="Send message">
>>> </PRE>
>>> </FORM>
>>
>>> Then the send_msg.php should send the e-mail by the following code
>>> (but does not send e-mail). What am I doing wrong?
>>
>>> <?php
>>> $date = date("F jS Y, h:iA");
>>> if ($name == ""&& $question == "") {exit;}
>>> $host=@gethostbyaddr($REMOTE_ADDR);
>>> $headers = "From: postmas...@domainname1.org \r\n";
>>> $headers .= "X-Mailer: PHP \r\n";
>>> if(mail("myusernameh...@gmail.com", "Comments from someone.",
>>> "$host on the contacts page at $date \n
>>> --- \n
>>> $name from $orgn, $locn ($emad) wrote:\n\n
>>> $question", $headers)) { $msg = "Thank you"; } else { $msg = "Message
>>> not sent"; }
>>> echo $msg;
>>> ?>
>>
>>> <html>
>>> <head>
>>> <title>Test form to email</title>
>>> </head>
>>
>>> <body>
>>> <?php echo $msg ?>
>>
>>> </body>
>>> </html>
>>
>>> <?php
>>> echo "<HTML>";
>>> echo '<BODY bgcolor="#E0FFE0" text="#008000" leftmargin="30"
>>> topmargin="20">';
>>> echo '<FONT face="Arial" size=1> <B>';
>>> echo $msg ;
>>> echo "Thank you. Your message has been sent.";
>>> echo "</B> </FONT> </HTML>";
>>> ?>
>>
>>> Thanks for all help/replies.
>>
>>> By the way, PHP.INI contained the following but suspecting this to be
>>> a problem, I removed the file, and it still does not work.
>>
>>> register_globals = off
>>> allow_url_fopen = off
>>
>>> expose_php = Off
>>> max_input_time = 60
>>> variables_order = "EGPCS"
>>> extension_dir = ./
>>> upload_tmp_dir = /tmp
>>> precision = 12
>>> SMTP = relay-hosting.secureserver.net
>>> url_rewriter.tags =
>>> "a=href,area=href,frame=src,input=src,form=,fieldset="
>>
>>> ; Only uncomment zend optimizer lines if your application requires
>>> Zend Optimizer support
>>
>>> ;[Zend]
>>> ;zend_optimizer.optimization_level=15
>>> ;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
>>> ;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/
>>> Optimizer_TS-3.3.3
>>> ;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/
>>> ZendExtensionManager.so
>>> ;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/
>>> ZendExtensionManager_TS.so
>>
>>> ; -- Be very careful to not to disable a function which might be
>>> needed!
>>> ; -- Uncomment the following lines to increase the security of your
>>> PHP site.
>>
>>> ;disable_functions =
>>> "highlight_file,ini_alter,ini_restore,openlog,passthru,
>>> ; phpinfo, exec, system, dl, fsockopen, set_time_limit,
>>> ; popen, proc_open,
>>> proc_nice,shell_exec,show_source,symlink"
>>
>> In addition to what LUUK said - there can be a lot of problems -
>> anywhere from your SMTP server rejecting the message for any of a number
>> of reasons to the client machine rejecting the message.
>
> Even if the message were rejected, I would still see something in that
> frame, but I get only a blank frame. Client machine rejecting the
> message should not even be noticed by this PHP script, or would it?
>

No, but then neither will the SMTP server rejecting the message.

You have other problems also, like trying to echo $msg before the
<html>, etc. are sent. But that isn't causing the message to not be
received.

Of course, getting a blank frame is a completely different problem than
you first reported, and usually means a fatal error in your PHP script.
That needs to be found and fixed first.

>>
>> P.S. unless you are E. Mousa from time Advertising Agency, you should
>> not be using his domain name in your code.
>
> Which domain name does he have? I can of course use example.***.
>

The domain you used in your example.

> You should instead use
>> example.com, example.org, etc., which are specifically reserved for such
>> uses.
>>


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Trouble with sending e-mail from simple php script [message #176483 is a reply to message #176473] Sun, 08 January 2012 14:12 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 08.01.2012 10:20, schrieb C:
>
> Even if the message were rejected, I would still see something in that
> frame, but I get only a blank frame. Client machine rejecting the
> message should not even be noticed by this PHP script, or would it?
>
You have to learn how to find and read the log files. Your script
will not show errors if it dies.

On Linux log files are only readable by root.

/Str.
Re: Trouble with sending e-mail from simple php script [message #176485 is a reply to message #176483] Sun, 08 January 2012 14:34 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
M. Strobel wrote:
> Am 08.01.2012 10:20, schrieb C:
>> Even if the message were rejected, I would still see something in that
>> frame, but I get only a blank frame. Client machine rejecting the
>> message should not even be noticed by this PHP script, or would it?
>>
> You have to learn how to find and read the log files. Your script
> will not show errors if it dies.
>
> On Linux log files are only readable by root.
>
> /Str.
Probably the most common error when using mail() from within php on a
shared host is to fail to use the -f function to pass a valid sender
address to sendmail (or its analogue). Without that, the 'true' sender
is likely to be 'your-login-name(at)hosting-omain(dot)com' which will fail most
rudimentary validation and simply reject the mail.

I ALWAYS use the -f to set the sender to something like
'webmaster(at)myvirtualdomson(dot)com' and set up that virtual domain so that
webmaster is a valid known target for emails.

e.g.

mail($to, $subject, $body, $headers, "-f webmaster(at)mydomain(dot)com");

is far more likely to get through anti-relay security in the hosts
mailer system.

Start by testing the host mailer with the above line, so

mail("me(at)validmail(dot)com","test message", "From:
another(at)validmail(dot)com\r\n", -f "webmaster(at)mydomain(dot)com");

is where you should start.

If that fails to make it then you need to talk to the hosting company.
Re: Trouble with sending e-mail from simple php script [message #176487 is a reply to message #176483] Sun, 08 January 2012 15:02 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 1/8/2012 9:12 AM, M. Strobel wrote:
> Am 08.01.2012 10:20, schrieb C:
>>
>> Even if the message were rejected, I would still see something in that
>> frame, but I get only a blank frame. Client machine rejecting the
>> message should not even be noticed by this PHP script, or would it?
>>
> You have to learn how to find and read the log files. Your script
> will not show errors if it dies.
>
> On Linux log files are only readable by root.
>
> /Str.

Log files are not always available, and PHP errors are often not written
to logs (depending on the configuration - the default is to NOT write them).

Also, if the log files exist, they may easily be set up to be read by
others than root.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Trouble with sending e-mail from simple php script [message #176488 is a reply to message #176458] Sun, 08 January 2012 15:29 Go to previous messageGo to next message
Jeff North is currently offline  Jeff North
Messages: 58
Registered: November 2010
Karma: 0
Member
On Sat, 7 Jan 2012 11:01:51 -0800 (PST), in comp.lang.php C
<wrong(dot)address(dot)1(at)gmail(dot)com>
<19e29d83-3207-45e8-b63e-f476e7f900cc(at)u32g2000yqe(dot)googlegroups(dot)com>
wrote:

> | I have a simple form which is handled in a *.htm file by
> |
> | <FORM METHOD="POST" ACTION="send_msg.php">
> | <PRE>
> | Your name <INPUT TYPE="text" NAME="name" MAXLENGTH=35 SIZE=50>
> | Company <INPUT TYPE="text" NAME="orgn" MAXLENGTH=60 SIZE=50>
> | City and country <INPUT TYPE="text" NAME="locn"
> | MAXLENGTH=60 SIZE=50>
> | Your e-mail address <INPUT TYPE="text" NAME="emad" MAXLENGTH=60
> | SIZE=50>
> | Your message <TEXTAREA NAME="question" WRAP=VIRTUAL
> | ROWS=5 COLS=45></TEXTAREA>
> | <INPUT TYPE="submit" VALUE="Send message">
> | </PRE>
> | </FORM>
> |
> | Then the send_msg.php should send the e-mail by the following code
> | (but does not send e-mail). What am I doing wrong?

Apart from the other posters - you are not getting, validating nor
sanitising the input data.

> | <?php
> | $date = date("F jS Y, h:iA");
$name = $_POST['name'];
$orgn = $_POST['orgn'] etc etc
//-- now validate and sanitise the data

// then - if all is well, send out the email
> | if ($name == "" && $question == "") {exit;}
> | $host=@gethostbyaddr($REMOTE_ADDR);
> | $headers = "From: postmaster(at)domainname1(dot)org \r\n";
> | $headers .= "X-Mailer: PHP \r\n";
> | if(mail("myusernamehere(at)gmail(dot)com", "Comments from someone.",
> | "$host on the contacts page at $date \n
> | --- \n
> | $name from $orgn, $locn ($emad) wrote:\n\n
> | $question", $headers)) { $msg = "Thank you"; } else { $msg = "Message
> | not sent"; }
> | echo $msg;
> | ?>
> |
> | <html>
> | <head>
> | <title>Test form to email</title>
> | </head>
> |
> | <body>
> | <?php echo $msg ?>
> |
> |
> | </body>
> | </html>
> |
> | <?php
> | echo "<HTML>";
> | echo '<BODY bgcolor="#E0FFE0" text="#008000" leftmargin="30"
> | topmargin="20">';
> | echo '<FONT face="Arial" size=1> <B>';
> | echo $msg ;
> | echo "Thank you. Your message has been sent.";
> | echo "</B> </FONT> </HTML>";
> | ?>
> |
> | Thanks for all help/replies.
> |
> | By the way, PHP.INI contained the following but suspecting this to be
> | a problem, I removed the file, and it still does not work.
> |
> | register_globals = off
> | allow_url_fopen = off
> |
> | expose_php = Off
> | max_input_time = 60
> | variables_order = "EGPCS"
> | extension_dir = ./
> | upload_tmp_dir = /tmp
> | precision = 12
> | SMTP = relay-hosting.secureserver.net
> | url_rewriter.tags =
> | "a=href,area=href,frame=src,input=src,form=,fieldset="
> |
> | ; Only uncomment zend optimizer lines if your application requires
> | Zend Optimizer support
> |
> | ;[Zend]
> | ;zend_optimizer.optimization_level=15
> | ;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
> | ;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/
> | Optimizer_TS-3.3.3
> | ;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/
> | ZendExtensionManager.so
> | ;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/
> | ZendExtensionManager_TS.so
> |
> |
> | ; -- Be very careful to not to disable a function which might be
> | needed!
> | ; -- Uncomment the following lines to increase the security of your
> | PHP site.
> |
> | ;disable_functions =
> | "highlight_file,ini_alter,ini_restore,openlog,passthru,
> | ; phpinfo, exec, system, dl, fsockopen, set_time_limit,
> | ; popen, proc_open,
> | proc_nice,shell_exec,show_source,symlink"
Re: Trouble with sending e-mail from simple php script [message #176489 is a reply to message #176487] Sun, 08 January 2012 15:33 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 08.01.2012 16:02, schrieb Jerry Stuckle:
> On 1/8/2012 9:12 AM, M. Strobel wrote:
>> Am 08.01.2012 10:20, schrieb C:
>>>
>>> Even if the message were rejected, I would still see something
>>> in that
>>> frame, but I get only a blank frame. Client machine rejecting the
>>> message should not even be noticed by this PHP script, or
>>> would it?
>>>
>> You have to learn how to find and read the log files. Your script
>> will not show errors if it dies.
>>
>> On Linux log files are only readable by root.
>>
>> /Str.
>
> Log files are not always available, and PHP errors are often not
> written to logs (depending on the configuration - the default is
> to NOT write them).
>
> Also, if the log files exist, they may easily be set up to be
> read by others than root.
>

Don't tell me, tell C.

And the standard on linux is that log files are only root
readable. I don't think it helps anybody if we start discussing
what could all be done with the log files.

Please do not start arguing with me on this level. I did Coherent
on a serial terminal at home before linux came up, and I was
working in an IBM computing center back then.

/Str.
Re: Trouble with sending e-mail from simple php script [message #176490 is a reply to message #176489] Sun, 08 January 2012 15:39 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 1/8/2012 10:33 AM, M. Strobel wrote:
> Am 08.01.2012 16:02, schrieb Jerry Stuckle:
>> On 1/8/2012 9:12 AM, M. Strobel wrote:
>>> Am 08.01.2012 10:20, schrieb C:
>>>>
>>>> Even if the message were rejected, I would still see something
>>>> in that
>>>> frame, but I get only a blank frame. Client machine rejecting the
>>>> message should not even be noticed by this PHP script, or
>>>> would it?
>>>>
>>> You have to learn how to find and read the log files. Your script
>>> will not show errors if it dies.
>>>
>>> On Linux log files are only readable by root.
>>>
>>> /Str.
>>
>> Log files are not always available, and PHP errors are often not
>> written to logs (depending on the configuration - the default is
>> to NOT write them).
>>
>> Also, if the log files exist, they may easily be set up to be
>> read by others than root.
>>
>
> Don't tell me, tell C.
>

No, you're the one who made the claims. I'm just correcting your
misinformation.

> And the standard on linux is that log files are only root
> readable. I don't think it helps anybody if we start discussing
> what could all be done with the log files.
>

They can easily be changed - it has nothing to do with whether you're
using standard linux or not.

> Please do not start arguing with me on this level. I did Coherent
> on a serial terminal at home before linux came up, and I was
> working in an IBM computing center back then.
>
> /Str.

Great. I was programming an IBM 1410 with punched cards in the 60's and
an IBM employee in the 70's - both long before Linux came up.

When your statements are incorrect, I will correct them.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Trouble with sending e-mail from simple php script [message #176492 is a reply to message #176490] Sun, 08 January 2012 16:01 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 08.01.2012 16:39, schrieb Jerry Stuckle:
> On 1/8/2012 10:33 AM, M. Strobel wrote:
>> Am 08.01.2012 16:02, schrieb Jerry Stuckle:
>>> On 1/8/2012 9:12 AM, M. Strobel wrote:
>>>> Am 08.01.2012 10:20, schrieb C:
>>>> >
>>>> > Even if the message were rejected, I would still see something
>>>> > in that
>>>> > frame, but I get only a blank frame. Client machine
>>>> > rejecting the
>>>> > message should not even be noticed by this PHP script, or
>>>> > would it?
>>>> >
>>>> You have to learn how to find and read the log files. Your
>>>> script
>>>> will not show errors if it dies.
>>>>
>>>> On Linux log files are only readable by root.
>>>>
>>>> /Str.
>>>
>>> Log files are not always available, and PHP errors are often not
>>> written to logs (depending on the configuration - the default is
>>> to NOT write them).
>>>
>>> Also, if the log files exist, they may easily be set up to be
>>> read by others than root.
>>>
>>
>> Don't tell me, tell C.
>>
>
> No, you're the one who made the claims. I'm just correcting your
> misinformation.
>
>> And the standard on linux is that log files are only root
>> readable. I don't think it helps anybody if we start discussing
>> what could all be done with the log files.
>>
>
> They can easily be changed - it has nothing to do with whether
> you're using standard linux or not.
>
>> Please do not start arguing with me on this level. I did Coherent
>> on a serial terminal at home before linux came up, and I was
>> working in an IBM computing center back then.
>>
>> /Str.
>
> Great. I was programming an IBM 1410 with punched cards in the
> 60's and an IBM employee in the 70's - both long before Linux
> came up.
>
> When your statements are incorrect, I will correct them.
>
I was glad the punched cards were gone when I came. The old
operator could sort them by hand.

There was nothing wrong with my statements. If he says "no log
file" (which is not true, he said "blank frame") or "0 bytes in
it" we know more, meanwhile it makes sense to suggest a standard
setup.

/Str.
Re: Trouble with sending e-mail from simple php script [message #176493 is a reply to message #176458] Sun, 08 January 2012 16:19 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 07.01.2012 20:01, schrieb C:
>
> By the way, PHP.INI contained the following but suspecting this to be
> a problem, I removed the file, and it still does not work.
>

You removed the file?

Put it back in its original state, and tell us the settings once
again.

During development all error messages should be turned on,
otherwise you don't see what fails.

/Str.
Re: Trouble with sending e-mail from simple php script [message #176498 is a reply to message #176471] Sun, 08 January 2012 18:09 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 08-01-2012 10:17, C wrote:
> On Jan 7, 9:42 pm, Luuk <L...@invalid.lan> wrote:
>> On 07-01-2012 20:01, C wrote:
>>
>>> (but does not send e-mail). What am I doing wrong?
>>
>> you forgot to say which errors are in your logfiles.... ;)
>>
>> --
>> Luuk
>
> Where do I find the logfiles? There seems to be a logs directory which
> I cannot read from, and anyway seems to be empty.
>
> When I click send, I get only a blank frame with nothing in it. No
> errors or complaints either.

http://lmgtfy.com/?q=php+how+to+create+log+file+site%3Aphp.net&l=1


--
Luuk
Re: Trouble with sending e-mail from simple php script [message #176501 is a reply to message #176485] Sun, 08 January 2012 18:51 Go to previous messageGo to next message
C is currently offline  C
Messages: 24
Registered: January 2012
Karma: 0
Junior Member
On Jan 8, 4:34 pm, The Natural Philosopher <t...@invalid.invalid>
wrote:
> M. Strobel wrote:
>> Am 08.01.2012 10:20, schrieb C:
>>> Even if the message were rejected, I would still see something in that
>>> frame, but I get only a blank frame. Client machine rejecting the
>>> message should not even be noticed by this PHP script, or would it?
>
>> You have to learn how to find and read the log files. Your script
>> will not show errors if it dies.
>
>> On Linux log files are only readable by root.
>
>> /Str.
>
> Probably the most common error when using mail() from within php on a
> shared host is to fail to use the -f function to pass a valid sender
> address to sendmail (or its analogue). Without that, the 'true' sender
> is likely to be 'your-login-n...@hosting-omain.com' which will fail most
> rudimentary validation and simply reject the mail.
>
> I ALWAYS use the -f to set the sender to something like
> 'webmas...@myvirtualdomson.com' and set up that virtual domain so that
> webmaster is a valid known target for emails.
>
> e.g.
>
> mail($to, $subject, $body, $headers, "-f webmas...@mydomain.com");
>
> is far more likely to get through anti-relay security in the hosts
> mailer system.
>
> Start by testing the host mailer with the above line, so
>
> mail("m...@validmail.com","test message", "From:
> anot...@validmail.com\r\n", -f "webmas...@mydomain.com");
>
> is where you should start.

I did that and got an error: Parse error: syntax error, unexpected
T_CONSTANT_ENCAPSED_STRING

>
> If that fails to make it then you need to talk to the hosting company.

I wrote the following test.php, uploaded it and tried it.

<?php

mail("aaaa....@gmail.com","test message", "From:
postmaster(at)example(dot)org\r\n", -f "postmaster(at)example(dot)org");

?>

My earlier code works well on two other sites of mine which are
sitting on other shared servers.
Re: Trouble with sending e-mail from simple php script [message #176503 is a reply to message #176488] Sun, 08 January 2012 18:57 Go to previous messageGo to next message
C is currently offline  C
Messages: 24
Registered: January 2012
Karma: 0
Junior Member
On Jan 8, 5:29 pm, Jeff North <jnort...@yahoo.com.au> wrote:
> On Sat, 7 Jan 2012 11:01:51 -0800 (PST), in comp.lang.php C
> <wrong.addres...@gmail.com>
> <19e29d83-3207-45e8-b63e-f476e7f90...@u32g2000yqe.googlegroups.com>
> wrote:
>
>
>
>
>
>> | I have a simple form which is handled in a *.htm file by
>> |
>> | <FORM METHOD="POST" ACTION="send_msg.php">
>> | <PRE>
>> |     Your name    <INPUT TYPE="text" NAME="name" MAXLENGTH=35 SIZE=50>
>> |     Company  <INPUT TYPE="text" NAME="orgn"  MAXLENGTH=60 SIZE=50>
>> |     City and country         <INPUT TYPE="text" NAME="locn"
>> | MAXLENGTH=60 SIZE=50>
>> |     Your e-mail address   <INPUT TYPE="text" NAME="emad"  MAXLENGTH=60
>> | SIZE=50>
>> |     Your message          <TEXTAREA NAME="question" WRAP=VIRTUAL
>> | ROWS=5 COLS=45></TEXTAREA>
>> |                           <INPUT TYPE="submit" VALUE="Send message">
>> | </PRE>
>> | </FORM>
>> |
>> | Then the send_msg.php should send the e-mail by the following code
>> | (but does not send e-mail). What am I doing wrong?
>
> Apart from the other posters - you are not getting, validating nor
> sanitising the input data.
>
>> | <?php
>> | $date = date("F jS Y, h:iA");
>
> $name = $_POST['name'];
> $orgn = $_POST['orgn'] etc etc
> //-- now validate and sanitise the data
>
> // then - if all is well, send out the email

I added four lines for those four variables.
What does this really do? I already have those values in the
variables. Why do we have to do this?

>
>
>
>> | if ($name == "" && $question == "") {exit;}
>> | $host=@gethostbyaddr($REMOTE_ADDR);
>> | $headers = "From: postmas...@domainname1.org \r\n";
>> | $headers .= "X-Mailer: PHP \r\n";
>> | if(mail("myusernameh...@gmail.com", "Comments from someone.",
>> | "$host on the contacts page at $date \n
>> | --- \n
>> | $name from $orgn, $locn ($emad) wrote:\n\n
>> | $question", $headers)) { $msg = "Thank you"; } else { $msg = "Message
>> | not sent"; }
>> | echo $msg;
>> | ?>
>> |
>> | <html>
>> | <head>
>> |   <title>Test form to email</title>
>> | </head>
>> |
>> | <body>
>> | <?php echo $msg ?>
>> |
>> |
>> | </body>
>> | </html>
>> |
>> | <?php
>> | echo "<HTML>";
>> | echo '<BODY bgcolor="#E0FFE0" text="#008000" leftmargin="30"
>> | topmargin="20">';
>> | echo '<FONT face="Arial" size=1> <B>';
>> | echo $msg ;
>> | echo "Thank you. Your message has been sent.";
>> | echo "</B> </FONT> </HTML>";
>> | ?>
>> |
>> | Thanks for all help/replies.
>> |
>> | By the way, PHP.INI contained the following but suspecting this to be
>> | a problem, I removed the file, and it still does not work.
>> |
>> | register_globals = off
>> | allow_url_fopen = off
>> |
>> | expose_php = Off
>> | max_input_time = 60
>> | variables_order = "EGPCS"
>> | extension_dir = ./
>> | upload_tmp_dir = /tmp
>> | precision = 12
>> | SMTP = relay-hosting.secureserver.net
>> | url_rewriter.tags =
>> | "a=href,area=href,frame=src,input=src,form=,fieldset="
>> |
>> | ; Only uncomment zend optimizer lines if your application requires
>> | Zend Optimizer support
>> |
>> | ;[Zend]
>> | ;zend_optimizer.optimization_level=15
>> | ;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
>> | ;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/
>> | Optimizer_TS-3.3.3
>> | ;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/
>> | ZendExtensionManager.so
>> | ;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/
>> | ZendExtensionManager_TS.so
>> |
>> |
>> | ; -- Be very careful to not to disable a function which might be
>> | needed!
>> | ; -- Uncomment the following lines to increase the security of your
>> | PHP site.
>> |
>> | ;disable_functions =
>> | "highlight_file,ini_alter,ini_restore,openlog,passthru,
>> | ;               phpinfo, exec, system, dl, fsockopen, set_time_limit,
>> | ;                     popen, proc_open,
>> | proc_nice,shell_exec,show_source,symlink"- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
Re: Trouble with sending e-mail from simple php script [message #176504 is a reply to message #176493] Sun, 08 January 2012 19:02 Go to previous messageGo to next message
C is currently offline  C
Messages: 24
Registered: January 2012
Karma: 0
Junior Member
On Jan 8, 6:19 pm, "M. Strobel" <sorry_no_mail_h...@nowhere.dee>
wrote:
> Am 07.01.2012 20:01, schrieb C:
>
>
>
>> By the way, PHP.INI contained the following but suspecting this to be
>> a problem, I removed the file, and it still does not work.
>
> You removed the file?

Yes, I had. I put it back.

>
> Put it back in its original state, and tell us the settings once
> again.

It says the following:

register_globals = off
allow_url_fopen = off

expose_php = Off
max_input_time = 60
variables_order = "EGPCS"
extension_dir = ./
upload_tmp_dir = /tmp
precision = 12
SMTP = relay-hosting.secureserver.net
url_rewriter.tags =
"a=href,area=href,frame=src,input=src,form=,fieldset="


; Only uncomment zend optimizer lines if your application requires
Zend Optimizer support

;[Zend]
;zend_optimizer.optimization_level=15
;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/
Optimizer_TS-3.3.3
;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/
ZendExtensionManager.so
;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/
ZendExtensionManager_TS.so


; -- Be very careful to not to disable a function which might be
needed!
; -- Uncomment the following lines to increase the security of your
PHP site.

;disable_functions =
"highlight_file,ini_alter,ini_restore,openlog,passthru,
; phpinfo, exec, system, dl, fsockopen, set_time_limit,
; popen, proc_open,
proc_nice,shell_exec,show_source,symlink"


>
> During development all error messages should be turned on,
> otherwise you don't see what fails.
>
> /Str.

Thanks. Do you see some trouble with the PHP.INI?
Re: Trouble with sending e-mail from simple php script [message #176510 is a reply to message #176492] Sun, 08 January 2012 20:44 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 1/8/2012 11:01 AM, M. Strobel wrote:
> Am 08.01.2012 16:39, schrieb Jerry Stuckle:
>> On 1/8/2012 10:33 AM, M. Strobel wrote:
>>> Am 08.01.2012 16:02, schrieb Jerry Stuckle:
>>>> On 1/8/2012 9:12 AM, M. Strobel wrote:
>>>> > Am 08.01.2012 10:20, schrieb C:
>>>> >>
>>>> >> Even if the message were rejected, I would still see something
>>>> >> in that
>>>> >> frame, but I get only a blank frame. Client machine
>>>> >> rejecting the
>>>> >> message should not even be noticed by this PHP script, or
>>>> >> would it?
>>>> >>
>>>> > You have to learn how to find and read the log files. Your
>>>> > script
>>>> > will not show errors if it dies.
>>>> >
>>>> > On Linux log files are only readable by root.
>>>> >
>>>> > /Str.
>>>>
>>>> Log files are not always available, and PHP errors are often not
>>>> written to logs (depending on the configuration - the default is
>>>> to NOT write them).
>>>>
>>>> Also, if the log files exist, they may easily be set up to be
>>>> read by others than root.
>>>>
>>>
>>> Don't tell me, tell C.
>>>
>>
>> No, you're the one who made the claims. I'm just correcting your
>> misinformation.
>>
>>> And the standard on linux is that log files are only root
>>> readable. I don't think it helps anybody if we start discussing
>>> what could all be done with the log files.
>>>
>>
>> They can easily be changed - it has nothing to do with whether
>> you're using standard linux or not.
>>
>>> Please do not start arguing with me on this level. I did Coherent
>>> on a serial terminal at home before linux came up, and I was
>>> working in an IBM computing center back then.
>>>
>>> /Str.
>>
>> Great. I was programming an IBM 1410 with punched cards in the
>> 60's and an IBM employee in the 70's - both long before Linux
>> came up.
>>
>> When your statements are incorrect, I will correct them.
>>
> I was glad the punched cards were gone when I came. The old
> operator could sort them by hand.
>
> There was nothing wrong with my statements. If he says "no log
> file" (which is not true, he said "blank frame") or "0 bytes in
> it" we know more, meanwhile it makes sense to suggest a standard
> setup.
>
> /Str.

No log file can be completely correct. The default setup for PHP does
not include writing errors to a log file. Even if the errors are
written to a log file (very unusual in a shared hosting environment), he
will probably not have access to those files. The sysop can change the
configuration (and some good hosts do) to allow this, but it's uncommon.

You are the one who told him he needs to learn to find and read the log
files. And you're the one who said they can only be read by root.
Neither statement is correct.

But it matters not because there is nearly a 0% chance he will be able
to read the log files. So telling him to do it just sends him off on a
wild goose chase.

And as I told him - a blank frame is a different problem than email not
being received. He needs to fix that first.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Trouble with sending e-mail from simple php script [message #176515 is a reply to message #176501] Sun, 08 January 2012 22:02 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
C wrote:
> On Jan 8, 4:34 pm, The Natural Philosopher <t...@invalid.invalid>
> wrote:
>> M. Strobel wrote:
>>> Am 08.01.2012 10:20, schrieb C:
>>>> Even if the message were rejected, I would still see something in that
>>>> frame, but I get only a blank frame. Client machine rejecting the
>>>> message should not even be noticed by this PHP script, or would it?
>>> You have to learn how to find and read the log files. Your script
>>> will not show errors if it dies.
>>> On Linux log files are only readable by root.
>>> /Str.
>> Probably the most common error when using mail() from within php on a
>> shared host is to fail to use the -f function to pass a valid sender
>> address to sendmail (or its analogue). Without that, the 'true' sender
>> is likely to be 'your-login-n...@hosting-omain.com' which will fail most
>> rudimentary validation and simply reject the mail.
>>
>> I ALWAYS use the -f to set the sender to something like
>> 'webmas...@myvirtualdomson.com' and set up that virtual domain so that
>> webmaster is a valid known target for emails.
>>
>> e.g.
>>
>> mail($to, $subject, $body, $headers, "-f webmas...@mydomain.com");
>>
>> is far more likely to get through anti-relay security in the hosts
>> mailer system.
>>
>> Start by testing the host mailer with the above line, so
>>
>> mail("m...@validmail.com","test message", "From:
>> anot...@validmail.com\r\n", -f "webmas...@mydomain.com");
>>
>> is where you should start.
>
> I did that and got an error: Parse error: syntax error, unexpected
> T_CONSTANT_ENCAPSED_STRING
>

Then you typed it wrong

>> If that fails to make it then you need to talk to the hosting company.
>
> I wrote the following test.php, uploaded it and tried it.
>
> <?php
>
> mail("aaaa....@gmail.com","test message", "From:
> postmaster(at)example(dot)org\r\n", -f "postmaster(at)example(dot)org");
>
> ?>

did it work or not...?
>
> My earlier code works well on two other sites of mine which are
> sitting on other shared servers.

So the problem is in the setting of this shared servers mail, which is
what I said..unless you have some other versions of php running.
Re: Trouble with sending e-mail from simple php script [message #176516 is a reply to message #176504] Sun, 08 January 2012 22:35 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 08.01.2012 20:02, schrieb C:
> On Jan 8, 6:19 pm, "M. Strobel" <sorry_no_mail_h...@nowhere.dee>
> wrote:
>> Am 07.01.2012 20:01, schrieb C:
>>
>>
>>
>>> By the way, PHP.INI contained the following but suspecting this to be
>>> a problem, I removed the file, and it still does not work.
>>
>> You removed the file?
>
> Yes, I had. I put it back.
>
>>
>> Put it back in its original state, and tell us the settings once
>> again.
>
> It says the following:
>
> register_globals = off
> allow_url_fopen = off
>
> expose_php = Off
> max_input_time = 60
> variables_order = "EGPCS"
> extension_dir = ./
> upload_tmp_dir = /tmp
> precision = 12
> SMTP = relay-hosting.secureserver.net
> url_rewriter.tags =
> "a=href,area=href,frame=src,input=src,form=,fieldset="
>
>
> ; Only uncomment zend optimizer lines if your application requires
> Zend Optimizer support
>
> ;[Zend]
> ;zend_optimizer.optimization_level=15
> ;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
> ;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/
> Optimizer_TS-3.3.3
> ;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/
> ZendExtensionManager.so
> ;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/
> ZendExtensionManager_TS.so
>
>
> ; -- Be very careful to not to disable a function which might be
> needed!
> ; -- Uncomment the following lines to increase the security of your
> PHP site.
>
> ;disable_functions =
> "highlight_file,ini_alter,ini_restore,openlog,passthru,
> ; phpinfo, exec, system, dl, fsockopen, set_time_limit,
> ; popen, proc_open,
> proc_nice,shell_exec,show_source,symlink"
>
>
>>
>> During development all error messages should be turned on,
>> otherwise you don't see what fails.
>>
>> /Str.
>
> Thanks. Do you see some trouble with the PHP.INI?

Add these entries at the beginning:

display_errors = On
error_reporting = E_ALL
error_log = /var/log/php-errors
log_errors = On

This is about the maximum of error information, it will be
displayed and written to the log file.

You can easily look up the keywords in the web.

Then run your script, and see what the errors are.

/Str.
Re: Trouble with sending e-mail from simple php script [message #176518 is a reply to message #176510] Sun, 08 January 2012 22:53 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 08.01.2012 21:44, schrieb Jerry Stuckle:
> On 1/8/2012 11:01 AM, M. Strobel wrote:
>> Am 08.01.2012 16:39, schrieb Jerry Stuckle:
>>> On 1/8/2012 10:33 AM, M. Strobel wrote:
>>>> Am 08.01.2012 16:02, schrieb Jerry Stuckle:
>>>> > On 1/8/2012 9:12 AM, M. Strobel wrote:
>>>> >> Am 08.01.2012 10:20, schrieb C:
>>>> >>>
>>>> >>> Even if the message were rejected, I would still see
>>>> >>> something
>>>> >>> in that
>>>> >>> frame, but I get only a blank frame. Client machine
>>>> >>> rejecting the
>>>> >>> message should not even be noticed by this PHP script, or
>>>> >>> would it?
>>>> >>>
>>>> >> You have to learn how to find and read the log files. Your
>>>> >> script
>>>> >> will not show errors if it dies.
>>>> >>
>>>> >> On Linux log files are only readable by root.
>>>> >>
>>>> >> /Str.
>>>> >
>>>> > Log files are not always available, and PHP errors are often
>>>> > not
>>>> > written to logs (depending on the configuration - the
>>>> > default is
>>>> > to NOT write them).
>>>> >
>>>> > Also, if the log files exist, they may easily be set up to be
>>>> > read by others than root.
>>>> >
>>>>
>>>> Don't tell me, tell C.
>>>>
>>>
>>> No, you're the one who made the claims. I'm just correcting your
>>> misinformation.
>>>
>>>> And the standard on linux is that log files are only root
>>>> readable. I don't think it helps anybody if we start discussing
>>>> what could all be done with the log files.
>>>>
>>>
>>> They can easily be changed - it has nothing to do with whether
>>> you're using standard linux or not.
>>>
>>>> Please do not start arguing with me on this level. I did
>>>> Coherent
>>>> on a serial terminal at home before linux came up, and I was
>>>> working in an IBM computing center back then.
>>>>
>>>> /Str.
>>>
>>> Great. I was programming an IBM 1410 with punched cards in the
>>> 60's and an IBM employee in the 70's - both long before Linux
>>> came up.
>>>
>>> When your statements are incorrect, I will correct them.
>>>
>> I was glad the punched cards were gone when I came. The old
>> operator could sort them by hand.
>>
>> There was nothing wrong with my statements. If he says "no log
>> file" (which is not true, he said "blank frame") or "0 bytes in
>> it" we know more, meanwhile it makes sense to suggest a standard
>> setup.
>>
>> /Str.
>
> No log file can be completely correct. The default setup for PHP
> does not include writing errors to a log file.

Checked, and true, log_errors is 0.
But display_errors is STDOUT.

> Even if the
> errors are written to a log file (very unusual in a shared
> hosting environment), he will probably not have access to those
> files. The sysop can change the configuration (and some good
> hosts do) to allow this, but it's uncommon.
Is it? There would be no chance to find errors. Last 10 years I
only have virtual and true servers.
>
> You are the one who told him he needs to learn to find and read
> the log files. And you're the one who said they can only be read
> by root. Neither statement is correct.
If he can delete php.ini he is on his own machine.
>
> But it matters not because there is nearly a 0% chance he will be
> able to read the log files. So telling him to do it just sends
> him off on a wild goose chase.
>
I agree to the chance. It is hard to give a basic course in some
newsgroups posts.

> And as I told him - a blank frame is a different problem than
> email not being received. He needs to fix that first.
>
I told him, and it is incorrect, so I sent him into a loop ah
goose chase, so he has no chance, and he listens to me instead of
you, he needs to fix that first, that's my fault, because I don't
care about security, ... Did I summon it up correctly?

/Str.
Re: Trouble with sending e-mail from simple php script [message #176521 is a reply to message #176518] Mon, 09 January 2012 00:00 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 1/8/2012 5:53 PM, M. Strobel wrote:
> Am 08.01.2012 21:44, schrieb Jerry Stuckle:
>> On 1/8/2012 11:01 AM, M. Strobel wrote:
>>> Am 08.01.2012 16:39, schrieb Jerry Stuckle:
>>>> On 1/8/2012 10:33 AM, M. Strobel wrote:
>>>> > Am 08.01.2012 16:02, schrieb Jerry Stuckle:
>>>> >> On 1/8/2012 9:12 AM, M. Strobel wrote:
>>>> >>> Am 08.01.2012 10:20, schrieb C:
>>>> >>>>
>>>> >>>> Even if the message were rejected, I would still see
>>>> >>>> something
>>>> >>>> in that
>>>> >>>> frame, but I get only a blank frame. Client machine
>>>> >>>> rejecting the
>>>> >>>> message should not even be noticed by this PHP script, or
>>>> >>>> would it?
>>>> >>>>
>>>> >>> You have to learn how to find and read the log files. Your
>>>> >>> script
>>>> >>> will not show errors if it dies.
>>>> >>>
>>>> >>> On Linux log files are only readable by root.
>>>> >>>
>>>> >>> /Str.
>>>> >>
>>>> >> Log files are not always available, and PHP errors are often
>>>> >> not
>>>> >> written to logs (depending on the configuration - the
>>>> >> default is
>>>> >> to NOT write them).
>>>> >>
>>>> >> Also, if the log files exist, they may easily be set up to be
>>>> >> read by others than root.
>>>> >>
>>>> >
>>>> > Don't tell me, tell C.
>>>> >
>>>>
>>>> No, you're the one who made the claims. I'm just correcting your
>>>> misinformation.
>>>>
>>>> > And the standard on linux is that log files are only root
>>>> > readable. I don't think it helps anybody if we start discussing
>>>> > what could all be done with the log files.
>>>> >
>>>>
>>>> They can easily be changed - it has nothing to do with whether
>>>> you're using standard linux or not.
>>>>
>>>> > Please do not start arguing with me on this level. I did
>>>> > Coherent
>>>> > on a serial terminal at home before linux came up, and I was
>>>> > working in an IBM computing center back then.
>>>> >
>>>> > /Str.
>>>>
>>>> Great. I was programming an IBM 1410 with punched cards in the
>>>> 60's and an IBM employee in the 70's - both long before Linux
>>>> came up.
>>>>
>>>> When your statements are incorrect, I will correct them.
>>>>
>>> I was glad the punched cards were gone when I came. The old
>>> operator could sort them by hand.
>>>
>>> There was nothing wrong with my statements. If he says "no log
>>> file" (which is not true, he said "blank frame") or "0 bytes in
>>> it" we know more, meanwhile it makes sense to suggest a standard
>>> setup.
>>>
>>> /Str.
>>
>> No log file can be completely correct. The default setup for PHP
>> does not include writing errors to a log file.
>
> Checked, and true, log_errors is 0.
> But display_errors is STDOUT.
>
>> Even if the
>> errors are written to a log file (very unusual in a shared
>> hosting environment), he will probably not have access to those
>> files. The sysop can change the configuration (and some good
>> hosts do) to allow this, but it's uncommon.
> Is it? There would be no chance to find errors. Last 10 years I
> only have virtual and true servers.

Definitely true. To log errors to one file and give anyone access would
be a huge security violation for others on the server.

The server CAN be set up to have individual logs for each site with the
logs accessible to the user (i.e. one level below DOCUMENT_ROOT) can be
done, but it seldom is.

You find errors on your development system (which should be very similar
to your production one - i.e. same versions of PHP and MySQL, etc.)
then, once they are working, upload the code to your production server.

>>
>> You are the one who told him he needs to learn to find and read
>> the log files. And you're the one who said they can only be read
>> by root. Neither statement is correct.
> If he can delete php.ini he is on his own machine.
>>
>> But it matters not because there is nearly a 0% chance he will be
>> able to read the log files. So telling him to do it just sends
>> him off on a wild goose chase.
>>
> I agree to the chance. It is hard to give a basic course in some
> newsgroups posts.
>
>> And as I told him - a blank frame is a different problem than
>> email not being received. He needs to fix that first.
>>
> I told him, and it is incorrect, so I sent him into a loop ah
> goose chase, so he has no chance, and he listens to me instead of
> you, he needs to fix that first, that's my fault, because I don't
> care about security, ... Did I summon it up correctly?
>
> /Str.

Pretty much.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Trouble with sending e-mail from simple php script [message #176528 is a reply to message #176503] Mon, 09 January 2012 01:46 Go to previous messageGo to next message
Jeff North is currently offline  Jeff North
Messages: 58
Registered: November 2010
Karma: 0
Member
On Sun, 8 Jan 2012 10:57:23 -0800 (PST), in comp.lang.php C
<wrong(dot)address(dot)1(at)gmail(dot)com>
<c18fd10b-1e24-4282-9dad-609366911cc3(at)o9g2000yqa(dot)googlegroups(dot)com>
wrote:

[snip]

> | > Apart from the other posters - you are not getting, validating nor
> | > sanitising the input data.
> | >
> | > >| <?php
> | > >| $date = date("F jS Y, h:iA");
> | >
> | > $name = $_POST['name'];
> | > $orgn = $_POST['orgn'] etc etc
> | > //-- now validate and sanitise the data
> | >
> | > // then - if all is well, send out the email
> |
> | I added four lines for those four variables.
> | What does this really do? I already have those values in the
> | variables. Why do we have to do this?

If you are using just $name == '' then how is the value set from the
user's input? To do this you need to get the users input, place it
into your variables, validate and sanitise your data.

Your form uses the method='POST' therefore the data will be sent to
the php file in the $_POST array.

[snip 2 end]
Re: Trouble with sending e-mail from simple php script [message #176543 is a reply to message #176503] Mon, 09 January 2012 12:36 Go to previous messageGo to next message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Jan 8, 6:57 pm, C <wrong.addres...@gmail.com> wrote:
> I added four lines for those four variables.
> What does this really do? I already have those values in the
> variables. Why do we have to do this?
>

You only have those values in variables if you are relying on
register_globals being on. The php manual has this to say on that
subject:

Warning
This feature has been DEPRECATED as of PHP 5.3.0. Relying on this
feature is highly discouraged.

'nuff said?
Re: Trouble with sending e-mail from simple php script [message #176546 is a reply to message #176518] Mon, 09 January 2012 13:32 Go to previous messageGo to next message
C is currently offline  C
Messages: 24
Registered: January 2012
Karma: 0
Junior Member
On Jan 9, 12:53 am, "M. Strobel" <sorry_no_mail_h...@nowhere.dee>
wrote:
> Am 08.01.2012 21:44, schrieb Jerry Stuckle:
>
>
>
>
>
>> On 1/8/2012 11:01 AM, M. Strobel wrote:
>>> Am 08.01.2012 16:39, schrieb Jerry Stuckle:
>>>> On 1/8/2012 10:33 AM, M. Strobel wrote:
>>>> > Am 08.01.2012 16:02, schrieb Jerry Stuckle:
>>>> >> On 1/8/2012 9:12 AM, M. Strobel wrote:
>>>> >>> Am 08.01.2012 10:20, schrieb C:
>
>>>> >>>> Even if the message were rejected, I would still see
>>>> >>>> something
>>>> >>>> in that
>>>> >>>> frame, but I get only a blank frame. Client machine
>>>> >>>> rejecting the
>>>> >>>> message should not even be noticed by this PHP script, or
>>>> >>>> would it?
>
>>>> >>> You have to learn how to find and read the log files. Your
>>>> >>> script
>>>> >>> will not show errors if it dies.
>
>>>> >>> On Linux log files are only readable by root.
>
>>>> >>> /Str.
>
>>>> >> Log files are not always available, and PHP errors are often
>>>> >> not
>>>> >> written to logs (depending on the configuration - the
>>>> >> default is
>>>> >> to NOT write them).
>
>>>> >> Also, if the log files exist, they may easily be set up to be
>>>> >> read by others than root.
>
>>>> > Don't tell me, tell C.
>
>>>> No, you're the one who made the claims.  I'm just correcting your
>>>> misinformation.
>
>>>> > And the standard on linux is that log files are only root
>>>> > readable. I don't think it helps anybody if we start discussing
>>>> > what could all be done with the log files.
>
>>>> They can easily be changed - it has nothing to do with whether
>>>> you're using standard linux or not.
>
>>>> > Please do not start arguing with me on this level. I did
>>>> > Coherent
>>>> > on a serial terminal at home before linux came up, and I was
>>>> > working in an IBM computing center back then.
>
>>>> > /Str.
>
>>>> Great.  I was programming an IBM 1410 with punched cards in the
>>>> 60's and an IBM employee in the 70's - both long before Linux
>>>> came up.
>
>>>> When your statements are incorrect, I will correct them.
>
>>> I was glad the punched cards were gone when I came. The old
>>> operator could sort them by hand.
>
>>> There was nothing wrong with my statements. If he says "no log
>>> file" (which is not true, he said "blank frame") or "0 bytes in
>>> it" we know more, meanwhile it makes sense to suggest a standard
>>> setup.
>
>>> /Str.
>
>> No log file can be completely correct.  The default setup for PHP
>> does not include writing errors to a log file.
>
> Checked, and true, log_errors is 0.
> But display_errors is STDOUT.
>
>> Even if the
>> errors are written to a log file (very unusual in a shared
>> hosting environment), he will probably not have access to those
>> files.  The sysop can change the configuration (and some good
>> hosts do) to allow this, but it's uncommon.
>
> Is it? There would be no chance to find errors. Last 10 years I
> only have virtual and true servers.
>
>> You are the one who told him he needs to learn to find and read
>> the log files.  And you're the one who said they can only be read
>> by root. Neither statement is correct.
>
> If he can delete php.ini he is on his own machine.

No, I am not.

(This work is done for a non-profit organisation voluntarily. A friend
got the server space and domain registration done. I tried to get a
basic www site established, so that I can hand over to others who
would then add information to it now and then.)

>
>> But it matters not because there is nearly a 0% chance he will be
>> able to read the log files.  So telling him to do it just sends
>> him off on a wild goose chase.
>
> I agree to the chance. It is hard to give a basic course in some
> newsgroups posts.
>
>> And as I told him - a blank frame is a different problem than
>> email not being received.  He needs to fix that first.

Getting a blank frame seems to be an additional problem. I have not
made progress on either problem yet.

>
> I told him, and it is incorrect, so I sent him into a loop ah
> goose chase, so he has no chance, and he listens to me instead of
> you, he needs to fix that first, that's my fault, because I don't
> care about security, ... Did I summon it up correctly?
>
> /Str.- Hide quoted text -
>
> - Show quoted text -
Re: Trouble with sending e-mail from simple php script [message #176547 is a reply to message #176528] Mon, 09 January 2012 13:39 Go to previous messageGo to next message
C is currently offline  C
Messages: 24
Registered: January 2012
Karma: 0
Junior Member
On Jan 9, 3:46 am, Jeff North <jnort...@yahoo.com.au> wrote:
> On Sun, 8 Jan 2012 10:57:23 -0800 (PST), in comp.lang.php C
> <wrong.addres...@gmail.com>
> <c18fd10b-1e24-4282-9dad-609366911...@o9g2000yqa.googlegroups.com>
> wrote:
>
> [snip]
>
>> | > Apart from the other posters - you are not getting, validating nor
>> | > sanitising the input data.
>> | >
>> | > >| <?php
>> | > >| $date = date("F jS Y, h:iA");
>> | >
>> | > $name = $_POST['name'];
>> | > $orgn = $_POST['orgn'] etc etc
>> | > //-- now validate and sanitise the data
>> | >
>> | > // then - if all is well, send out the email
>> |
>> | I added four lines for those four variables.
>> | What does this really do? I already have those values in the
>> | variables. Why do we have to do this?
>
-> If you are using just $name == '' then how is the value set from
the
-> user's input? To do this you need to get the users input, place it
-> into your variables, validate and sanitise your data.
->
-> Your form uses the  method='POST' therefore the data will be sent
to
-> the php file in the $_POST array.
>
> [snip 2 end]

It works on two other sites in that way. I did not even know about the
$_POST array until recently.

The contact page is in contact.php, and the action is send_msg.php.
This send_msg.php seems to know the values of Method=Post variables.

I have INPUT TYPE = "text" NAME = "name", etc. and send_msg.php should
know the values of $name, $locn, etc.
Re: Trouble with sending e-mail from simple php script [message #176548 is a reply to message #176543] Mon, 09 January 2012 13:40 Go to previous messageGo to next message
C is currently offline  C
Messages: 24
Registered: January 2012
Karma: 0
Junior Member
On Jan 9, 2:36 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> On Jan 8, 6:57 pm, C <wrong.addres...@gmail.com> wrote:
>
>> I added four lines for those four variables.
>> What does this really do? I already have those values in the
>> variables. Why do we have to do this?
>
> You only have those values in variables if you are relying on
> register_globals being on. The php manual has this to say on that
> subject:
>
> Warning
> This feature has been DEPRECATED as of PHP 5.3.0. Relying on this
> feature is highly discouraged.
>
> 'nuff said?

THIS MIGHT BE IT. I will try at home in the evening.
Re: Trouble with sending e-mail from simple php script [message #176549 is a reply to message #176516] Mon, 09 January 2012 13:28 Go to previous messageGo to next message
C is currently offline  C
Messages: 24
Registered: January 2012
Karma: 0
Junior Member
On Jan 9, 12:35 am, "M. Strobel" <sorry_no_mail_h...@nowhere.dee>
wrote:
> Am 08.01.2012 20:02, schrieb C:
>
>
>
>
>
>> On Jan 8, 6:19 pm, "M. Strobel" <sorry_no_mail_h...@nowhere.dee>
>> wrote:
>>> Am 07.01.2012 20:01, schrieb C:
>
>>>> By the way, PHP.INI contained the following but suspecting this to be
>>>> a problem, I removed the file, and it still does not work.
>
>>> You removed the file?
>
>> Yes, I had. I put it back.
>
>>> Put it back in its original state, and tell us the settings once
>>> again.
>
>> It says the following:
>
>> register_globals = off
>> allow_url_fopen = off
>
>> expose_php = Off
>> max_input_time = 60
>> variables_order = "EGPCS"
>> extension_dir = ./
>> upload_tmp_dir = /tmp
>> precision = 12
>> SMTP = relay-hosting.secureserver.net
>> url_rewriter.tags =
>> "a=href,area=href,frame=src,input=src,form=,fieldset="
>
>> ; Only uncomment zend optimizer lines if your application requires
>> Zend Optimizer support
>
>> ;[Zend]
>> ;zend_optimizer.optimization_level=15
>> ;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
>> ;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/
>> Optimizer_TS-3.3.3
>> ;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/
>> ZendExtensionManager.so
>> ;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/
>> ZendExtensionManager_TS.so
>
>> ; -- Be very careful to not to disable a function which might be
>> needed!
>> ; -- Uncomment the following lines to increase the security of your
>> PHP site.
>
>> ;disable_functions =
>> "highlight_file,ini_alter,ini_restore,openlog,passthru,
>> ;                phpinfo, exec, system, dl, fsockopen, set_time_limit,
>> ;                     popen, proc_open,
>> proc_nice,shell_exec,show_source,symlink"
>
>>> During development all error messages should be turned on,
>>> otherwise you don't see what fails.
>
>>> /Str.
>
>> Thanks. Do you see some trouble with the PHP.INI?
>
> Add these entries at the beginning:
>
> display_errors = On
> error_reporting = E_ALL
> error_log = /var/log/php-errors
> log_errors = On
>
> This is about the maximum of error information, it will be
> displayed and written to the log file.
>
> You can easily look up the keywords in the web.
>
> Then run your script, and see what the errors are.
>
> /Str.- Hide quoted text -
>
> - Show quoted text -

Thanks. I should try this and let you know what happened. I have the
files lying at home.
Re: Trouble with sending e-mail from simple php script [message #176550 is a reply to message #176515] Mon, 09 January 2012 13:27 Go to previous messageGo to next message
C is currently offline  C
Messages: 24
Registered: January 2012
Karma: 0
Junior Member
On Jan 9, 12:02 am, The Natural Philosopher <t...@invalid.invalid>
wrote:
> C wrote:
>> On Jan 8, 4:34 pm, The Natural Philosopher <t...@invalid.invalid>
>> wrote:
>>> M. Strobel wrote:
>>>> Am 08.01.2012 10:20, schrieb C:
>>>> > Even if the message were rejected, I would still see something in that
>>>> > frame, but I get only a blank frame. Client machine rejecting the
>>>> > message should not even be noticed by this PHP script, or would it?
>>>> You have to learn how to find and read the log files. Your script
>>>> will not show errors if it dies.
>>>> On Linux log files are only readable by root.
>>>> /Str.
>>> Probably the most common error when using mail() from within php on a
>>> shared host is to fail to use the -f function to pass a valid sender
>>> address to sendmail (or its analogue). Without that, the 'true' sender
>>> is likely to be 'your-login-n...@hosting-omain.com' which will fail most
>>> rudimentary validation and simply reject the mail.
>
>>> I ALWAYS use the -f to set the sender to something like
>>> 'webmas...@myvirtualdomson.com' and set up that virtual domain so that
>>> webmaster is a valid known target for emails.
>
>>> e.g.
>
>>> mail($to, $subject, $body, $headers, "-f webmas...@mydomain.com");
>
>>> is far more likely to get through anti-relay security in the hosts
>>> mailer system.
>
>>> Start by testing the host mailer with the above line, so
>
>>> mail("m...@validmail.com","test message", "From:
>>> anot...@validmail.com\r\n", -f "webmas...@mydomain.com");
>
>>> is where you should start.
>
>> I did that and got an error: Parse error: syntax error, unexpected
>> T_CONSTANT_ENCAPSED_STRING
>
> Then you typed it wrong
>
>>> If that fails to make it then you need to talk to the hosting company.
>
>> I wrote the following test.php, uploaded it and tried it.
>
> > <?php
>
> > mail("aaaa....@gmail.com","test message", "From:
> > postmas...@example.org\r\n", -f "postmas...@example.org");
>
> > ?>
>
> did it work or not...?
>

No, it did not send me any mail (at least I did not receive any), and
resulted in a blank page (but perhaps that is expected since there are
no html or echo statements).

>
>
>> My earlier code works well on two other sites of mine which are
>> sitting on other shared servers.
>
> So the problem is in the setting of this shared servers mail, which is
> what I said..unless you have some other versions of php running.- Hide quoted text -

Should I try to circumvent the problem in some way? Can one write the
same thing in Javascript?

>
> - Show quoted text -
Re: Trouble with sending e-mail from simple php script [message #176551 is a reply to message #176548] Mon, 09 January 2012 13:53 Go to previous messageGo to next message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Jan 9, 1:40 pm, C <wrong.addres...@gmail.com> wrote:
> On Jan 9, 2:36 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote:
>
>> On Jan 8, 6:57 pm, C <wrong.addres...@gmail.com> wrote:
>
>>> I added four lines for those four variables.
>>> What does this really do? I already have those values in the
>>> variables. Why do we have to do this?
>
>> You only have those values in variables if you are relying on
>> register_globals being on. The php manual has this to say on that
>> subject:
>
>> Warning
>> This feature has been DEPRECATED as of PHP 5.3.0. Relying on this
>> feature is highly discouraged.
>
>> 'nuff said?
>
> THIS MIGHT BE IT. I will try at home in the evening.

There is no "might" about it. Jeff's suggested lines:

$name = $_POST['name'];
$orgn = $_POST['orgn'] etc etc

are the way it is done nowadays, because register_globals no longer is.
Re: Trouble with sending e-mail from simple php script [message #176552 is a reply to message #176546] Mon, 09 January 2012 14:32 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
C wrote:
> On Jan 9, 12:53 am, "M. Strobel" <sorry_no_mail_h...@nowhere.dee>
> wrote:
>> Am 08.01.2012 21:44, schrieb Jerry Stuckle:
>>
>>
>>
>>
>>
>>> On 1/8/2012 11:01 AM, M. Strobel wrote:
>>>> Am 08.01.2012 16:39, schrieb Jerry Stuckle:
>>>> > On 1/8/2012 10:33 AM, M. Strobel wrote:
>>>> >> Am 08.01.2012 16:02, schrieb Jerry Stuckle:
>>>> >>> On 1/8/2012 9:12 AM, M. Strobel wrote:
>>>> >>>> Am 08.01.2012 10:20, schrieb C:
>>>> >>>>> Even if the message were rejected, I would still see
>>>> >>>>> something
>>>> >>>>> in that
>>>> >>>>> frame, but I get only a blank frame. Client machine
>>>> >>>>> rejecting the
>>>> >>>>> message should not even be noticed by this PHP script, or
>>>> >>>>> would it?
>>>> >>>> You have to learn how to find and read the log files. Your
>>>> >>>> script
>>>> >>>> will not show errors if it dies.
>>>> >>>> On Linux log files are only readable by root.
>>>> >>>> /Str.
>>>> >>> Log files are not always available, and PHP errors are often
>>>> >>> not
>>>> >>> written to logs (depending on the configuration - the
>>>> >>> default is
>>>> >>> to NOT write them).
>>>> >>> Also, if the log files exist, they may easily be set up to be
>>>> >>> read by others than root.
>>>> >> Don't tell me, tell C.
>>>> > No, you're the one who made the claims. I'm just correcting your
>>>> > misinformation.
>>>> >> And the standard on linux is that log files are only root
>>>> >> readable. I don't think it helps anybody if we start discussing
>>>> >> what could all be done with the log files.
>>>> > They can easily be changed - it has nothing to do with whether
>>>> > you're using standard linux or not.
>>>> >> Please do not start arguing with me on this level. I did
>>>> >> Coherent
>>>> >> on a serial terminal at home before linux came up, and I was
>>>> >> working in an IBM computing center back then.
>>>> >> /Str.
>>>> > Great. I was programming an IBM 1410 with punched cards in the
>>>> > 60's and an IBM employee in the 70's - both long before Linux
>>>> > came up.
>>>> > When your statements are incorrect, I will correct them.
>>>> I was glad the punched cards were gone when I came. The old
>>>> operator could sort them by hand.
>>>> There was nothing wrong with my statements. If he says "no log
>>>> file" (which is not true, he said "blank frame") or "0 bytes in
>>>> it" we know more, meanwhile it makes sense to suggest a standard
>>>> setup.
>>>> /Str.
>>> No log file can be completely correct. The default setup for PHP
>>> does not include writing errors to a log file.
>> Checked, and true, log_errors is 0.
>> But display_errors is STDOUT.
>>
>>> Even if the
>>> errors are written to a log file (very unusual in a shared
>>> hosting environment), he will probably not have access to those
>>> files. The sysop can change the configuration (and some good
>>> hosts do) to allow this, but it's uncommon.
>> Is it? There would be no chance to find errors. Last 10 years I
>> only have virtual and true servers.
>>
>>> You are the one who told him he needs to learn to find and read
>>> the log files. And you're the one who said they can only be read
>>> by root. Neither statement is correct.
>> If he can delete php.ini he is on his own machine.
>
> No, I am not.
>
> (This work is done for a non-profit organisation voluntarily. A friend
> got the server space and domain registration done. I tried to get a
> basic www site established, so that I can hand over to others who
> would then add information to it now and then.)
>
>>> But it matters not because there is nearly a 0% chance he will be
>>> able to read the log files. So telling him to do it just sends
>>> him off on a wild goose chase.
>> I agree to the chance. It is hard to give a basic course in some
>> newsgroups posts.
>>
>>> And as I told him - a blank frame is a different problem than
>>> email not being received. He needs to fix that first.
>
> Getting a blank frame seems to be an additional problem. I have not
> made progress on either problem yet.
>
in my latest default debian squeeze mysql, the default setup both rids
me of magic quotes, which I had to re-enable, and also hides any errors
from appearing on the users web browser..instead these are sometimes
silently ignored, and sometimes appear the apaches error log.

The result is that a blank screen is not uncommon during any program bug
- especially syntax errors.

I have not delved into this beyond that - since I have root access to
the server keeping a screen monitoring apache errors is trivial.

Probably you need to get error reports to be directed to a useful file
in your user space where you can pick over the remains...


I have never had occasion to do this, so I cant say how it might be done.
Re: Trouble with sending e-mail from simple php script [message #176553 is a reply to message #176549] Mon, 09 January 2012 14:34 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
C wrote:
> On Jan 9, 12:35 am, "M. Strobel" <sorry_no_mail_h...@nowhere.dee>
> wrote:
>> Am 08.01.2012 20:02, schrieb C:
>>
>>
>>
>>
>>
>>> On Jan 8, 6:19 pm, "M. Strobel" <sorry_no_mail_h...@nowhere.dee>
>>> wrote:
>>>> Am 07.01.2012 20:01, schrieb C:
>>>> > By the way, PHP.INI contained the following but suspecting this to be
>>>> > a problem, I removed the file, and it still does not work.
>>>> You removed the file?
>>> Yes, I had. I put it back.
>>>> Put it back in its original state, and tell us the settings once
>>>> again.
>>> It says the following:
>>> register_globals = off
>>> allow_url_fopen = off
>>> expose_php = Off
>>> max_input_time = 60
>>> variables_order = "EGPCS"
>>> extension_dir = ./
>>> upload_tmp_dir = /tmp
>>> precision = 12
>>> SMTP = relay-hosting.secureserver.net
>>> url_rewriter.tags =
>>> "a=href,area=href,frame=src,input=src,form=,fieldset="
>>> ; Only uncomment zend optimizer lines if your application requires
>>> Zend Optimizer support
>>> ;[Zend]
>>> ;zend_optimizer.optimization_level=15
>>> ;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
>>> ;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/
>>> Optimizer_TS-3.3.3
>>> ;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/
>>> ZendExtensionManager.so
>>> ;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/
>>> ZendExtensionManager_TS.so
>>> ; -- Be very careful to not to disable a function which might be
>>> needed!
>>> ; -- Uncomment the following lines to increase the security of your
>>> PHP site.
>>> ;disable_functions =
>>> "highlight_file,ini_alter,ini_restore,openlog,passthru,
>>> ; phpinfo, exec, system, dl, fsockopen, set_time_limit,
>>> ; popen, proc_open,
>>> proc_nice,shell_exec,show_source,symlink"
>>>> During development all error messages should be turned on,
>>>> otherwise you don't see what fails.
>>>> /Str.
>>> Thanks. Do you see some trouble with the PHP.INI?
>> Add these entries at the beginning:
>>
>> display_errors = On
>> error_reporting = E_ALL
>> error_log = /var/log/php-errors

that may not be useful if /var/log is not accessible on a shared host.

>> log_errors = On
>>
>> This is about the maximum of error information, it will be
>> displayed and written to the log file.
>>
>> You can easily look up the keywords in the web.
>>
>> Then run your script, and see what the errors are.
>>
>> /Str.- Hide quoted text -
>>
>> - Show quoted text -
>
> Thanks. I should try this and let you know what happened. I have the
> files lying at home.
Re: Trouble with sending e-mail from simple php script [message #176554 is a reply to message #176550] Mon, 09 January 2012 14:35 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
C wrote:
> On Jan 9, 12:02 am, The Natural Philosopher <t...@invalid.invalid>
> wrote:
>> C wrote:
>>> On Jan 8, 4:34 pm, The Natural Philosopher <t...@invalid.invalid>
>>> wrote:
>>>> M. Strobel wrote:
>>>> > Am 08.01.2012 10:20, schrieb C:
>>>> >> Even if the message were rejected, I would still see something in that
>>>> >> frame, but I get only a blank frame. Client machine rejecting the
>>>> >> message should not even be noticed by this PHP script, or would it?
>>>> > You have to learn how to find and read the log files. Your script
>>>> > will not show errors if it dies.
>>>> > On Linux log files are only readable by root.
>>>> > /Str.
>>>> Probably the most common error when using mail() from within php on a
>>>> shared host is to fail to use the -f function to pass a valid sender
>>>> address to sendmail (or its analogue). Without that, the 'true' sender
>>>> is likely to be 'your-login-n...@hosting-omain.com' which will fail most
>>>> rudimentary validation and simply reject the mail.
>>>> I ALWAYS use the -f to set the sender to something like
>>>> 'webmas...@myvirtualdomson.com' and set up that virtual domain so that
>>>> webmaster is a valid known target for emails.
>>>> e.g.
>>>> mail($to, $subject, $body, $headers, "-f webmas...@mydomain.com");
>>>> is far more likely to get through anti-relay security in the hosts
>>>> mailer system.
>>>> Start by testing the host mailer with the above line, so
>>>> mail("m...@validmail.com","test message", "From:
>>>> anot...@validmail.com\r\n", -f "webmas...@mydomain.com");
>>>> is where you should start.
>>> I did that and got an error: Parse error: syntax error, unexpected
>>> T_CONSTANT_ENCAPSED_STRING
>> Then you typed it wrong
>>
>>>> If that fails to make it then you need to talk to the hosting company.
>>> I wrote the following test.php, uploaded it and tried it.
>>> <?php
>>
>>> mail("aaaa....@gmail.com","test message", "From:
>>> postmas...@example.org\r\n", -f "postmas...@example.org");
>>
>>> ?>
>>
>> did it work or not...?
>>
>
> No, it did not send me any mail (at least I did not receive any), and
> resulted in a blank page (but perhaps that is expected since there are
> no html or echo statements).
>

Indeed. Well in that case the mail interface at least is an issue: And
it looks like you have others.

Time for full error logging to see what's what.



>>
>>> My earlier code works well on two other sites of mine which are
>>> sitting on other shared servers.
>> So the problem is in the setting of this shared servers mail, which is
>> what I said..unless you have some other versions of php running.- Hide quoted text -
>
> Should I try to circumvent the problem in some way? Can one write the
> same thing in Javascript?
>
>> - Show quoted text -
>
Re: Trouble with sending e-mail from simple php script [message #176556 is a reply to message #176551] Mon, 09 January 2012 14:50 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article
<36944289-58f2-4cc9-a12f-386aa9ad6da9(at)y7g2000vbe(dot)googlegroups(dot)com>,
Captain Paralytic <paul_lautman(at)yahoo(dot)com> wrote:

> On Jan 9, 1:40 pm, C <wrong.addres...@gmail.com> wrote:
>> On Jan 9, 2:36 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote:
>>
>>> On Jan 8, 6:57 pm, C <wrong.addres...@gmail.com> wrote:
>>
>>>> I added four lines for those four variables.
>>>> What does this really do? I already have those values in the
>>>> variables. Why do we have to do this?
>>
>>> You only have those values in variables if you are relying on
>>> register_globals being on. The php manual has this to say on that
>>> subject:
>>
>>> Warning
>>> This feature has been DEPRECATED as of PHP 5.3.0. Relying on this
>>> feature is highly discouraged.
>>
>>> 'nuff said?
>>
>> THIS MIGHT BE IT. I will try at home in the evening.
>
> There is no "might" about it. Jeff's suggested lines:
>
> $name = $_POST['name'];
> $orgn = $_POST['orgn'] etc etc
>
> are the way it is done nowadays, because register_globals no longer is.

Doing it this way provides some security. It means that the *only* way
to get that data is via the $_POST array. So that means that your script
doesn't start off with values in variables, assume they're OK, and use
them. The old way meant someone could just run your script and preset
*any* variable, even one you didn't mean to have set by the web page. So
if you forgot to initialise $delete, but instead relied on it being null
by default, and your code has this:

if ($delete==1)
{
delete_complete_file_system ();
}

the bad guy could easily do you some damage.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: Trouble with sending e-mail from simple php script [message #176557 is a reply to message #176546] Mon, 09 January 2012 15:04 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 1/9/2012 8:32 AM, C wrote:
> On Jan 9, 12:53 am, "M. Strobel"<sorry_no_mail_h...@nowhere.dee>
> wrote:
>> Am 08.01.2012 21:44, schrieb Jerry Stuckle:
>>
>>
>>
>>
>>
>>> On 1/8/2012 11:01 AM, M. Strobel wrote:
>>>> Am 08.01.2012 16:39, schrieb Jerry Stuckle:
>>>> > On 1/8/2012 10:33 AM, M. Strobel wrote:
>>>> >> Am 08.01.2012 16:02, schrieb Jerry Stuckle:
>>>> >>> On 1/8/2012 9:12 AM, M. Strobel wrote:
>>>> >>>> Am 08.01.2012 10:20, schrieb C:
>>
>>>> >>>>> Even if the message were rejected, I would still see
>>>> >>>>> something
>>>> >>>>> in that
>>>> >>>>> frame, but I get only a blank frame. Client machine
>>>> >>>>> rejecting the
>>>> >>>>> message should not even be noticed by this PHP script, or
>>>> >>>>> would it?
>>
>>>> >>>> You have to learn how to find and read the log files. Your
>>>> >>>> script
>>>> >>>> will not show errors if it dies.
>>
>>>> >>>> On Linux log files are only readable by root.
>>
>>>> >>>> /Str.
>>
>>>> >>> Log files are not always available, and PHP errors are often
>>>> >>> not
>>>> >>> written to logs (depending on the configuration - the
>>>> >>> default is
>>>> >>> to NOT write them).
>>
>>>> >>> Also, if the log files exist, they may easily be set up to be
>>>> >>> read by others than root.
>>
>>>> >> Don't tell me, tell C.
>>
>>>> > No, you're the one who made the claims. I'm just correcting your
>>>> > misinformation.
>>
>>>> >> And the standard on linux is that log files are only root
>>>> >> readable. I don't think it helps anybody if we start discussing
>>>> >> what could all be done with the log files.
>>
>>>> > They can easily be changed - it has nothing to do with whether
>>>> > you're using standard linux or not.
>>
>>>> >> Please do not start arguing with me on this level. I did
>>>> >> Coherent
>>>> >> on a serial terminal at home before linux came up, and I was
>>>> >> working in an IBM computing center back then.
>>
>>>> >> /Str.
>>
>>>> > Great. I was programming an IBM 1410 with punched cards in the
>>>> > 60's and an IBM employee in the 70's - both long before Linux
>>>> > came up.
>>
>>>> > When your statements are incorrect, I will correct them.
>>
>>>> I was glad the punched cards were gone when I came. The old
>>>> operator could sort them by hand.
>>
>>>> There was nothing wrong with my statements. If he says "no log
>>>> file" (which is not true, he said "blank frame") or "0 bytes in
>>>> it" we know more, meanwhile it makes sense to suggest a standard
>>>> setup.
>>
>>>> /Str.
>>
>>> No log file can be completely correct. The default setup for PHP
>>> does not include writing errors to a log file.
>>
>> Checked, and true, log_errors is 0.
>> But display_errors is STDOUT.
>>
>>> Even if the
>>> errors are written to a log file (very unusual in a shared
>>> hosting environment), he will probably not have access to those
>>> files. The sysop can change the configuration (and some good
>>> hosts do) to allow this, but it's uncommon.
>>
>> Is it? There would be no chance to find errors. Last 10 years I
>> only have virtual and true servers.
>>
>>> You are the one who told him he needs to learn to find and read
>>> the log files. And you're the one who said they can only be read
>>> by root. Neither statement is correct.
>>
>> If he can delete php.ini he is on his own machine.
>
> No, I am not.
>
> (This work is done for a non-profit organisation voluntarily. A friend
> got the server space and domain registration done. I tried to get a
> basic www site established, so that I can hand over to others who
> would then add information to it now and then.)
>

Non-profit or not, you need to set up a development machine which
closely emulates what you have on the server. That way you can write
and test your code locally, while displaying error messages, etc. Then
once the code is working you can upload to the production server.

It's not that hard to set up a local machine. There are packages out
there which will help you, depending on your OS.

>>
>>> But it matters not because there is nearly a 0% chance he will be
>>> able to read the log files. So telling him to do it just sends
>>> him off on a wild goose chase.
>>
>> I agree to the chance. It is hard to give a basic course in some
>> newsgroups posts.
>>
>>> And as I told him - a blank frame is a different problem than
>>> email not being received. He needs to fix that first.
>
> Getting a blank frame seems to be an additional problem. I have not
> made progress on either problem yet.
>

That's why you need a local development server.

>>
>> I told him, and it is incorrect, so I sent him into a loop ah
>> goose chase, so he has no chance, and he listens to me instead of
>> you, he needs to fix that first, that's my fault, because I don't
>> care about security, ... Did I summon it up correctly?
>>
>> /Str.- Hide quoted text -
>>
>> - Show quoted text -
>



--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Trouble with sending e-mail from simple php script [message #176559 is a reply to message #176543] Mon, 09 January 2012 15:30 Go to previous messageGo to next message
C is currently offline  C
Messages: 24
Registered: January 2012
Karma: 0
Junior Member
On Jan 9, 2:36 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> On Jan 8, 6:57 pm, C <wrong.addres...@gmail.com> wrote:
>
>> I added four lines for those four variables.
>> What does this really do? I already have those values in the
>> variables. Why do we have to do this?
>
> You only have those values in variables if you are relying on
> register_globals being on. The php manual has this to say on that
> subject:
>
> Warning
> This feature has been DEPRECATED as of PHP 5.3.0. Relying on this
> feature is highly discouraged.
>
> 'nuff said?

THIS WAS IT.

register_globals is off by default and confirmed even by PHP.INI.
This meant that the variables $name, $locn were empty and the if
statements saw them as empty and decided that this was not a proper
message to be sent. Nothing happened after that (just exit) and
therefore also the blank frame.

Now it seems to be sending messages about 75% of the time. I tested
very many variations, and some of them are disappearing. This should
be in the logic in the code. If not, I will ask here with a new
subject line.

THANKS to all of you for trying to help and particularly to you, who
pointed out the essential thing.
Re: Trouble with sending e-mail from simple php script [message #176560 is a reply to message #176551] Mon, 09 January 2012 15:32 Go to previous messageGo to next message
C is currently offline  C
Messages: 24
Registered: January 2012
Karma: 0
Junior Member
On Jan 9, 3:53 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> On Jan 9, 1:40 pm, C <wrong.addres...@gmail.com> wrote:
>
>
>
>
>
>> On Jan 9, 2:36 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote:
>
>>> On Jan 8, 6:57 pm, C <wrong.addres...@gmail.com> wrote:
>
>>>> I added four lines for those four variables.
>>>> What does this really do? I already have those values in the
>>>> variables. Why do we have to do this?
>
>>> You only have those values in variables if you are relying on
>>> register_globals being on. The php manual has this to say on that
>>> subject:
>
>>> Warning
>>> This feature has been DEPRECATED as of PHP 5.3.0. Relying on this
>>> feature is highly discouraged.
>
>>> 'nuff said?
>
>> THIS MIGHT BE IT. I will try at home in the evening.
>
> There is no "might" about it. Jeff's suggested lines:
>
-> $name = $_POST['name'];
-> $orgn = $_POST['orgn'] etc etc
->
-> are the way it is done nowadays, because register_globals no longer
is.- Hide quoted text -
->
> - Show quoted text -

You are right. This worked. I think I could also have set register
globals to on in PHP.INI.
Re: Trouble with sending e-mail from simple php script [message #176562 is a reply to message #176556] Mon, 09 January 2012 15:34 Go to previous messageGo to next message
C is currently offline  C
Messages: 24
Registered: January 2012
Karma: 0
Junior Member
On Jan 9, 4:50 pm, Tim Streater <timstrea...@greenbee.net> wrote:
> In article
> <36944289-58f2-4cc9-a12f-386aa9ad6...@y7g2000vbe.googlegroups.com>,
>  Captain Paralytic <paul_laut...@yahoo.com> wrote:
>
>
>
>
>
>> On Jan 9, 1:40 pm, C <wrong.addres...@gmail.com> wrote:
>>> On Jan 9, 2:36 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote:
>
>>>> On Jan 8, 6:57 pm, C <wrong.addres...@gmail.com> wrote:
>
>>>> > I added four lines for those four variables.
>>>> > What does this really do? I already have those values in the
>>>> > variables. Why do we have to do this?
>
>>>> You only have those values in variables if you are relying on
>>>> register_globals being on. The php manual has this to say on that
>>>> subject:
>
>>>> Warning
>>>> This feature has been DEPRECATED as of PHP 5.3.0. Relying on this
>>>> feature is highly discouraged.
>
>>>> 'nuff said?
>
>>> THIS MIGHT BE IT. I will try at home in the evening.
>
>> There is no "might" about it. Jeff's suggested lines:
>
>> $name = $_POST['name'];
>> $orgn = $_POST['orgn'] etc etc
>
>> are the way it is done nowadays, because register_globals no longer is.
>
> Doing it this way provides some security. It means that the *only* way
> to get that data is via the $_POST array. So that means that your script
> doesn't start off with values in variables, assume they're OK, and use
> them. The old way meant someone could just run your script and preset
> *any* variable, even one you didn't mean to have set by the web page. So
> if you forgot to initialise $delete, but instead relied on it being null
> by default, and your code has this:
>
> if  ($delete==1)
>    {
>    delete_complete_file_system ();
>    }
>
> the bad guy could easily do you some damage.
>
> --
> Tim
>
> "That excessive bail ought not to be required, nor excessive fines imposed,
> nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689- Hide quoted text -
>
> - Show quoted text -

Makes sense.

Thanks for the explanation.
Re: Trouble with sending e-mail from simple php script [message #176563 is a reply to message #176556] Mon, 09 January 2012 15:40 Go to previous messageGo to previous message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Jan 9, 2:50 pm, Tim Streater <timstrea...@greenbee.net> wrote:
> In article
> <36944289-58f2-4cc9-a12f-386aa9ad6...@y7g2000vbe.googlegroups.com>,
>  Captain Paralytic <paul_laut...@yahoo.com> wrote:
>
>
>
>
>
>
>
>
>
>> On Jan 9, 1:40 pm, C <wrong.addres...@gmail.com> wrote:
>>> On Jan 9, 2:36 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote:
>
>>>> On Jan 8, 6:57 pm, C <wrong.addres...@gmail.com> wrote:
>
>>>> > I added four lines for those four variables.
>>>> > What does this really do? I already have those values in the
>>>> > variables. Why do we have to do this?
>
>>>> You only have those values in variables if you are relying on
>>>> register_globals being on. The php manual has this to say on that
>>>> subject:
>
>>>> Warning
>>>> This feature has been DEPRECATED as of PHP 5.3.0. Relying on this
>>>> feature is highly discouraged.
>
>>>> 'nuff said?
>
>>> THIS MIGHT BE IT. I will try at home in the evening.
>
>> There is no "might" about it. Jeff's suggested lines:
>
>> $name = $_POST['name'];
>> $orgn = $_POST['orgn'] etc etc
>
>> are the way it is done nowadays, because register_globals no longer is.
>
> Doing it this way provides some security. It means that the *only* way
> to get that data is via the $_POST array. So that means that your script
> doesn't start off with values in variables, assume they're OK, and use
> them. The old way meant someone could just run your script and preset
> *any* variable, even one you didn't mean to have set by the web page. So
> if you forgot to initialise $delete, but instead relied on it being null
> by default, and your code has this:
>
> if  ($delete==1)
>    {
>    delete_complete_file_system ();
>    }
>
> the bad guy could easily do you some damage.
>
> --
> Tim
>
> "That excessive bail ought not to be required, nor excessive fines imposed,
> nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689

I think I already knew that! And sorry but your post will now be
archived regardless of your setting.
Pages (2): [1  2    »]  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: scoping inside a block
Next Topic: Best PHP Training | PHP Development Training | PHP Training Institute
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 03:51:21 GMT 2024

Total time taken to generate the page: 0.02269 seconds