Page 1 of 1
PHP Mail() problem
Posted: Mon Jan 17, 2005 2:02 pm
by mmanders
I have php code which I know corectly sends an email. After the email has been sent, I want to include the contents of another php file to display a "success" style message. After the email is sent, this arbitrary success code does not get executed. If i remove the call to mail() the success php code is displayed. As such, I can only assume that the error involves my use of the mail function. Please see code below and help if you can! Thanks
Code: Select all
<?php
...
/*mail($_POSTї'newEmail'],"Your Password for the JavGuide Website",
$message, "From:elearnJava Webmaster <webmaster@realisedesign.co.uk>");*/
include("success.php");
endif;
?>
*THIS WORKS - NO MAIL SENT BUT NEXT PAGE LOADS OK*
Code: Select all
<?php
...
mail($_POSTї'newEmail'],"Your Password for the JavGuide Website",
$message, "From:elearnJava Webmaster <webmaster@realisedesign.co.uk>");
include("success.php");
endif;
?>
* THIS DOES NOT WORK - EMAIL IS SENT BUT NEXT PAGE DOES NOT LOAD _ BROWSER SIMPLY SAYS DONE*
Posted: Mon Jan 17, 2005 2:05 pm
by feyd
first off what does success.php look like? Second make sure the following is in the code (at the top of the file)
Code: Select all
error_reporting(E_ALL);
ini_set('display_errors', '1');
Posted: Mon Jan 17, 2005 2:11 pm
by ast3r3x
While we are on the topic, I never get errors. I'm not saying I am that good, but I mean even if I mess up my code, I don't get an error.
In my .ini I have
error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
display_errors = On
But nothing, am I missing anything?
Posted: Mon Jan 17, 2005 2:14 pm
by mmanders
I will give the contents of success.php if the following doesn't shed further light on the problem!
I receive the following error in both the following cases, where the mail function is uncommented and free to execute:
Fatal error: Maximum execution time of 30 seconds exceeded in C:\WWW\project\login\signup.php on line 221
If I use an include, the line number pointed to is the line of the include call.
If I write raw html as in:
Code: Select all
mail($_POSTї'newEmail'],"Your Password for the JavGuide Website",
$message, "From:elearnJava Webmaster <webmaster@realisedesign.co.uk>");
/*include("success.php"); commented out for raw html below*/
?>
<html>
<body>
success
</body>
</html>
<?php
endif;
?>
then the line number points to the <?php open bracket directly below </html>
Posted: Mon Jan 17, 2005 2:15 pm
by mmanders
However, if the mail call is commented out - then either the raw html or the include is displayed successfully
Posted: Mon Jan 17, 2005 2:25 pm
by feyd
ast3r3x, E_ALL for the error reporting line.
mmanders, seems very strange indeed..It sounds like you are using a loop around that section... is this true?
Posted: Mon Jan 17, 2005 2:35 pm
by mmanders
No loop as far as I am aware... When i try replying with full code listings i can only assume that the size of the message is too large as i get a http error - so if you want to see all the code you can - le tme know and i can put it on www as txt files!?
Posted: Mon Jan 17, 2005 2:37 pm
by feyd
the server error comes from something in your code not being kosher with the server.. such as: INSERT INTO, DELETE FROM, Perl, .htaccess, there are others..
Posted: Mon Jan 17, 2005 2:43 pm
by mmanders
My SQL seems ok as all the data is being input to the db without error.
I am testing on a local server so have no htaccess setup.
The php code for signup.php (the file with the mail call) can be found at
http://www.macs.hw.ac.uk/~ceemrm1/signup.txt
The code for success.php can be found at
http://www.macs.hw.ac.uk/~ceemrm1/success.txt
This last file is parsed as HTML so you may need to view source to see
the code!
Posted: Mon Jan 17, 2005 2:58 pm
by mmanders
also - increasing the timeout interval in php.ini for executing scripts to some very long time does not have any effect
Posted: Mon Jan 17, 2005 3:02 pm
by feyd
what effect does moving the include call before the mail() call have? What about hardcoding the code that'd normally be included?
Posted: Mon Jan 17, 2005 3:09 pm
by mmanders
i have hardcoded the code that would be included in place of the include function (noting to use opening and closing php tags where appropriate to parse the code as html and not php) with no effect.
If I move the include above the mail function the desired include page does load as hoped - but i still get the error I mentioned before
Posted: Mon Jan 17, 2005 3:20 pm
by mmanders
BINGO!!!!! Kind of
This didn't occur to me until I took a cigarette and coffee break...
I turned off my firewall and low and behold - it worked!
This is out of your remit I know - but do you know what settings may need to be modified in order to send mail from php with a firewall enabled?
Thanks
Posted: Mon Jan 17, 2005 3:27 pm
by feyd
best to allow port 25 to go out, I think...