The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP mail problem

Discussion in 'E-mail Discussions' started by hamper, Sep 14, 2006.

  1. hamper

    hamper Well-Known Member

    Joined:
    Apr 28, 2006
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
    hello folks,

    I'm having a serious issue with email forms working using the PHP ()mail function on my box. I'm not even sure when it stopped working, but it just isn't working now and I need to find out why, which is what I need help with.

    I've posted a simple email form below that isn't working either. I get no errors back on the site after I submit, I cannot find any errors in any logs and there is no mails in queue on the server. I'm totally at a loss.

    I'm running:
    Apache version 1.3.37
    PHP version 4.4.4
    MySQL version 5.0.24-standard
    cPanel Build 10.9.0-CURRENT 4

    Code:
    <div>
    	<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
    		<p>Name:</p>
    		<input name="name" type="text" />
    		<p>Email:</p>
    		<input name="email" type="text" />
    		<p>Subject:</p>
    		<input name="subject" type="text" />
    		<p>Message:</p>
    		<textarea name="message" rows="6"></textarea>
    		<br />
    		<input type="submit" value="Send" /><input type="hidden" name="do" value="send" /><input type="reset" value="Reset" />
    	</form>
    </div>
    <?php
    
    if($_POST['do']=="send") {
    	$recipient="testing@ezwebsol.com"; // Set your email here //
    	$subject=$_POST['subject'];
    	$name=$_POST['name'];
    	$email=$_POST['email'];
    	$message=$_POST['message'];
    	$formsend=mail("$recipient", "$subject", "$message", "From: $name ($email)\r\nReply-to:$email");
    	echo("Your message was successfully sent!");
    }
    ?>
    So any help I would very much appreciate.

    hamper
     
    #1 hamper, Sep 14, 2006
    Last edited: Sep 14, 2006
  2. rsaylor

    rsaylor Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    160
    Likes Received:
    1
    Trophy Points:
    18
    do a search, I just answered same issue a couple of days ago.
     
  3. hamper

    hamper Well-Known Member

    Joined:
    Apr 28, 2006
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
    thanks,

    but that isn't my issue. my dns and hostname are correctly set.
    i can dig, nslookup and ping it just fine and it resolves.

    next?
     
  4. Dennisb1

    Dennisb1 Active Member

    Joined:
    Aug 16, 2006
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    The Netherlands
    its with php security
    open php.ini and look for a line
    Code:
    register_globals
    And make sure its turned on! when its off you cant send mail with php
    Php have register_globals a while ago turned off in there new installations read at:
    www.php.net/register_globals

    Good luck ;)
     
  5. rsaylor

    rsaylor Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    160
    Likes Received:
    1
    Trophy Points:
    18
    what does /var/log/exim_mainlog state?

    tail -f /var/log/exim_mainlog

    Try sending an email, what error do you get? Have you also tried re-compiling php?
     
  6. hamper

    hamper Well-Known Member

    Joined:
    Apr 28, 2006
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
    Hi,

    Well the register_globals were turned off so I turned them on and restarted apache and still no difference in getting mail from a form script.

    as to the other question..

    Code:
    blah@george [/home/clancy]# tail -f /var/log/exim_mainlog
    2006-09-15 07:20:04 1GOBjn-0007Nk-Li => username <support@domain.com> R=virtual_user T=virtual_userdelivery
    2006-09-15 07:20:04 1GOBjn-0007Nk-Li Completed
    2006-09-15 08:02:44 Start queue run: pid=1985
    2006-09-15 08:02:44 End queue run: pid=1985
    2006-09-15 09:02:44 Start queue run: pid=10611
    2006-09-15 09:02:44 End queue run: pid=10611
    2006-09-15 10:02:44 Start queue run: pid=19343
    2006-09-15 10:02:44 End queue run: pid=19343
    2006-09-15 11:02:44 Start queue run: pid=27979
    2006-09-15 11:02:44 End queue run: pid=27979   
    I've changed certain points, but this is what the output was.
    It seems everything ran and finished fine.

    I'm just really confused as to what the problem is. Anyone?
     
  7. gflamerich

    gflamerich Well-Known Member

    Joined:
    Jul 21, 2003
    Messages:
    122
    Likes Received:
    0
    Trophy Points:
    16
    Register globals hasn't anything to do with your problem,
    you are not using register globals ($_SERVER['PHP_SELF'], $_POST['do'], etc.. )
    I recomend you to turn it back to off, because in furute php releases register globals will be totally removed.

    On the other hand.
    As far I can see, you don't have phpsuexec, if so, mails are sent by nobody. So go to:
    WHM ->Tweak Settings where you can find:

    Prevent the user "nobody" from sending out mail to remote addresses (PHP and CGI scripts generally run as nobody if you are not using PHPSuexec and Suexec respectively.)

    If that box is checked, thats the reason of why emails are not being delivered.
     
  8. Anishts

    Anishts Active Member

    Joined:
    Oct 6, 2005
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    Hi

    hello,

    try that script in shell prompt and see what it is saying....

    # php scriptname.php and also tail the mail log same time in a different shelll
     
  9. hamper

    hamper Well-Known Member

    Joined:
    Apr 28, 2006
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
    Hi,

    where would I check to see if I am running phpsuexec?

    I checked the logs again, and nothing again.

    I checked the settings and no the box wasn't checked.

    I'm really at a loss here. Thinking about it, I tried to
    setup and run the postwwwacct script and I cannot get
    an email back from it either.

    Could it be something with my firewall?

    Thanks again.. anything else you can think of.
     
  10. hamper

    hamper Well-Known Member

    Joined:
    Apr 28, 2006
    Messages:
    85
    Likes Received:
    0
    Trophy Points:
    6
    PROBLEM FIXED

    I followed the suggestion of:

    deleted the /etc/eximmailtrap file
    changed /var/cpanel/cpanel.config to make eximmailtrap=0

    and this solved the problem.

    thanks to everyone for your suggestions.

    now I'm off to try to install PHP5 :)
     
Loading...

Share This Page