Showing results for 
Show  only  | Search instead for 
Did you mean: 
Go to solution
Getting Started

Contact form not sending email

I used the contact form application from GoDaddy and installed it.  I can get it to execute successfully, however I never get an email.  The link is /


Thanks for the help!  Colleen


Here is the code:

    $name        = $_POST['name'];
    $email        = $_POST['email'];
    $message    = $_POST['msg'];

    if ( ( !$email ) ||
         ( strlen($_POST['email']) > 200 ) ||
         ( !preg_match("#^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$#", $email) )
        print "Error: Invalid E-Mail Address";
    if ( ( !$name ) ||
         ( strlen($name) > 100 ) ||
         ( preg_match("/[:=@\<\>]/", $name) )
        print "Error: Invalid Name";
    if ( preg_match("#cc:#i", $message, $matches) )
        print "Error: Found Invalid Header Field";
    if ( !$message )
        print "Error: No Message";
    if (eregi("\r",$email) || eregi("\n",$email)){
        print "Error: Invalid E-Mail Address";
    if (FALSE) {
        print "Error: You cannot send to an email address on the same domain.";

    $headers    = "Content-Type: text/plain; charset=iso-8859-1\n";
    $headers    .= "From: $name <$email>\n";
    $recipient    = "";
    $subject    = "Contact From Avitus Press";
    $message    = wordwrap($message, 1024);

    mail($recipient, $subject, $message, $headers);

    header("location: thankyou.htm");

Getting Started

If you're still having trouble, try this:


I was able to solve my issue, so I'll share what I did. If you use the Office365 email account purchased with your domain, and you want the php in your code to send emails to that address via a form, then you have to make sure the MX entry on the domain server matches the MX entry in on the hosting server. Here's what you do:


1. Login to your GoDadday account, and click on "My Products"

2. Find your target domain and click on the "DNS" button

3. Scroll down until you see the entry row for "MX" and find the "Value" column

4. Copy this part of the entry to your clipboard. (should be some kind of web address)

5. Open a new tab and login to cpanel (...yourdomain/cpanel)

6. Scroll to the bottom to find the "Email" section. Click "MX Entry"

7. Make sure "Remote Mail Exchanger" radio button is selected. If not, select it and click change. (*** This is important before changing the MX entry***)

8. At the bottom,under "MX Records", click edit (or add a new one if it doesn't already exist).

9. Replace the "Destination" by pasting what you copied from the GoDaddy DNS manager.

10. Click "Edit". Now you're done.


The "MX record" should now match whatever was in the "Value" column of the MX entry from the DNS manager, and your form should work. I would imagine the same thing would work for any remote email server (e.g. Google), as long as the MX entries match. I hope this helps the rest of you who still can't get the email form on your site to work. 

View solution in original post


Hey Colleen,

Can you clarify which specific application you acquired this contact form from? Reviewing the code you provided I noticed your script was specifying an email address at If you're using cPanel, then that means you're likely not using local mail exchange to send out the message. In which case, you'll want to check your cPanel MX settings to be sure mail is set to "remote" instead of "local".


Would any of our members more familiar with scripting like to offer more insight on what else may be preventing submissions from being mailed out?

CG - GoDaddy | Community Moderator
24/7 support available at

I found a contact form at (not It specifies ./perl-script/request.cgi as the form action.  The pasted code in your forum post is PHP (note the <?php in the first line) so the form action should specify a page ending with .php.


Try creating a page called sendform.php and put it in the root folder.  Put the PHP code you posted into it and replace the form's action with "sendform.php".


In addition, the form handling script is looking for a $_POST variable called name but the posted form field is Name so change

$name        = $_POST['name'];


$name        = $_POST['Name'];

Also, the form handling script is looking for a $_POST variable called email but the posted form field is Email so change

$email        = $_POST['email'];


$email        = $_POST['Email'];

and the form handler is looking for a posted variable called msg but the posted form field is called Message so change 

$message    = $_POST['msg'];


$message    = $_POST['Message'];

the logic in the later parts of the script will then have some data to play with.

Do these things and test it out, let us know if it works out or what does happen.




Keep on Coding!
Mark Cicchetti - There are 10 kinds of people... those who understand binary and those who don't.
Getting Started

The php code for the Contact Us is a script from GoDaddy.  Thank you for your replies.  I understand a little better what I needed to change.  I am able to send an email to a GoDaddy account with the php code.  If I want to send that same email to something other than a GoDaddy account how is that done? 


I am not very familiar with the 'MX' settings. 


Thanks again for the assistance.

Hi @MaryBaker,

Can you share an example of how you were able to send email to a GoDaddy account? All of my attempts at using PHP mail() result in TRUE (success on the send) but no email ever arrives in my account.



Hi everyone,


I have been pulling out my hair to get this contact form successfully send email out... 


So I have tried to echo-ing out the result of mail() and it returns true... but I never got the email.


Our company uses google apps for the email and I have changed the MX ENTRY according to google docs and not receiving the email on gmail.


Anyone has any success on this?

Now all you need to do is to "route a domain's incoming mail to a specific server"

It is very easy, all you need to do is to change MX Entry in cpanel.

Form local to "remote". 



Where are the cpanel MX settings located?  


I know where the domain - manage dns is located, but in the domain manage dns settings, remote or local do  not appear. 


Can you please provide further explanation?  

My client is using Office 365 and wasn't getting the emails.  Changing the MX setting to remote fixed my issue. Thanks!!!

Do you have an example?

Getting Started

I created more than 10 web sites for my clients, I can say - generating an email by click of Submit input type is tricky and especially for Go Daddy one has to tweak the code to get it working. I got the form working on asp, and it works like a charm.

Here is the process flow that needs to be followed if the code is written in ASP.

1. Create the form. You can use GET method when clicking the Input type=Submit

2. Create a java script validation for the form, Success is in how you validate and if validation fails you get back to the form page maintaining its state

3. Create a Processing page

3a. Once validated, pass the FORM values to the processing page

4. The processing page can catch the variables using request.querystring (in case of GET form method) or request.form (in case of POST form method) 

5. This is where you create the CDO.Message object. I used Microsoft libraries (sendusing and smtpserver) to make my life easier while my object references these included libraries. 

6. Parse your algorithm so you organize the construct of your email

7. check logic for proper creation of the email and put email body in HTML or plain text format

8. This logic has to be doing two steps:

8a. SERVER ACTIONS - Parse the email and send the email on success. OR

8b. CLIENT NOTIFICATION - Get the client to know there was a failure and client has to use alternate method to contact OR the Email was generated and sent out successfully.

Hope this guidance helps.



as a point of reference one could reference to this article


Very useful article, keep it on godaddy

Helper I

Hi Mary. I am Susan Marie CASSADY Neuhart.


I copied the HTML source code from the local television station's CONTACT form. I live in Columbus, Ohio. NBC is one of our "local" tv stations. You can find my web site using GOOGLE terms = Susan Marie Cassady Zora


I saved the copied source code file as HTML type. 
I see - using the cPanel NEW file creator - that I may also save the file as type = PHP.

So, Mary, let's keep going and see if we can "figure this out" together.  My LINUX economy HTML editor - offers me the following options - when I select the FORM icon.

Form Properties
Method GET Post


Godaddy Form Properties Name Action Id Encoding Target Method GET Post



 And, finally - My husband's form (hosted by another company) SEE: Hans Neuhart - has ALSO stopped sending E-mails. WHEN I can - I am going to get him to switch to GO-Daddy web-hosting. I AM A VERY SERIOUS "GODADDY" FAN > And, maybe, just like Ms. DaniCa Patrick - Maybe ALL Irish (mixed ethnic heritage) girls are GOdaddy fans.



My school is  hosting a site on Godaddy, and we use Machform for student applications. The form isn't sending confirmation emails. I have tried several SMTP servers, but continue to get the same error:


Warning: stream_socket_client(): unable to connect to tls:// (Connection refused) in /home/content/81/8477781/html/machform/lib/swift-mailer/classes/Swift/Transport/StreamBuffer.php on line 271 Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host [Connection refused #111]' in /home/content/81/8477781/html/machform/lib/swift-mailer/classes/Swift/Transport/StreamBuffer.php:273 Stack trace: #0 /home/content/81/8477781/html/machform/lib/swift-mailer/classes/Swift/Transport/StreamBuffer.php(66): Swift_Transport_StreamBuffer->_establishSocketConnection() #1 /home/content/81/8477781/html/machform/lib/swift-mailer/classes/Swift/Transport/AbstractSmtpTransport.php(116): Swift_Transport_StreamBuffer->initialize(Array) #2 /home/content/81/8477781/html/machform/lib/swift-mailer/classes/Swift/Mailer.php(79): Swift_Transport_AbstractSmtpTransport->start() #3 /home/content/81/8477781/html/machform/includes/helper-functions.php(759): Swift_Mailer->send(Object(Swift_Message)) #4 /home/content/81/8477781/html/machform/includes/post-functions.php(2688): mf_send_notification(Object(PDO), 13726, 210, '{element_14}', Array) #5 /home/content/81/84777 in /home/content/81/8477781/html/machform/lib/swift-mailer/classes/Swift/Transport/StreamBuffer.php on line 273


Some  Googling has suggested that outgoing connections on certain ports aren't allowed. I don't have much technical knowledge about this at all, so I'm not sure if it's a problem with the Machform script, or if it's something on the Godaddy side that I need to address.


How can I track down the cause of this?



Im trying to create a contact form using php.


However,  I cannot find "webformmail.php"  or "gdform.php" under my root directory after clicking Manage my hosting account.


Also, I cannot find "Form Mail" icon anywhere.


Where is it??

Hello @xinyi


The  "Form Mail" , "webformmail.php" and "gdform.php" ou are talking are available only under the old Web Hosting Linux plan.

You will not find them under the new Linux Hosting with cPanel plan.


Sorry to bring you such bad news.

I hope you will survive.


***Signature: -> Do not assume anything! If you want help, explain your problem. If my post helped you, give it a Kudo. If you have the solution, mark the topic as Solved.

I have been trying to make a website work off a cgi file since November. Talked with several techs. No one told me that formmail would not work.  


Looking for the correct entry in this formmail script:

$mailprog = '/usr/lib/sendmail -i -t';


Enter a number of parts. Go to view cart entries, fill out the form (I put test in the comments section) and select Send query... get a 500 Internal Server Error??

I have been trying to make a website work off a cgi file since November. Talked with several techs. No one told me that formmail would not work.  


Looking for the correct entry in this formmail script:

$mailprog = '/usr/lib/sendmail -i -t';


Enter a number of parts. Go to view cart entries, fill out the form (I put test in the comments section) and select Send query... get a 500 Internal Server Error??

Is there not an alternative section to set up an contact form then?


I'm looking to set up my contact form on my website? 

Help guides and tutorials on here seem to be out of date. 

It seems that everything is not working which Go Daddy never told me when they switched me over to C-Panel. Two people sent me to this link which is useless. Time to start shopping for a new web host who will be more helpful!