php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16516 mail doesn't work with globalized vars
Submitted: 2002-04-09 12:50 UTC Modified: 2002-04-10 04:31 UTC
From: djlopez at mail dot com Assigned:
Status: Closed Package: Mail related
PHP Version: 4.1.2 OS: FreeBSD 4.4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: djlopez at mail dot com
New email:
PHP Version: OS:

 

 [2002-04-09 12:50 UTC] djlopez at mail dot com
I got 3 files, part of an eShop:

config.php  // contains $mailto
func.php    // contains sendmail();
send.php    // calls sendmail();

OK, the problem was, I execute send.php:

<? 
include("config.php");
include("func.php");
sendmail();
//now HTML-code
?>



sendmail() contains:

<?
function sendmail(){
global $mailto;         //and other vars

//now last line
mail($mailto, "Any subject", $body, "From: any@adress.com");
}
?>


Now, PHP crashed without a reason, server error page appears, nothing wrote to the error.log!


I changed the mail-function in:

mail("the@recipient.com", "Any subject", $body, "From: any@adress.com");

Now it worked fine!
Dunno if its a bug, but it was difficult to catch the error!


Apache Server, tested with PHP 4.0.6 and 4.1.2
(err, sorry 4 bad english)

greets, 
Lopez

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-09 13:55 UTC] sander@php.net
To properly diagnose this bug, we need a backtrace to see what is
happening behind the scenes. To find out how to generate a backtrace,
please read http://bugs.php.net/bugs-generating-backtrace.php

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open".
 [2002-04-09 16:29 UTC] djlopez at mail dot com
Sorry, can't backtrace on my server!
But it's really reproducible!
so here's the set of files:

send.php:
<?
include("func.php");
sendmail();
?>


func.php:
<?
function sendmail(){
global $mailto;
mail($mailto, "Subject", "Body", "From: djlopez@gmx.de");
}
?>

config.php:
<?
$mailto="djlopez@gmx.de";
?>


Just put this 3 files on a server in the same directory, and start "send.php" in your browser.
It shouldn't work.
 [2002-04-09 16:34 UTC] mfischer@php.net
Can't work unless you include config.php somewhere.
 [2002-04-09 16:36 UTC] derick@php.net
Where do you include config.php?

Derick
 [2002-04-10 04:31 UTC] djlopez at mail dot com
just include the config.php in send.php!
But thats right, it crashed too, if config.php is not included :)
However, it works on Win32 systems, but on my server it wouldn't work....
It's part of an eShop, so I can't give the complete sourcecode.
So, I don't think it's very important... I'll close it.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 14:01:29 2024 UTC