Community Forums
Connect with us on LinkedIn
Community Notice
+ Reply to Thread
Results 1 to 13 of 13
  1. #1
    nsz
    nsz is offline
    Member
    Join Date
    Apr 2004
    Posts
    49

    Default Email PHP form

    I just moved to a new server with Cpanel, I had a php form that e-mails from the server but now it does not. Any idea what has changed that would send out blank emails?

    Thanks,

    If it helps here is the script



    <?php

    //Declare the variables
    $recipient = "emailtosendto@domain.com";
    $subject = "Form";
    $message = "Name: $firstname\nCompany Name: $companyname\nStreet Address: $streetaddy\nCity: $city\nState: $state\nZip Code: $zipcode\nPhone Number: $phonenumber\nFax Number: $faxnumber\nE-mail Address: $email\n\nInformation about property to be appraised (subject property):\n\nBorrower/Owners Name: $ownername\nSubject Address: $subjectaddress\nSubject City: $selectcity\nSubject State: $subjectstate\nSubject Zip Code: $subjectzipcode\nSales Price: $salesprice\nEstimated Value: $estvalue\nLoan Amount: $loanamnt\nProperty Type: $propertytype\nPurpose of Appraisal: $purposeappr\nFormat Needed: $formatneeded\nContact for Access: $contactaccess\nPhone Work: $phonedw\nPhone Home: $phonehome\n\n\nComments: $comments";

    //mail() function sends the mail
    mail($recipient,$subject,$message,"From: $email");


    //Contents of form
    $firstname=$_POST['firstname'];
    $companyname=$_POST['companyname'];
    $streetaddy=$_POST['streetaddy'];
    $city=$_POST['city'];
    $state=$_POST['state'];
    $zipcode=$_POST['zipcode'];
    $phonenumber=$POST['phonenumber'];
    $faxnumber=$_POST['faxnumber'];
    $email=$_POST['email'];
    $ownername=$_POST['ownername'];
    $subjectaddress=$_POST['subjectaddress'];
    $selectcity=$_POST['selectcity'];
    $subjectstate=$_POST['subjectstate'];
    $subjectzipcode=$_POST['subjectzipcode'];
    $salesprice=$_POST['salesprice'] ;
    $estvalue=$_POST['estvalue'];
    $loanamnt=$_POST['loanamnt'];
    $propertytype=$_POST['propertytype'];
    $purposeappr=$_POST['purposeappr'];
    $formatneeded=$_POST['formatneeded'];
    $contactaccess=$_POST['contactaccess'];
    $phonedw=$_POST['phonedw'];
    $phonehome=$_POST['phonehome'];
    $comments=$_POST['comments'];

  2. #2
    Member
    Join Date
    Jan 2005
    Location
    /dev/null
    Posts
    770

    Default

    looks as if register_globals is off on the new server, move the message variable and mail command below the $_POST definitions and it will work.

    You will also want to properly clean the strings before emailing them, as the above code is vulnerable to spammers
    Last edited by nickp666; 12-01-2006 at 05:24 AM. Reason: Didnt read the script properly

  3. #3
    nsz
    nsz is offline
    Member
    Join Date
    Apr 2004
    Posts
    49

    Default

    That worked! Thanks so much.

  4. #4
    Member ullalla's Avatar
    Join Date
    Jan 2006
    Posts
    192

    Default

    Mine script is as then whats wrong with it : I am facing the same issue


    <?php
    $to = "frreehost@gmail.com";
    $fromname = "test@mydomian.com";
    $subject = "Testing EMail";
    $mailheaders ="From: test <test@mydomain.com> \n";
    $msg = "This is a test message from Sushil.\n";
    mail($to, $subject, $msg, $mailheaders);
    echo "Done!";
    ?>

  5. #5
    Member
    Join Date
    Jan 2005
    Location
    /dev/null
    Posts
    770

    Default

    that code should work fine, if your server isnt running phpsuexec please check that you dont have 'prevent user nobody from sending email' option in WHM > tweak settings enabled

    EDIT: in fact, have you actually checked the exim log to ensure the mail was delivered? could be in your gmail junk folder or you could even be blacklisted by gmail, change the address to another domain and see if it arrives
    Last edited by nickp666; 12-18-2006 at 07:42 AM. Reason: Further Thought.

  6. #6
    Member
    Join Date
    Jan 2005
    Location
    /dev/null
    Posts
    770

    Default

    that code should work fine, if your server isnt running phpsuexec please check that you dont have 'prevent user nobody from sending email' option in WHM > tweak settings enabled
    Did you check that? do you have any software that may be limiting outgoing sending to certain binaries only (CSF has this option as do a couple of other things), Do you have the 'SMTP Tweak' option enabled in WHM?

  7. #7
    Member ullalla's Avatar
    Join Date
    Jan 2006
    Posts
    192

    Default

    Hello Nick,

    Thanks for your quick attention on this but I have tried this for yahoo too. And when I sent a test mail from this domain to yahoo and gmail therough webmail then it goes fine.

    Please let me know if you have any info abt this.

    Thanks.

  8. #8
    Member ullalla's Avatar
    Join Date
    Jan 2006
    Posts
    192

    Default

    but when I used the email account which is on the same domain then it works . only problem for gmail and yahoo

  9. #9
    Member
    Join Date
    Jan 2005
    Location
    /dev/null
    Posts
    770

    Default

    See reply above, yet again posted in the wrong order!

  10. #10
    Member
    Join Date
    Jan 2005
    Location
    /dev/null
    Posts
    770

    Default

    Quote Originally Posted by SageBrian View Post
    the formmail script may only allow mail to be sent to an account on your domain.

    If you need it to go to a yahoo or gmail account (or anywhere off the server), setup a forward for an email like form@domain.com to go to the gmail
    You are indeed correct with regard to the formmailer located in /cgi-sys/ but this is a custom php script that isnt sending.

  11. #11
    Member SageBrian's Avatar
    Join Date
    Jun 2002
    Location
    NY/CT (US)
    Posts
    386

    Default

    the formmail script may only allow mail to be sent to an account on your domain.

    If you need it to go to a yahoo or gmail account (or anywhere off the server), setup a forward for an email like form@domain.com to go to the gmail

  12. #12
    Member serversphere's Avatar
    Join Date
    Jan 2004
    Posts
    658

    Default

    Quote Originally Posted by SageBrian View Post
    the formmail script may only allow mail to be sent to an account on your domain.

    If you need it to go to a yahoo or gmail account (or anywhere off the server), setup a forward for an email like form@domain.com to go to the gmail
    I think you are thinking of the CGI Formmail script perhaps? Not true of PHP customer mailers.

    If you use a local domain and it works then you need to check your /var/log/maillog and /var/log/exim_mainlog log files to see why it is failing for others. Perhaps that domain is listed on an RBL, or you have an SPF set up incorrectly, or DNS isn't working... multitude of possibilities...
    Darren Benfer | SS-Darren | AIM: serversphere
    www.serversphere.com
    Dedicated Server Solutions Have Come Full Circle

  13. #13
    Member ullalla's Avatar
    Join Date
    Jan 2006
    Posts
    192

    Default

    Hello,

    Thanks for your replies guys , I will check for all possibilites.

    Thanks.

Similar Threads & Tags
Similar threads

  1. PHP and Email Form Issue
    By fkgddy in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 08-24-2011, 04:56 PM
  2. php form
    By Zion Ahead in forum New User Questions
    Replies: 12
    Last Post: 04-24-2007, 07:36 AM
  3. PHP form mail not being transmitted in PHP 5.0.4
    By jdebois99 in forum New User Questions
    Replies: 3
    Last Post: 09-07-2006, 09:31 AM
  4. Setting Up Email thru Web Email Form
    By simplymagick in forum E-mail Discussions
    Replies: 2
    Last Post: 12-16-2005, 09:05 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube