PHP - Simple Email Script Problems
Ok, I submit the form, and when the next page displays, it says recieved with the persons name, but it wont post their email, and it wont ever send the message to the email address......... i've been playing with it all day long and just cannot figure it out, about to rip my hair out... any help would be appreciated.
Contact.php page Code: [Select] <?php // Header Include include('includes/header.php'); ?> <!-- BEGIN SITE CONTENT INCLUDES HERE --> <!-- Index page included --> <table border="0" cellpadding="5" cellspacing="0" width="300" align="center"> <tr> <td><font face="verdana" size="2" color=#"000000"><b>Feedback Form</b></font></td> <tr> <td><form name="contact" method="post" action="contact_submit.php"> <font face="verdana" size="1" color="#1b4a1b">Your Name:<br /> <input type="text" name="name" size="25" /> <br /> Email:<br /> <input type="text" name"email" size="25" /> <br /> Comments:</font><br /> <textarea name="comments" rows="5" cols="30"></textarea> <br /><input type="submit" name="submit" value="Send" /> </form></td> </tr> </table> <br /><br /> <!-- / End Index Page --> <!-- / END SITE CONTENT INCLUDES HERE --> <!-- Footer Include --> <?php include('includes/footer.php'); ?> Form Processing Script contact_submit.php Code: [Select] <?php $to = "tonyagmatrix@gmail.com"; $re = "Feedback Form"; $msg = $comments; mail($to,$re,$msg); ?> <html><head><title>Message Recieved</title></head> <body> <h3>Thank you for your feedback <?PHP echo ($name); ?></h3> <br />We value your opinions and any questions will be replyed to your email address: <?php echo ($email); ?> </body></html> Does anyone have any idea wtf is wrong? Similar TutorialsCan someone show me a simple mail script that I can run in cli, I can enter a $to = email@email.com and then have it send to my email? just in cli.. Thanks So basically here is what Im trying to do: I have a site that has an employee roster on it...this roster obviously has the employees information including their email addresses next to their names. I am trying to create a script that will allow an employee to easily email another employee on the roster simply by clicking the email address for that employee. To sum this up (or make it even more confusing) ... If i have an email address LINK of "myname@company.com" next to an employees name and a person clicks on that link ... I need some code that will take that email address link (myname@company.com) and add it into the email script into the "$to" function so that when they submit the email form it will go to the employees email (myname@company). I have several employee on this roster so I need a universal script that takes the email links information (ie myname@company.com) and puts it into the mail.php script. I do not want to have to make individual email scripts for each employee just to add to change the "$to" variable on each script!!! So basically how do I add a "links information" into a php script ?? Does this make sense ??? Are you confused ?? I can TRY to explain better if need be. I have looked all over the internet for this and have searched this forum however I have not been able to find a solution to this. A step in the right direction would be great!!! Hello all, I used simple php email function but it send an email in junk folder or spam. Can anyone tell me why is this so? Her is the code: $host = "ssl://smtp.gmail.com"; $port = "465"; $to = " xx@gmail.com"; // note the comma $subject = " $_POST[company_website] "; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: About Wholesale Account' . "<$_POST[email]>\r\n"; $headers .= 'Cc: mail@gmail.com' . "\r\n"; $headers .= 'Bcc: cc@gmail.com' . "\r\n"; mail($to, $subject, $message, $headers); Hi the user fill details and then the email his sent to me the only problem is that the emails keeps going to my spam, can someone help me out please I looked already php website and email format looks the same. This is the link to my form. http://www.people.eurico.co.uk/ here my form script Code: [Select] <?php // Set email variables $email_to = 'xxxxx@xxxxxxx.co.uk'; $email_subject = 'Call back form'; // Set required fields $required_fields = array('fullname','email','telephone','comment'); // set error messages $error_messages = array( 'fullname' => 'Please enter a Name to proceed.', 'email' => 'Please enter a valid Email.', 'telephone' => 'Please telephone.', 'comment' => 'Please enter your Message to continue.' ); // Set form status $form_complete = FALSE; // configure validation array $validation = array(); // check form submittal if(!empty($_POST)) { // Sanitise POST array foreach($_POST as $key => $value) $_POST[$key] = remove_email_injection(trim($value)); // Loop into required fields and make sure they match our needs foreach($required_fields as $field) { // the field has been submitted? if(!array_key_exists($field, $_POST)) array_push($validation, $field); // check there is information in the field? if($_POST[$field] == '') array_push($validation, $field); // validate the email address supplied if($field == 'email') if(!validate_email_address($_POST[$field])) array_push($validation, $field); } // basic validation result if(count($validation) == 0) { // Prepare our content string $email_content = 'peoplesmartlearning.co.uk: ' . "\n\n"; // simple email content foreach($_POST as $key => $value) { if($key != 'submit') $email_content .= $key . ': ' . $value . "\n"; } // if validation passed ok then send the email mail($email_to, $email_subject, $email_content); // Update form switch $form_complete = TRUE; } } function validate_email_address($email = FALSE) { return (preg_match('/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? TRUE : FALSE; } function remove_email_injection($field = FALSE) { return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field)); } ?> The HTML Code: [Select] <div class="call_us_form"> <p class="title">WE'LL CALL YOU BACK</p> <?php if($form_complete === FALSE): ?> <form class="contact_form" id="fm-form" method="post" action="index.php" > <fieldset> <div class="fm-req"> <label for="fm-firstname">Name</label> <input type="text" id="fullname" class="detail" name="fullname" value="<?php echo isset($_POST['fullname'])? $_POST['fullname'] : ''; ?>" /> <?php if(in_array('fullname', $validation)): ?><script type="text/javascript">alert("Please enter a Name"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-firstname">Email</label> <input type="text" id="email" class="detail" name="email" value=" <?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" /> <?php if(in_array('email', $validation)): ?><script type="text/javascript">alert("Please enter a valid Email Address"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-firstname">Number</label> <input type="text" id="telephone" class="detail" name="telephone" value="<?php echo isset($_POST['telephone'])? $_POST['telephone'] : ''; ?>" /> <?php if(in_array('telephone', $validation)): ?><script type="text/javascript">alert("Please enter telephone number"); history.back();</script><?php endif; ?> </div> <div class="fm-req"> <label for="fm-lastname">Message</label> <textarea cols="40" rows="5" id="comment" name="comment" class="mess"><?php echo isset($_POST['comment'])? $_POST['comment'] : ''; ?></textarea> <?php if(in_array('comment', $validation)): ?><script type="text/javascript">alert("Please enter your message"); history.back();</script><?php endif; ?> </div> <input class="submit_button" type="submit" value="Call us" /> </fieldset> </form> <?php else: ?> <p>Thank you for your Message!</p> <p>We will get back to you as soon as we can</p> <script type="text/javascript"> setTimeout ('ourRedirect()', 5000) function ourRedirect () { location.href='index.php' } </script> <?php endif; ?> Hi, n0obie here. I'm trying to identify where my customers are coming from via emails I've sent/received. However, many email providers (namely Gmail) have circumvented this by disallowing IP address geolocation/image caching. Code: [Select] $sql="SELECT * FROM $tbl_name3 WHERE review_show='n'"; $result=mysql_query($sql); $num_results=mysql_num_rows($result); if($num_results > 1){ $message="You have ".$num_results." reviews unapproved."; mail('example@example.com','GHP Reviews', $message, 'From: example@example.com'); } $sql2="SELECT * FROM $tbl_name4 WHERE rma_issued='n'"; $result2=mysql_query($sql2); $num_results2=mysql_num_rows($result2); if($num_results2 > 1){ $message="You have ".$num_results2." RMA Numbers Requested."; mail('example@example.com','GHP RMA Number Requests', $message, 'From: example@example.com'); } The reviews email is being sent, however, the RMA email is not. EDIT: Nevermind, $num_results and $num_results2 should have been > 0 not > 1. Hi Everyone! Thanks in advance for taking the time to review my post. I am pretty new to PHP so please excuse my ignorance. I am working a project for myself. I want to be able to send out newsletters to my customers and sponsors. I have written the code and here it is: <?php $subject = $_POST['subject']; $message = $_POST['message']; $email = "bubba@bubba.com"; $headers = "From: $email"; $email_list = file("elist.txt"); $total_emails = count($email_list); for ($counter=0; $counter<$total_emails; $counter++) { $email_list[$counter] = trim($email_list[$counter]); } $to = implode(",",$email_list); if ( mail($to,$subject,$message,$headers) ) { echo "The email has been sent!"; } else { echo "The email has failed!"; } ?> ----------------------------------------------------------------------------- In my elist.txt file - I have two fields. Name and email. Bubba|bubba@bubba.com Oohay|oohay@yahoo.com If i leave the names out of this file, the email script works great! I want to leave the names in there and reference them in my email that I am sending out to be more personal. Can this be done and can you help? Thanks! Mike Hello, im very green to php and I am having trouble creating a simple log in script. Not sure why this is not working, maybe a mysql_query mistake? I am not receiving any errors but nothing gets updated in the members table and my error message to the user displays. any help is appreciated! here is my php: <?php session_start(); $errorMsg = ''; $email = ''; $pass = ''; if (isset($_POST['email'])) { $email = ($_POST['email']); $pass = ($_POST['password']); $email = stripslashes($email); $pass = stripslashes($pass); $email = strip_tags($email); $pass = strip_tags($pass); if ((!$email) || (!$pass)) { $errorMsg = '<font color="#FF0000">Please fill in both fields</font>'; }else { include 'scripts/connect_db.php'; $email = mysql_real_escape_string ($email); $pass = md5($pass); $sql = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$pass'"); $log_check = mysql_num_rows($sql); if ($log_check > 0) { while($row = mysql_fetch_array($sql)) { $id = $row["id"]; $_SESSION['id']; $email = $row["email"]; $_SESSION['email']; $username = $row["username"]; $_session['username']; mysql_query("UPDATE members SET last_logged=now() WHERE id='$id' LIMIT 1"); }//Close while loop echo "You are logged in"; exit(); } else { $errorMsg = '<font color="#FF0000">Incorrect login data, please try again</font>'; } } } ?> and the form: <?php echo $errorMsg; ?> <form action="log_in.php" method="post"> Email:<br /> <input name="email" type="text" /><br /><br /> Password:<br /> <input name="password" type="password" /><br /><br /> <input name="myBtn" type="submit" value="Log In" /> </form> why cant i login in i have everything in my db this is the code Code: [Select] <?php session_start(); $email= $_SESSION['email']; ?> <?php if(loginbtn){ $email = $_POST['email']; $password = $_POST['password']; if($email && $password){ //connection to db require 'scripts/connect.php'; $query = mysql_query("SELECT * FROM users WHERE email='$email'"); $numrows = mysql_num_rows($query); if($numrows == 0){ $rows = mysql_fetch_assoc($query); $dbemail = $row['email']; $dbpassword = $row['password']; if($password==$dbpassword){ $_SESSION['email'] = $dbemail; echo "You have been logged in as $email"."<br/>"; }else echo "You enter a incorrect password"; }else echo "This person does not exsit"; }else echo "You did not fill in all the fields"; }else echo "$form"; $form = "<form action='login.php' method='POST'> <table> <tr> <td>Email</td> <td><input type='email' name='email'></td> </tr> <tr> <td>Password</td> <td><input type='password' name='password'></td> </tr> <tr> <td></td> <td><input type='submit' name='loginbtn' value='Login'></td> </tr> </table> </form>"; echo $form; ?> Hi can someone pls help, im tryin a tutorial but keep getting errors, this is the first one i get after registering. You Are Registered And Can Now Login Warning: Cannot modify header information - headers already sent by (output started at /home/aretheyh/public_html/nealeweb.com/regcheck.php:43) in /home/aretheyh/public_html/nealeweb.com/regcheck.php on line 46 Hi, I need to send a html image as an email to people. Here is the link http://cs.txstate.edu/~sr1388/Test/.. When I send I send the email by copying the source code(from view source) of that page, everything looks the same except for the fact the registry and review tables dont get aligned side by side . I cannot find what issue is causing it. This is what my email function looks like: Code: [Select] <? $content='view-source code here'; echo $content; $to = "me@gmail.com"; $subject = "test"; $body=$content; //$body="hello"; //$message=$total; $from = "webmaster@example.com"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; //$headers .= 'X-Mailer: PHP/' . phpversion() . "\r\n"; $headers .= 'From: Admin <Admin@mysite.com>' . "\r\n"; // Send email if(mail($to,$subject,$body,$headers)) { // Inform the user echo "Your email has been sent"; } else { echo "MAIL not sent"; } ?> Hey folks, this is a demo of my cart htp://fhcs.be/cart-demo3/ I have made a send button and a mail.php , but I dont receive the mail although it says that the email is sent. Here is my mail.php <?php if($_POST['sendemail'] == 'Email') { mail('andrej13@gmail.com', 'Subject', $cart); echo 'Your mail has been sent'; } else { echo 'Your mail was not sent'; } ?> my cart.php (where the email button is) <?php // Include MySQL class require_once('inc/mysql.class.php'); // Include database connection require_once('inc/global.inc.php'); // Include functions require_once('inc/functions.inc.php'); // Start the session session_start(); // Process actions $cart = $_SESSION['cart']; $action = $_GET['action']; switch ($action) { case 'add': if ($cart) { $cart .= ','.$_GET['id']; } else { $cart = $_GET['id']; } break; case 'delete': if ($cart) { $items = explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($_GET['id'] != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } $cart = $newcart; } break; case 'update': if ($cart) { $newcart = ''; foreach ($_POST as $key=>$value) { if (stristr($key,'qty')) { $id = str_replace('qty','',$key); $items = ($newcart != '') ? explode(',',$newcart) : explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($id != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } for ($i=1;$i<=$value;$i++) { if ($newcart != '') { $newcart .= ','.$id; } else { $newcart = $id; } } } } } $cart = $newcart; break; } $_SESSION['cart'] = $cart; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>PHP Shopping Cart Demo &#0183; Cart</title> <link rel="stylesheet" href="css/styles.css" /> </head> <body> <div id="shoppingcart"> <h1>Your Shopping Cart</h1> <?php echo writeShoppingCart(); ?> </div> <div id="contents"> <h1>Please check quantities...</h1> <?php echo showCart(); ?> <p><a href="index.php">Back to bookshop...</a></p> <form action="mail.php" method="post"> <input type="submit" name="sendemail" value="Email" /> </form> </div> </body> </html> and the functions.inc.php <?php function writeShoppingCart() { $cart = $_SESSION['cart']; if (!$cart) { return '<p>You have no items in your shopping cart</p>'; } else { // Parse the cart session variable $items = explode(',',$cart); $s = (count($items) > 1) ? 's':''; return '<p>You have <a href="cart.php">'.count($items).' item'.$s.' in your shopping cart</a></p>'; } } function showCart() { global $db; $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $output[] = '<form action="cart.php?action=update" method="post" id="cart">'; $output[] = '<table>'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM products WHERE id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $output[] = '<tr>'; $output[] = '<td><a href="cart.php?action=delete&id='.$id.'" class="r">Remove</a></td>'; $output[] = '<td>'.$name.'</td>'; $output[] = '<td>€'.$price.'</td>'; $output[] = '<td><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>'; $output[] = '<td>€'.($price * $qty).'</td>'; $total += $price * $qty; $output[] = '</tr>'; } $output[] = '</table>'; $output[] = '<p>Grand total: <strong>£'.$total.'</strong></p>'; $output[] = '<div><button type="submit">Update cart</button></div>'; $output[] = '</form>'; } else { $output[] = '<p>You shopping cart is empty.</p>'; } return join('',$output); } ?> So, I'm working on this contact form for a project. I found a tutorial on building such a form which turned out to be simple enough. It seems to work as far as when I submit, the echo response shows up in the browser window..however, there's no actual email that shows up in my mailbox. Here's the code for the form: Code: [Select] <form name="contact" id="contact" method="post" action="mailer.php"> <p> <label for="fullname">Name:</label> <input type="text" name="name" class="txt"> </p> <p> <label for="address"> Property Street Address:</label> <input type="text" name="address" class="txt"> </p> <p> <label for="city">City:</label> <input type="text" name="city" class="txt"> </p> <p> <label for="state">State:</label> <input type="text" name="state" class="txt"> </p> <p> <label for="zip">Zip:</label> <input type="text" name="zip" class="txt"> </p> <p> <label for="owners">Owner(s) of Record:</label> <input type="text" name="owner" class="txt"> </p> <p> <label for="parcel">Parcel ID# (Leave Blank if Unknown):</label> <input type="text" name="parcel" class="txt"> </p> <p> <label for="phone">Phone:</label> <input type="text" name="phone" class="txt"> </p> <p> <label for="email">Email:</label> <input type="text" name="email" class="txt"> </p> <p> <label for="thanking">Who do we thank for referring you?</label> <input type="text" name="thanking" class="txt"> </p> <p><strong>Ready to reduce your soaring property taxes? Then check off level of assistance.</strong></p> <p> <input type="radio" value="yes" name="option"> Tool Box <input type="radio" value="no" name="option"> Self Starter Kits <input type="radio" value="no" name="option"> Predetermination Analysis <input type="radio" value="no" name="option"> Consultation <input type="radio" value="no" name="option"> Other </p> <p> Message: <textarea rows="9" name="comment" cols="30"></textarea> </p> <div id="subButton"> <input class="buttons" type="image" src="images/formSubmit.gif" tabindex="3" name="submit" value="submit" /> </div> </form> Here's the code for the script: Code: [Select] <?php if(isset($_POST['submit'])) { $to = "xxxxxxx@goofyEmail.com"; $subject = "Service inquiry"; $name = $_POST['name']; $address = $_POST['address']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $owner = $_POST['owner']; $parcel = $_POST['parcel']; $phone = $_POST['phone']; $email = $_POST['email']; $thanking = $_POST['thanking']; $comment = $_POST['comment']; $option = $_POST['radio']; $body = "From: $name\n Address: $address\n City: $city\n State: $state\n Zip: $zip\n Owner: $owner\n Parcel Number: $parcel\n Phone Number: $phone\n Referral Name: $thanking\n E-Mail: $email\n Option: $option\n Message: $comment\n "; echo "Thank you! Your Wicked Awesome Service Inquiry has been submitted to $to!"; mail($to, $subject, $body, "From: $from"); } else { echo "Oops. You have reached this page in error."; } ?> I also sent this to a friend for him to test on his server. Same results..form works but no email arrives. now, someone gave me this code to try out in order to make sure it's not my server and is in fact my code: Code: [Select] <?php $mail_test = mail("youremail@yourdomain.com", "Test Email", "This is a test message..."); if( $mail_test === true ) { echo "Sent email"; } else { echo "Mail failed!"; } ?> tried the page...loaded it in my browser and it worked fine...but no email hit my inbox. So, I'm not sure if it's my code or my hosting. I have a flash - to - php form for my personal site that works fine so that would have me thinking it might be my hosting. I tried moving this form and the script to a different location on the server thinking that might make a difference but it didn't. Also, again, I had a friend load it on their server as well...thinking it might be my server but the result is the same. So, I'm quite sure it's my code...but I'm just not sure where the issue is. One other thing, I looked at another tutorial with the most basic form I could find...email address and message input, button...nothing more. Same result. Not sure where to go from here. Any help or input is appreciated. Hi This is for a simple email client. I am trying to create a delete button that deletes a message when in message view from the MySQL database. Bellow is what I have so far. Currently it sends an alert confirming the message has been deleted and goes back to the inbox view where, it is evident that nothing has been deleted. Even when I log out then back in, the message is still there. Code: [Select] // This is how I call the JavaScript function in the html page: <input type="button" value="Delete" onclick="deleteMessage();" /> // This is the relevant JavaScript: /* ~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions used to Delete a message ~~~~~~~~~~~~~~~~~~~~~~~~~~ */ var requestDlt = false; // for the message to delete /* I created my own addition PHP script that, if correct, should delete a message when in message view */ function deleteMessage(mailNumber) { var url = "delete.php?mailID="+mailNumber; // assign to the url if (window.ActiveXObject) // if the users window matches this { // then requestDlt = new ActiveXObject("Microsoft.XMLHTTP"); // create a new ActiveXObject } else if (window.XMLHttpRequest) // else if the window matches this { // then requestDlt = new XMLHttpRequest(); // the global variable is an XMLHttpRequest } if (requestDlt!=null) // if the request exists { requestDlt.onreadystatechange=RequestFunctionDelete; // when ready envoke RequestFunctionMessage requestDlt.open("GET",url); // the request will now open the assigned url requestDlt.send(null); // send the request } } function RequestFunctionDelete() { if (requestDlt.readyState==4) // if all has been sent { // and if (requestDlt.status==200) // if it is all OK { /* if in message view, hide it, and show inbox */ if (document.getElementById("messageView").style.display!="none") { var response=requestDlt.responseText; // the variable response will hold the response text alert(response); // display the response to the user $("#messageView").fadeOut(1000, function() // hide message { $("#inboxBox").fadeIn(1000); // show inbox }); } else { // else /* Warn user they are unable to access button in this view */ alert("select a message you would like to delete"); } } } } // And lastly, here is the PHP Script that is called: <?php header('Content-Type: text/xml'); header("Cache-Control: no-cache, must-revalidate"); $dbhost = 'localhost'; $dbuser = 'cjc16'; $dbpass = 'cjc16'; $dbname = 'cjc16'; $dbtable = 'mail'; $id=$_GET["mailID"]; $con = mysql_connect($dbhost, $dbuser, $dbpass); if (!$con) { die('Could not connect: ' . mysql_error()); } $dbselect = mysql_select_db($dbname,$con); $sql="DELETE FROM $dbtable WHERE mailID='$id'"; $result = mysql_query($sql); if ($result) { echo "Deleted"; } else { echo 'Unable to delete'; } mysql_close($con); ?> Mod edit: [code] . . . [/code] tags added. I have been looking everywhere, and can't find a simple example of scripting a confirmation email. Basically, I have a form that is submitting to a database. But when the user submits the form successfully (I already have the validation in place), it sends their submitted email address a confirmation email. Currently the form submits, fills in fields in a database, and sends the user to a static thank you page. At this time I would like to send them the email. How can this be done somewhat simply? I still have little knowledge of php, I asked a question earlier but that gave me so as it is now my help please. I'm looking for an easy script that sends the info and send a confirmation. but everyone says something different. Have you a script that I only need to change what data? before hand thanks now use this script but does not work also completely leak, I understood for spammmers i have some code which sends a confrim link via the posted email. In hotmail it works fine, once the link is clicked they are confirmed but gmail adds %09 to the link making it break. example WHERE hash = their email hashed posted email = test@test.com confirm link(hotmail) confirm.php?email=HASH&o=test@test.com(works) confirm link(gmail)confirm.php?email=%09HASH&o=test@test.com(Doesnt work) anyone know why gmail does this? Hi, folks -- I've been working on this for quite awhile, and have done lots of searching, but I still cannot make it work. Using Xampp on Win 7 x64, with PHP 5.3. Here is my simple PHP code just trying to get something to work: $to = 'my_real_email@gmail.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: someone@localhost.com' ; mail($to, $subject, $message, $headers); ?> (NOTE: "my_real_email" is set to my actual email address.) Here are my php.ini settings: Code: [Select] [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = localhost ; http://php.net/smtp-port smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from ; sendmail_from = postmaster@localhost ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path sendmail_path = "\"E:\xampplite\sendmail\sendmail.exe\" -t" ; Force the addition of the specified parameters to be passed as extra parameters ; to the sendmail binary. These parameters will always replace the value of ; the 5th parameter to mail(), even in safe mode. ; mail.force_extra_parameters = ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename mail.add_x_header = Off ; Log all mail() calls including the full path of the script, line #, to address and headers mail.log = "E:\xampplite\apache\logs\php_mail.log" I'm not getting an error and the email seems to be getting "logged", but I do not receive an actual email in my account. Thanks for any suggestions. Hey everyone. I hope you can help me getting through this problem, because I have no idea of what else to try. I'm a web designer and sometimes modify Javascript, but my main focus is HTML and CSS, meaning I have no idea how to code in Javascript, but most importantly, how to write something from scratch in PHP. So I designed a form that works pretty well, and integrated a PHP and Javascript script to make it work. This is the form: Code: [Select] <form name="form" id="form" method="post" action="contact.php"> <p>Hello,</p> <p>My name is <input type="text" name="name">, from <input type="text" name="location">, and I'd like to get in touch with you for the following purpose:</p> <p><textarea name="message" rows="10" ></textarea></p> <p>By the way, my email address is <input type="text" name="email" id="email" placeholder="john@doe.com">, and I can prove I'm not a robot because I know the sky is <input type="text" name="code" placeholder="Red, green or blue?">.</p> <p title="Send this message."><input type="submit" id="submit" value="Take care."></p> </form> And this is the script, in an external file called contact.php: Code: [Select] <?php $name = check_input($_REQUEST['name'], "Please enter your name.") ; $location = check_input($_REQUEST['location']) ; $message = check_input($_REQUEST['message'], "Please write a message.") ; $email = check_input($_REQUEST['email'], "Please enter a valid email address.") ; if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) {die("E-mail address not valid");} if (strtolower($_POST['code']) != 'blue') {die('You are definitely a robot.');} $mail_status = mail( "my@email.com", "Hey!", "Hello,\n\n$message\n\nRegards,\n\n$name\n$location", "From: $email $name" ); function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data; } function show_error($myError) { ?> <html> <body> <b>Please correct the following error:</b><br /> <?php echo $myError; ?> </body> </html> <?php exit(); } if ($mail_status) { ?> <script language="javascript" type="text/javascript"> alert('Thank you for the message. I will try to respond as soon as I can.'); window.location = '/about'; </script> <?php } else { ?> <script language="javascript" type="text/javascript"> alert('There was an error. Please try again in a few minutes, or send the message directly to aalejandro@bitsland.com.'); window.location = '/about'; </script> <?php } ?> So what it does is this: if everything's OK, it sends an email with "Hey!" as the subject, "[name]" as the sender, "Hello, [message]. Regards, [name], [location]" as the body, and a popup saying the message was delivered appears. If something fails, it outputs the error in a new address, so the user will have to go back to the form and correct the error. What I actually want to happen is this: if everything's OK, a <p> which was hidden beneath the form appears saying the message was delivered, or, alternatively, make the submit button gray out and confirm the message was delivered. I found a script to make this happen, but with "Please wait...", so the user can't resubmit the form. If there's an error, I'd like another <p> which was hidden to appear with the specific error, so there'd be many <p>'s hidden with different IDs. If possible, I'd also like to change the CSS style of the input field, specifically changing the border color to red, so it'd be a change in class for the particular field. -- So in essence, I want the errors and the success messages to output in the same page as the form (without refresh), and a change of class in the input fields that have an error. Thanks in advance, and please let me know if it'll be possible. |