Jump to content

Search the Community

Showing results for tags 'php mail not sending'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General Discussion
    • Website Management and Coding
    • Technology and the Internet
    • Philosophy, Politics, and Science
    • Art and Entertainment
    • Other Discussion
  • HelioHost
    • Questions
    • Customer Service
    • How You Can Help
  • HelioNet
    • News
    • Contact HelioNet

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 1 result

  1. Hey! I have a php mail() function that just refuses to send! I was wondering if someone here could check my code or suggest anything that might be preventing this from working. HTML / jQUERY / AJAX: <div id="contactformcontainer"> <form method="post" id="contactform"> <table> <tr> <td><label>Name</label></td> <td><input class="formbox" type="text" name="contactname" id="contactname"/></td> </tr> <tr> <td><label>Email</label></td> <td><input class="formbox" type="email" name="contactemail" id="contactemail"/></td> </tr> <tr> <td><label>Subject</label></td> <td><input class="formbox" type="text" name="contactsubject" id="contactsubject"/></td> </tr> <tr> <td><label>Message</label></td> <td><textarea class="formbox" name="contactmessage" id="contactmessage"></textarea></td> </tr> <tr> <td><label>Anti-spam</label></td> <td> <script> $(document).ready( function() { var randNumber1 = Math.floor(Math.random()*10) var randNumber2 = Math.floor(Math.random()*10) sumNumbers = randNumber1 + randNumber2; $('#randomNumbers').html(randNumber1 + ' + ' + randNumber2 + ' = '); }); </script> <span id="randomNumbers"></span> <input class="formbox" type="text" name="contactantispam" id="contactantispam"/> </td> </tr> <tr> <td></td> <td><input name="contactsubmit" id="contactsubmit" value="Send"/></td> </tr> </table> </form> <div id="success"><p>Thank you. Your message was successfully delivered.</p></div> <div id="empty"><p>Please ensure all fields are filled out correctly.</p></div> </div> <script> $('#contactsubmit').click(function() { var emailformat = /^([A-Za-z0-9_\+\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; if( $('#contactname').attr('value') !== '' && emailformat.test( $('#contactemail').attr('value') ) && $('#contactsubject').attr('value') !== '' && $('#contactmessage').attr('value') !== '' && $('#contactantispam').attr('value') == sumNumbers ) { var contactname = $('#contactname').attr('value'); var contactemail = $('#contactemail').attr('value'); var contactsubject = $('#contactsubject').attr('value'); var contactmessage = $('#contactmessage').attr('value'); var datastring = "contactname=" + contactname + "&contactemail=" + contactemail + "&contactsubject=" + contactsubject + "&contactmessage=" + contactmessage; //alert(datastring); $('#empty').hide(); $('#contactsubmit').hide(); $.ajax({ type: "POST", url: "php/contactform.php", data: datastring, success: function(){ alert("success!"); $('#success').fadeIn(); } }); return false; } else { alert("empty"); $('#empty').fadeIn(); } }); </script> PHP: <?php $to = "james@jalproductions.co.uk"; $contactname = $_REQUEST["contactname"]; $contactemail = $_REQUEST["contactemail"]; $subject = $_REQUEST["contactsubject"]; $contactmessage = $_REQUEST["contactmessage"]; $headers = "From: $contactemail\r\n"; $headers .= "Reply-to: $contactemail"; $body = "Name: $contactname\nEmail: $contactemail\nMessage:\n$contactmessage"; mail($to, $subject, $body, $headers); echo "$to"; echo "$subject"; echo "$body"; echo "$headers"; ?> Using alerts and echos, it seems that the data is being sent to the php code perfectly fine. The echos in the php code print out exactly what was entered into the form. I tried removing the jQUERY/AJAX and adding an action="" to the form tag so that it just runs the php on its own, but this still doesn't work! Help! Thanks! EDIT: I'm not using this code on a HelioHost hosted site.
×
×
  • Create New...