fullspec

Member
Apr 8, 2011
5
0
51
I am a new website designer. I have always been into Computers and liked working with them. I got a job at local Computer Repair store (- Removed - ) about three years ago. After about 6 months working there the Owner told me I should learn how to build websites because he often had people inquiring about who could do one for them. I live in a small town and there is no one else in the area who offers this service. So I Learned (from Google &W3C Schools) HTML, CSS, and some JavaScript. I have done over 20 sites to date and am getting more and more work as time goes on.

I have been using a Go Daddy Shared Hosting account the entire time. I have recently became very unhappy with Go Daddy's performance and reliability. I was contacted by viaVerio and after three months of giving them the run-around, I decided to join their "Partner Program" and purchased a WHM VPS with cPanel for $38 per month.

I know that this is a huge jump for me as far as the technical knowledge, but I also know that this is something I need to do to allow for future growth and customer satisfaction.

I have managed to get all of my currently hosted websites moved from the Go Daddy's Server to the new VPS and all the sites are up and running. I am only having one problem, but it is quite a big deal. None of the websites "Contact Us" email forms are working.
This site ( /http://example.com/contact ) is still on the Go Daddy account and the email form works correctly.
These sites ( /http://domain.org & /http://domaintoo.org) are on the cPanel VPS and appears to be working, but they are not sending out the emails. I have checked the "Mail Queue Manager" and there it says "There are currently 0 messages in the mail queue."
This site, ( /Example Domain ) and all others on the cPanel VPS come back with simply "error" when trying to use them.

I am not sure but I think that there is something I need to do on the server to fix this. The reason I think this is because if you leave the email field blank and try to submit it come back with the correct "Invalid Email Address Entered" error.

I will provide the HTML and PHP used for all sites (except the domain.org)
Please forgive my very limited knowledge. I am however very eager to learn all that I can.
Thank You in advance for your time spent helping me with this problem.

Code:
                    <!--HTML FOR FORM-->

<h4>Please fill out the following form and we will be in touch with you soon.</h4>
<form action="contact.php" method="post" id="contactform">
  <ol>
    <li>
      <label for="name">Your Name <span class="red">*</span></label>
      <input id="name" name="name" class="text" />
    </li>
    <li>
      <label for="email">Your email <span class="red">*</span></label>
      <input id="email" name="email" class="text" />
    </li>
    <li>
      <label for="subject">Subject</label>
      <input id="subject" name="subject" class="text" />
    </li>
    <li>
      <label for="message">Message <span class="red">*</span></label>
      <textarea id="message" name="message" rows="6" cols="50"></textarea>
    </li>
    <li class="buttons">
      <input type="image" name="imageField" id="imageField" src="#" class="send" />
      <div class="clr"></div>
    </li>
  </ol>
</form>

                    <!--CONTACT.PHP FILE CONTENTS-->

<?php

if(!$_POST) exit;

$email = $_POST['email'];


//$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
    $error.="Invalid email address entered";
    $errors=1;
}
if($errors==1) echo $error;
else{
    $values = array ('name','email','message');
    $required = array('name','email','message');
   
    $your_email = "[email protected]";
    $email_subject = "New Message: ".$_POST['subject'];
    $email_content = "new message:\n";
  
    foreach($values as $key => $value){
      if(in_array($value,$required)){
        if ($key != 'subject' && $key != 'company') {
          if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
        }
        $email_content .= $value.': '.$_POST[$value]."\n";
      }
    }
   
    if(@mail($your_email,$email_subject,$email_content)) {
        echo 'Message sent!';
    } else {
        echo 'ERROR!';
    }
}
?>
 
Last edited by a moderator:

fullspec

Member
Apr 8, 2011
5
0
51
Thanks but I really like this email form, and am hoping someone can offer suggestions on how to fix the forms I am using now / Cpanel VPS settings. I really like this form and how it works feel free to tryout this website's form (/http://example.com/contact.html). This site is still on the Go Daddy server and form is working correctly. I have the form sending to a email address that I monitor with Outlook. So if you don't mind just enter "cPanel Forum" in the Subject Line. And you can just put in a bogus email (eg: - Removed -) if you don't want to share it with me.
Again, Thank You in advance for your time spent helping me with this problem.
I really like how the page is not reloaded or redirected to a success page; The form slides up and disappears,bringing the content from below it up in-place of the Form and displays the message (eg: Message Sent!!! or Invalid Email entered) directly above. The main thing Is you never leave the page, even if you just click Submit without filling anything in.
I really think that it has to be something relatively & easy to fix but I have no Idea what to check or how or what to troubleshoot to find out what is going on.
My Thoughts are that is may be something, or something related to:
1) Security setting, blocking the contact.php from send the email from sending the email.
2) Or possibly a small change needs to be made to the contact.php file ( The Go Daddy Server was running PHP v4.X - The new WHM VPS with cPanel) is running PHP 5 ) I have done a lot of research and found a substantial number people having trouble with various email related .php files on PHP 5 where they were working fine on PHP 4.X
 
Last edited by a moderator:

LinuxTechie

Well-Known Member
Jan 22, 2011
502
14
68
cPanel Access Level
Root Administrator
Hello,

Can you please check whether php mail function is enabled in the vps

php -m | grep mail

If that's not the issue, i.e. they are legitimate emails being sent out by PHP script, then it may well be that you have enabled the option WHM > Tweak Settings > Prevent the user "nobody" from sending out mail to remote addresses. That will obviously prevent those emails being sent and they will bounce back.
 
Last edited:

Infopro

Well-Known Member
May 20, 2003
17,075
524
613
Pennsylvania
cPanel Access Level
Root Administrator
Twitter
I really like how the page is not reloaded or redirected to a success page; The form slides up and disappears,bringing the content from below it up in-place of the Form and displays the message (eg: Message Sent!!! or Invalid Email entered) directly above. The main thing Is you never leave the page, even if you just click Submit without filling anything in.
The code that is doing that is not posted above, the page itself is using jquery it appears. This is also from the same page.

Code:
<script type="text/javascript"> 
// <![CDATA[
jQuery(document).ready(function(){
	$('#contactform').submit(function(){				  
		var action = $(this).attr('action');
		$.post(action, { 
			name: $('#name').val(),
			email: $('#email').val(),
			subject: $('#subject').val(),
			message: $('#message').val()
		},
			function(data){
				$('#contactform #submit').attr('disabled','');
				$('.response').remove();
				$('#contactform').before('<p class="response">'+data+'</p>');
				$('.response').slideDown();
				if(data=='Message sent!') $('#contactform').slideUp();
			}
		); 
		return false;
	});
});
// ]]>
</script>

You might want to check wherever you got the contact form code for support with this.



The new WHM VPS with cPanel) is running PHP 5
What version exactly?
 

fullspec

Member
Apr 8, 2011
5
0
51
First Thanks for you help.
I will do that ASAP, and post back whatever I am able to find out.
I remember running in to someone offering that for a possible solution on a forum to a user having similar results. But he did not give the path to find that section in WHM, and I was unable to find it by searching arround ( But I am very new to this and tend to overlook things ofter. So thanks again for including how I can get there.
Another question if I may... Is there anything else on Go Daddy's end I possibly need to do, besides changing the name servers ? I was thinking that maybe I will need to change some Mail-server settings in Go Daddy's Domain Manager as well before I will be able to setup the new VPS cPanel to takeover the email handling for the domains.

As always thank you very much for your help and the time you have taken to help me with my problem.
I have always believed that "What goes around, Comes around." I am sure you will be rewarded in the future for the things you have done for other people.

PS: I have created a webpage (example.com/contact_code.html ) on my website that has all of the code used for the contact form, with the exception but I didn't think that that would be necessary. But if you do need to look at it you can find that file here: example.com/js/jquery.js

Best Regards,
 
Last edited by a moderator:

fullspec

Member
Apr 8, 2011
5
0
51
Hi Infropro, and thank you for taking the interest to help me with my problem.

You might want to check wherever you got the contact form code for support with this.
I wish that was an option :( and I could very well be wrong but I really this that the problem is related to Something not set right or not enabled on the server. If the form seems to be functioning correctly. It is such a simple .php file it just seems that it would be unlikely that the problem is with it.
I am not sure exactly what version of PHP 5 the VPS has installed but I will try to find out and post back with the answer to that question ASAP. Also you are correct I did not include the JavaScript in the first post but I have all of the code available on a web page I built last night ( /example.com/contact_code.html), in addition to that here is a link to the jQuery file as well ( /example.com/js/jquery.js )

Thank You in advance for your time spent helping me with this problem.
 
Last edited by a moderator:

Infopro

Well-Known Member
May 20, 2003
17,075
524
613
Pennsylvania
cPanel Access Level
Root Administrator
Twitter
If you login to your cPanel and look down the left side menu you'll see an item that says:

PHP version

Whats it say to the right of that?

I can't help you at all here with the contact form script. Other than to mention that security for contact forms should be considered as they will be attacked at some point by someone.
 

fullspec

Member
Apr 8, 2011
5
0
51
I have PHP version 5.2.9
I also noticed this Server Name - a0000001, I believe I am supposed to change this to something else but I have no idea what.
Under Basic cPanel & WHM Setup the nameservers are set to:
Nameserver 1= ns1.a0000001.servername.com
Nameserver 2= ns1.a0000001.servername.com
Nameserver 3= blank
Nameserver 4= blank

I have done a lot of research on the internet and from what I have learned I should have a php.ini file somewhere but I have looked through the entire root and there is not one there, except the ones I copied over from Go Daddy. I looked at the ones I got from Go Daddy and I am sure that they I pointing to the wrong Mailserver & or "email.php handler".
I think I am getting a better understanding of why the forms dont work but I am also readin, One place says I need to install Smartmail, Another Place says that cPanel uses Exim "Sending mail using the PHP mail() function or a script configured for sendmail requires modification of the php.ini file and a setting in WHM. The reason for this is that CPanel uses Exim as the mail server instead of Sendmail"
One thing is for sure... I do have PHP installed, but I cannot seem to find the php.ini file anywhere.

I have gone to Configure PHP and SuExec - and this is the contents of the Generated php.conf it made after clicking Save and making no changes.
php.conf updated to:

This file was automatically generated by the Cpanel PHP Configuration system


# If you wish to change the way PHP is being handled by Apache on your system,
# use the /usr/local/cpanel/bin/rebuild_phpconf script or the WHM interface.
#
# Manual edits of this file will be lost when Apache is updated.


# SuPHP configuration for PHP5
LoadModule suphp_module modules/mod_suphp.so
suPHP_Engine on
AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml
<Directory />
suPHP_AddHandler application/x-httpd-php5
</Directory>

# End of autogenerated PHP configuration.


Updating user configurable PHP settings.
[info] recursion depth is set to: 2
Restarting Apache[/CODE]

But I have looked everywhere and can still not find a php.ini file. I also think that there are several more setting I will have to change to get the webmail working. But I dont know if there are