PHP Mail() problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mmanders
Forum Newbie
Posts: 23
Joined: Sun Jan 16, 2005 7:13 pm

PHP Mail() problem

Post 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&#1111;'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&#1111;'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*
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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');
ast3r3x
Forum Commoner
Posts: 95
Joined: Thu Aug 19, 2004 8:36 pm

Post 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?
mmanders
Forum Newbie
Posts: 23
Joined: Sun Jan 16, 2005 7:13 pm

Post 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&#1111;'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>
mmanders
Forum Newbie
Posts: 23
Joined: Sun Jan 16, 2005 7:13 pm

Post by mmanders »

However, if the mail call is commented out - then either the raw html or the include is displayed successfully
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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?
mmanders
Forum Newbie
Posts: 23
Joined: Sun Jan 16, 2005 7:13 pm

Post 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!?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
mmanders
Forum Newbie
Posts: 23
Joined: Sun Jan 16, 2005 7:13 pm

Post 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!
mmanders
Forum Newbie
Posts: 23
Joined: Sun Jan 16, 2005 7:13 pm

Post by mmanders »

also - increasing the timeout interval in php.ini for executing scripts to some very long time does not have any effect
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

what effect does moving the include call before the mail() call have? What about hardcoding the code that'd normally be included?
mmanders
Forum Newbie
Posts: 23
Joined: Sun Jan 16, 2005 7:13 pm

Post 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
mmanders
Forum Newbie
Posts: 23
Joined: Sun Jan 16, 2005 7:13 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

best to allow port 25 to go out, I think...
Post Reply