Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 3rd Dec 2015, 10:26 AM   #1
HyperActive Warrior
 
Join Date: 2009
Posts: 212
Thanks: 11
Thanked 5 Times in 5 Posts
Default
Form Not Sending Please Help
Share on: 
fb share twitter share gplus share more share

So I have a simple form the php code to send shoots out the reply that it was sent but nothing coming in email - why?

PHP Code:
<?php
//if "email" variable is filled out, send email
  
if (isset($_POST['email']))  {
  
  
//Email information
  
$email_subject = "New Credit Application";
  
$email_to = "myemail@hotmail.com";
  
$email_from = $_POST['email'];
  
$name = $_POST['name'];
  
$phone = $_POST['phone'];
  
$referral = $_POST['selection'];
  
 
  
  
//send email
  
$email_message .= "Name: ".$name."\n";
 
    
$email_message .= "Phone Number: ".$phone."\n";
 
    
$email_message .= "Email: ".$email_from."\n";
 
    
$email_message .= "Selection: ".$referral."\n";
 
  
  
// create email headers
 
    
$headers = 'From: '.$email_from."\r\n".
     
    
'Reply-To: '.$email_from."\r\n" .
     
    
'X-Mailer: PHP/' . phpversion();
     
$send = mail($email_to, $email_subject, $email_message, $headers);
      
      
//Email response
      
if ($send) {
      echo 
"Thank you for contacting us!";
      }else {
          echo 
"Something Went Wrong";
      }
      }
      
?>
solidsoul is offline  
Unread 3rd Dec 2015, 11:13 PM   #2
Toltec Warrior
War Room Member
 
majick's Avatar
 
Join Date: 2011
Location: Australia
Posts: 95
Thanks: 2
Thanked 23 Times in 22 Posts
Default
Re: Form Not Sending Please Help
Share on: 
fb share twitter share gplus share more share

code looks okay, perhaps it is being filtered and so not received...
check your spam folder and/or test a different email address?

majick is offline  
Unread 4th Dec 2015, 04:35 AM   #3
Active Warrior
 
Join Date: 2014
Posts: 84
Thanks: 5
Thanked 11 Times in 10 Posts
Default
Re: Form Not Sending Please Help
Share on: 
fb share twitter share gplus share more share

To send email with 'mail' you need a mail server (like postfix,sendmail,exim etc) installed and set up on the server that's running your php. It might be very hard to do that if you're not an IT Pro / sys admin or know your stuff about mail servers, it's really tricky. If you can I would recommend using 3rd party mail server infrastructure like Mandrill or Mailgun . Both of them have free tiers ( 12,000 emails a month I think ) . And you can be pretty much sure that your mail will be delivered ( unless you're spamming , have high bounce rate etc ). It's quite simple to use i.e. SwiftMailer for PHP to send mails with either of those .
robomedia is offline  
Unread 4th Dec 2015, 11:38 AM   #4
HyperActive Warrior
 
Join Date: 2009
Posts: 212
Thanks: 11
Thanked 5 Times in 5 Posts
Default
Re: Form Not Sending Please Help
Share on: 
fb share twitter share gplus share more share

Thank you for your reply - I find it strange cause this is the only domain on my server that won't send mail.. does it have anything to do with the fact that I'm working on Wordpress? the form itself is on a page in wordpress and form submitting to mydomain.com/phpfile.php again I get the email sent reply but nothing comes through - I have another site on the same server and get mail no problem??
solidsoul is offline  
Unread 4th Dec 2015, 11:44 AM   #5
HyperActive Warrior
 
Join Date: 2009
Posts: 212
Thanks: 11
Thanked 5 Times in 5 Posts
Default
Re: Form Not Sending Please Help
Share on: 
fb share twitter share gplus share more share

Ok following the advice here I tried a different email address to send to and that does work.... STRANGE hotmail not going to junk or anything just not going period??
solidsoul is offline  
Unread 4th Dec 2015, 07:13 PM   #6
Conceited Know-It-All
 
kilgore's Avatar
 
Join Date: 2014
Location: Amurrica
Posts: 952
Thanks: 465
Thanked 1,136 Times in 503 Posts
Default
Re: Form Not Sending Please Help
Share on: 
fb share twitter share gplus share more share

My guess is hotmail's spam protection is preventing your message from getting through. If I had to guess why, I'd venture to say that it doesn't recognize the server you're sending from as being a valid sender for your FROM email address. If you want to ensure deliverability, your best bet is to go through an established transactional email service such as SendGrid, SES, or Mandril (and there are plenty of others). Alternatively, make sure your SPF records are set for your domain's DNS and that they point to the correct servers.

kilgore is offline  
Unread 4th Dec 2015, 08:47 PM   #7
Toltec Warrior
War Room Member
 
majick's Avatar
 
Join Date: 2011
Location: Australia
Posts: 95
Thanks: 2
Thanked 23 Times in 22 Posts
Default
Re: Form Not Sending Please Help
Share on: 
fb share twitter share gplus share more share

if you are on wordpress anyway, why not use the wp_mail function instead of mail()
and put the php file in your /wp-content/mu-plugins/ folder ?

...you may need to wrap it as a function and add it to an action hook tho, eg. add_action('init','custom_email_sender');
function custom_email_sender() {YOUR CODE;}

then you just can just remove the form target that is pointing to the
php file, because it will be handled by any wordpress url this way.

this way you can install a mail logging plugin too and that might
help you see what else might be going on there, or you could
even install an smtp plugin to route the mail etc.

majick is offline  
Closed Thread


Bookmarks

Tags
form, sending


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 08:44 PM.