cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Go to solution
Highlighted

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 /http://www.avituspress.com/contact-us-php.htm.

 

Thanks for the help!  Colleen

 

Here is the code:

<?php
    // VALUES FROM THE FORM
    $name        = $_POST['name'];
    $email        = $_POST['email'];
    $message    = $_POST['msg'];

    // ERROR & SECURITY CHECKS
    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";
        exit;
    }
    if ( ( !$name ) ||
         ( strlen($name) > 100 ) ||
         ( preg_match("/[:=@\<\>]/", $name) )
       )
    {
        print "Error: Invalid Name";
        exit;
    }
    if ( preg_match("#cc:#i", $message, $matches) )
    {
        print "Error: Found Invalid Header Field";
        exit;
    }
    if ( !$message )
    {
        print "Error: No Message";
        exit;
    }
    if (eregi("\r",$email) || eregi("\n",$email)){
        print "Error: Invalid E-Mail Address";
        exit;
    }
    if (FALSE) {
        print "Error: You cannot send to an email address on the same domain.";
        exit;
    }


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

    // SEND THE EMAIL TO YOU
    mail($recipient, $subject, $message, $headers);

    // REDIRECT TO THE THANKS PAGE
    header("location: thankyou.htm");
?>

35 REPLIES 35
Moderator
Moderator

Re: Contact form not sending email

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 earthlink.net. 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 x.co/247support
Advocate V Advocate V
Advocate V

Re: Contact form not sending email

I found a contact form at http://www.avituspress.com/contact-us.htm (not http://www.avituspress.com/contact-us-php.htm). 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'];

to

$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'];

to

$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'];

to 

$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.

Re: Contact form not sending email

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.

Re: Contact form not sending email

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.

Regards,

Paul

Re: Contact form not sending email

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.

 

 

Re: Contact form not sending email

as a point of reference one could reference to this article

 

https://ca.godaddy.com/help/using-windows-hosting-form-mailers-512

 

Re: Contact form not sending email-CASSADY

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.

  (HTML or PHP) <<<<< THIS IS WHAT I CURRENTLY DO NOT KNOW. WHICH TO CHOOSE?
Form Properties
Name
Action
Id
Encoding
Target
Method GET Post

 

Godaddy Form Properties Name Action Id Encoding Target Method GET Post

 

AGAIN, LET'S TRY TO FIGURE THIS OUT - TOGETHER.  - SUSAN MARIE CASSADY ZORA

 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.

 

 

Unable to send email through any SMTP server using Machform

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://smtp.mail.XXXXX.com:465 (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 smtp.mail.XXXXX.com [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?

New

Re: Contact form not sending email

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?  

New

Where is "Form Mail" in Cpanel?

Hello,

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??

Helper VI
Helper VI

Re: Where is "Form Mail" in Cpanel?

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.

Smiley Happy

***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.

Re: Where is "Form Mail" in Cpanel?

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'; 

 

http://malpassinc.com/hotbunk.html

 

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??

Re: Where is "Form Mail" in Cpanel?

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'; 

 

http://malpassinc.com/hotbunk.html

 

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??

Re: Contact form not sending email

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 https://support.google.com/a/answer/33915?hl=en and not receiving the email on gmail.

 

Anyone has any success on this?

Re: Contact form not sending email

Very useful article, keep it on godaddy

Re: Contact form not sending email

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". 

 

 

Re: Contact form not sending email

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

Re: Where is "Form Mail" in Cpanel?

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. 

Re: Contact form not sending email

Do you have an example?

Re: Where is "Form Mail" in Cpanel?

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!

Re: Where is "Form Mail" in C panel?

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!

Re: Where is "Form Mail" in C panel?

Same here - been online with support for an hour!!

Cant believe there is no simple contact form solution for html with godaddy.

We have recently switched all our websites to them and none of our 30+ forms are working.

Solution

Re: Contact form not sending email

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. 

Re: Contact form not sending email

I know this is an old thread - just wanted to say I've been screwing with this for the better part of 2 days and king_sarge's answer worked like a champ for me!

Re: Where is "Form Mail" in C panel?

I think I figured this out. I believe you now have to go under CPanel Hosting then click on Applications. It's an application called "contact form." It creates a page with the form on it and from there you can edit the HTML. I don't know what you're supposed to do if you have existing forms though. It may be a painful process to update everything this way. 

Re: Where is "Form Mail" in C panel?

Actually I'm not sure if this is working now. Sorry. 

New

Form Mail Contact Us Page Not Working

We cannot get a formmail working at GoDaddy. We have been on the phone four times with four different people from different departments. Everytime we are told something different about what the problem may be.  

 

Some support staff we have spoken to tinker with the mx records, some tinker with the paths, but it is now obvious that no one is actually literate in how to set these up. We have just moved 12 sites over to GoDaddy and its frustrating that something so common in web design (a form action page) seems beyond the phone support staff.

 

Hopefully someone here can help us. The contact form is located at - 

 

http://www.austrac.com.au/contact-us.html

 

We just get an error 500 message. It was working on cpanel with the previous host. I've looked at the code but can't see anything wrong. Any ideas would be warmly welcomed. 

 

Thanks

 

Ray

 

Re: Contact form not sending email

Thank you for sharing the detailed Instructions.  These worked perfectly for my PHP contact form.    My domain had two MX records, so I added them both with priority 0 to give them high preference.  For the the original MX that came with Cpanel, I changed it priority to 10 to give it low preference.    

Re: Contact form not sending email

Also, be patient.  The email will deliver, but may take a minute or two if the interwebs are busy.


@KimmyAdmin wrote:

Thank you for sharing the detailed Instructions.  These worked perfectly for my PHP contact form.    My domain had two MX records, so I added them both with priority 0 to give them high preference.  For the the original MX that came with Cpanel, I changed it priority to 10 to give it low preference.    


 

Contact Us form does not send the email

For over some months now we have been unable to use the form to email features on our Delux Web hosting. All our website contact form pages are not sending email from the form to the specified email.
 
We cannot not use the "forgotten password" feature, where a user request for a reset password and an email link is send to the user box, this email are not sent out, our cronjob that require email being sent out are not also working.
 
We have been working with you for several years with no problem and quick response from live chat, but unfortunately your live chat is no longer available for speedy response, this make your services frustrating to us because we have also lost some sales as we could no longer cater for this features.
  
 
Thank You,
Anonymous
Not applicable

Re: Contact Us form does not send the email


@edwardkc wrote:
For over some months now we have been unable to use the form to email features on our Delux Web hosting. All our website contact form pages are not sending email from the form to the specified email.
 
We cannot not use the "forgotten password" feature, where a user request for a reset password and an email link is send to the user box, this email are not sent out, our cronjob that require email being sent out are not also working.
 
We have been working with you for several years with no problem and quick response from live chat, but unfortunately your live chat is no longer available for speedy response, this make your services frustrating to us because we have also lost some sales as we could no longer cater for this features.
  
 
Thank You,

Hi @edwardkc,

 

you say live chat is not available. Could you qualify what you mean there? Do you mean it’s there but nobody seems to be available, or, it’s just not there, period?

if the former, it’s because it’s the weekend and it’s only available Mon to Fri....

 

If you mean the latter then use a proxy server based in the USA or Europe to access it.... on Monday!

 

OR, you can easily phone any day of the week, any time at all.....

 

 

“Please don’t assume I work here just because I have a broom in my hands........”

Re: Contact form not sending email

HI,

 

This solutions worked great!

 

You have to make sure that the MX records on the cPanel are the same as the Domain MX records, mine was different on the cPanel.

New

Re: Contact form not sending email

I am in the novice class, but have a form which I set up using "thesitewizard.com" and bluegriffin package The form appears to work fine, but no mail delivered - as described above. I have tried to follow your suggestion, but unfortunately without success. I have still never received any emails from the form and when remote was selected I could not send emails to the main email address - although interestingly when I sent emails to an alias they did get delivered! No idea what is going on, but it is very frustrating and time consuming. When I changed back to local host the emails were delivered as normal, to main email address and aliases - but still nothing from form! It seems that the php file is working OK so no point in finding new file, the  problem seems to be with hosting and I seem to be getting way out of my depth here changing settings without really understanding what I am doing - and so far nothing has worked, in fact it has changed for the worse. Any suggestions??

lesjay

Re: Contact form not sending email

We are experiencing the same issue, however in the solution presented, it does not apply since not the cPanel Entry automatically redirects to the goDaddy MX records.  This email feature use to work before but after we were forced to be migrated, the email using php stopped working, namely we can send emails but cannot be receive.  Any help would be greatly appreciated.

New

Re: Contact form not sending email

Hello - I just spent half an hour replying to your post, but it does not seem to have been sent on - it is not an easy forum to use. I have spent hours trying to sort this problem out without any success at all. In the end I spoke to someone on the GoDaddy hosting section (UK branch) and tried a couple of things which did not work, but at least they told me I had managed to reverse all the changes I had made. In the end the advice was to redevelop the site using wordPress - which they said was free with the package I have with them (although I think it is free to download anyway?). And, for the sake of my sanity that is what I am doing. So far it has not been too difficult, but I have not yet reached the point where I am setting up the "contact form" - I shall be very annoyed if I find I am having the same problem with this package. The contact by email works fine (but then it did with the previous version) so the crunch comes when I look at the contact form - I'll let you know if I have the same problem - hopefully not!

lesjay