Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Email not sending

  1. #1
    Join Date
    Feb 2013
    Posts
    56
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default Email not sending

    I have a website with a contact form. The PHP code is at the top of the page. It is being called from the Form action. I am not getting any error messages. It seems to be working except that the emails aren't being sent. The page is...

    http://www.schuremediagroup.com/#!/page_Contact

    you can try it, and you'll see that it seems to be working, but alas I am not receiving any emails.

    Code:
    <?php
    if(isset($_POST['email'])) {
    	// EDIT THE 2 LINES BELOW AS REQUIRED
         $email_to = "ds@schuremediagroup.com";
    	 $email_subject = "SMG Contact";
    	 function died($error) {
         // your error code can go here
         echo "We are very sorry, but there were error(s) found with the form you submitted. ";
    	 echo "These errors appear below.<br /><br />";
    	 echo $error."<br /><br />";
    	 echo "Please go back and fix these errors.<br /><br />";
    	 die();    }
    	 // validation expected data exists
    	 if(!isset($_POST['name']) ||
    	 !isset($_POST['email']) ||
    	 !isset($_POST['comments'])) {
    		         died('We are sorry, but there appears to be a problem with the form you submitted.');           }         			
    				 $subject = $_POST['subject'];
    				 $name = $_POST['name']; // required
    				 $email_from = $_POST['email']; // required
    				 $comments = $_POST['comments']; // required
    				 $error_message = "";
    				 $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
    				 if(!preg_match($email_exp,$email_from)) {
    					 $error_message .= 'The Email Address you entered does not appear to be valid.<br />';  }
    					 $string_exp = "/^[A-Za-z .'-]+$/";  if(!preg_match($string_exp,$name)) {
    						    }
    							 if(strlen($comments) < 2) {
    								 $error_message .= 'The Comments you entered do not appear to be valid.<br />';  }
    								 if(strlen($error_message) > 0) {
    									 died($error_message);  }
    									 $email_message = "Information.\n\n";
    									 function clean_string($string) {
    										 $bad = array("content-type","bcc:","to:","cc:","href");
    										 return str_replace($bad,"",$string);    }
    										 $email_message .= "Subject: ".clean_string($subject)."\n";
    										 $email_message .= "Name: ".clean_string($name)."\n";
    										 $email_message .= "Email: ".clean_string($email_from)."\n";
    										 $email_message .= "Comments: ".clean_string($comments)."\n";
    										 // create email headers
    										 $headers = 'From: '.$email_from."\r\n". 
    										 'Reply-To: '.$email_from."\r\n".
    										 'X-Mailer: PHP/' . phpversion();
    										 @mail($email_to, $email_subject, $email_message, $headers);
    										 ?>
                                             <!-- include your own success html here -->
                                             	<div class="boxer" "visibility:hidden">
             										<div class="close_boxer" align="right">X</div>
                									<div align="center">
                   										Request Sent. Thank you!
                   									</div>
            									</div>
                                             <?php
                                             }
    										 ?>
    Any help is appreciated. Thank you.

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,933
    Thanks
    16
    Thanked 303 Times in 302 Posts
    Blog Entries
    9

    Default

    I haven't tested or looked too closely at your code as I'm on iPhone at the mo, but for starters, are you 100% sure that you have mailing enabled on your web host account? I ask because its more often than not disabled on free accounts (you don't say if that's the case but I just thought I'd throw it in there) and that sometime stumps folks before they even get started.
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  3. #3
    Join Date
    Feb 2013
    Posts
    56
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Beverleyh View Post
    I haven't tested or looked too closely at your code as I'm on iPhone at the mo, but for starters, are you 100% sure that you have mailing enabled on your web host account? I ask because its more often than not disabled on free accounts (you don't say if that's the case but I just thought I'd throw it in there) and that sometime stumps folks before they even get started.
    Thank you. The email account is not a free account. It is with GoDaddy. When I had the php file on a seperate page it worked. But then I moved it to the same page as the form and now it doesn't. I moved it so that I would get the popup div that the email was sent.

  4. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    • Do you have error reporting enabled?
    • Are you getting any error messages?


    Also,
    Quote Originally Posted by DS928
    PHP Code:
    @mail($email_to$email_subject$email_message$headers); 
    The error suppression operator ( @ ) allows you to implement your own error handling, but, in this case, it is simply being used to ignore errors. This is never A Good Thing.

    For example, your call to mail() is failing, but you will never know why because the error is ignored.

    Instead, try something like:
    PHP Code:
    # @mail($email_to, $email_subject, $email_message, $headers);

    if( mail($email_to$email_subject$email_message$headers) ){
        
    /*  success! show a thank-you message.  */
    }
    else{
        
    /* failure. show an error message.  */


  5. #5
    Join Date
    Feb 2013
    Posts
    56
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    Thank you. I did as you suggested and I am receiving no error messages. I think its fair to point out that I tried several email forms and they all said that the email was sent. However; I did not receive anything. I checked with GoDaddy and they said all is well at their end. Preplexing.

  6. #6
    Join Date
    Feb 2013
    Posts
    56
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    Eureka! Something showed up.

    [Fri Sep 20 12:56:10 2013] [error] [client 67.82.108.194] File does not exist: /var/chroot/home/content/d/s/t/dstr3/html/SMG/favicon.ico
    [Fri Sep 20 12:56:10 2013] [error] [client 67.82.108.194] File does not exist: /var/chroot/home/content/d/s/t/dstr3/html/SMG/missing.html

  7. #7
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by DS928 View Post
    Eureka! Something showed up.

    [Fri Sep 20 12:56:10 2013] [error] [client 67.82.108.194] File does not exist: /var/chroot/home/content/d/s/t/dstr3/html/SMG/favicon.ico
    [Fri Sep 20 12:56:10 2013] [error] [client 67.82.108.194] File does not exist: /var/chroot/home/content/d/s/t/dstr3/html/SMG/missing.html
    those seem unrelated to your script.


    Did you determine if the mail function is returning true or false (i.e., did you see your "success" message or your "error" message)?

    Did you make sure PHP's error reporting is enabled?
    Last edited by traq; 09-20-2013 at 09:33 PM.

  8. The Following User Says Thank You to traq For This Useful Post:

    DS928 (09-21-2013)

  9. #8
    Join Date
    Feb 2013
    Posts
    56
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by traq View Post
    those seem unrelated to your script.


    Did you determine if the mail function is returning true or false (i.e., did you see your "success" message or your "error" message)?

    Did you make sure PHP's error reporting is enabled?
    After several calls to GoDaddy they finally aditted that where my email resides on the server the que is jammed and I just have to wait. Thank you for your help.

  10. #9
    Join Date
    Feb 2013
    Posts
    56
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    How do you close this thread?

  11. #10
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    Is it working now? Is that the only issue? That's very strange. I wouldn't be surprised by a 5 minute delay, or maybe even a one time delay of an hour or two, but to have it down for long enough to have this whole conversation... GoDaddy did something very, very wrong.* And they're usually reliable. Keep an eye on this. One the other hand, their tech support, in my experience, is far from the best. So if you still have issues, don't hesitate to talk to a manager, get a second opinion, etc.
    (*Alternatively, it is, I suppose, possible that someone was abusing the email services on that server. Maybe that shut it down for everyone.)


    As for closing the thread, we don't usually do that (unless there's a specific reason to). Instead, we would ask that you go to your first post, click edit (and then enter the "advanced" mode, rather than then "quick" mode). Then you can select "Resolved" from a dropdown menu. We'll know the problem is resolved, but the discussion can continue if something comes up.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Similar Threads

  1. Sending Form in Email
    By GUIDesigner in forum HTML
    Replies: 2
    Last Post: 08-27-2010, 02:52 AM
  2. PHP Email Form not sending to email?
    By euphoriastudio in forum PHP
    Replies: 1
    Last Post: 02-14-2008, 07:04 PM
  3. sending mms to phone via email
    By davidjmorin in forum Looking for such a script or service
    Replies: 0
    Last Post: 01-04-2008, 09:36 PM
  4. PHP Only Sending To One Email
    By tomyknoker in forum PHP
    Replies: 11
    Last Post: 05-06-2007, 11:15 AM
  5. Sending an Email
    By Eclyps19 in forum JavaScript
    Replies: 3
    Last Post: 10-29-2005, 09:13 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •