PHP - Email Function Probs
Similar TutorialsEverything about the email is sending except the message text does anyone know what the issue could be? here is the block of code that sends the email Thanks in advance Code: [Select] $image = "http://www.visualrealityink.com/dev/clients/arzan/snell_form/images/email.png"; echo "got to process form"; $target_path = "upload/"; $path = $target_path = $target_path . basename( $_FILES['file']['name']); $boundary = '-----=' . md5( uniqid ( rand() ) ); $message .= "Content-Type: application/msword; name=\"my attachment\"\n"; $message .= "Content-Transfer-Encoding: base64\n"; $message .= "Content-Disposition: attachment; filename=\"$path\"\n\n"; echo $path; $fp = fopen($path, 'r'); do //we loop until there is no data left { $data = fread($fp, 8192); if (strlen($data) == 0) break; $content .= $data; } while (true); $content_encode = chunk_split(base64_encode($content)); $message .= $content_encode . "\n"; $message .= "--" . $boundary . "\n"; $message .= $image . "<br />" . $_POST['name'] . "submitted a resume on our website. Please review the applications and contact the candidate if their resume is a fit for any open opportunities with the company. <br><br> Thank you. <br><br> SEI Team"; $headers = "From: \"Me\"<me@example.com>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\""; mail('george@visualrealityink.com', 'Email with attachment from PHP', $headers, $message); 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); Hello Guys,
I need your help as many PHPers here is more experienced in PHP coding than me. I have specific project I am working on and need a piece of code that can send an email from HTML form using PHP to the email address that is entered manually on the form, instead of standard sent to PHP code that is fixed within PHP script and executed during submission. I want sth that can grab manually enetered recipient's e-mail address, paste it to the PHP code and then use it to send the email to the recipient, instead of fixed sent to code. Something would say dynamically changed during the entry that can inject into PHP code the new address email entered on the form and then submit to it. Any ideas will be great.
Thanks.
Edited March 27, 2019 by slawotrend Hey, i'm needing to use email in a php script, but i've had no luck getting this working.. Even with perfectly given details. Is there another way which would let me email? I've tried using smtp details from live, gmail, isp email... All of which say it's send, but is not the case. The function is extremely broken, is there an alternative? Or some way to get this working? Kris. Please would somebody be able to show me or give me some tips as to how I go about getting an email to send in my php code? $headers = 'From: me@me.com' . "\r\n" . 'Reply-To: me@me.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $first = $_GET['first']; $last = $_GET['last']; $town = $_GET['town']; $telephone = $_GET['telephone']; $code = $_GET['postcode']; $shortcode = substr($code,0,2); $query =mysql_query ("SELECT email FROM treesurgeons WHERE postcode like '%" . $shortcode . "%' ORDER BY companyName LIMIT 3"); echo mysql_error(); echo "<p>The email addresses you have requested are;</p>"; while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; echo "$nt[0]<br>$nt[1]<br>$nt[2]<br>"; $message = "$first . $last, from $town has searched for your details.<br>You may contact them on $telephone. <br> Thankyou."; $subject = "You Showed Up In The Tree Directory!"; $email = "$nt[0],$nt[1],$nt[2]"; $to = "$email"; mail( "$to", "$subject","$message", "$headers"); ?></body></html> Hello i have a syntax issue in the code below, can anyone shed some light? Code: [Select] <?php if(isset($_POST['submit'])) { $drop = mysql_real_escape_string($_POST['drop_1']); $tier_two = mysql_real_escape_string($_POST['Subtype']); echo "You selected "; echo $drop." & ".$tier_two; $Name = mysql_real_escape_string($_POST["Name"]); $Phone = mysql_real_escape_string($_POST["Phone"]); $Email = mysql_real_escape_string($_POST["Email"]); $Postcode = mysql_real_escape_string($_POST["Postcode"]); $Website = mysql_real_escape_string($_POST["Website"]); if($Name == '' || $Phone == '' || $Email == '' else if (!preg_match('/^[A-Za-z0-9\-.]+$/', $domain)|| $Postcode == '' || $Website == '') { die('<br> but you did not complete all of the required fields correctly, please try again'); } } the code works fine without the " else if (!preg_match('/^[A-Za-z0-9\-.]+$/', $domain) " . As well as checking for blank fields i'd like to check for the correct email format. Many thanks. I wrote a bunch of code just to realize that there's a huge security hole in my script. Here's a how I've built it: 1. first you enter the new email address into the input box and click submit 2. an email gets sent to you where you have to click on an activation link to confirm the change, and of course the email gets send to the inbox to make sure it's a valid email the activation link looks as follows: Code: [Select] http://localhost/changeemail_confirm.php?id=$dbuser_id&email=$user_email The dbuser_id gets taken from the session variable, and the user email is the new entered user email. 3. After clicking the link you get directed to an activation page, I thought about letting the user enter his password and letting it match with the password in the database as added security, so he can't just change the user_id in the link so that the email of another user gets changed. the query on the activation page looks like this: "UPDATE user SET email = '$user_email' WHERE nickname = '$dbuser_name' AND WHERE user_id = '$id'"; The $id is being taking from the activation link per GET, and the $dbuser_name is being taking from the session variable. And now this is the problem where I'm stuck, even though I've added a bunch of security, and even the necessary to enter a password there's still a major security hole, which is the user can easily change the email in the activation link to something else, something that is not a valid email. E.g. this Code: [Select] http://localhost/changeemail_confirm.php?id=35&email=mail@phpmail.local can become to this, when the user manually edits the url and pastes it into his browser: Code: [Select] http://localhost/changeemail_confirm.php?id=35&email=MAIL@ANYTHING.com How can I prevent this, is there any way I could tell the script the CONFIRMED and VALID email, with a more secure way? BTW this script works as it is, it's just that the user can manually change the email to something else what makes this script worthless for now. Hi, I need to check is the mail is sent and successfully deliver to the recipient email. here is the code : if(mail($to, $subject, $message, $headers, '-f ' . $return_path)) {echo "Sent"; }else {echo "Not Sent";} Please help me, its urgent. Thanks in advance. Hi All, I have a script that i bought and a part of it has a share icon with an email icon so if the user clicks the email icon then it opens up your email client and adds the details of the deal to the email. The problem is that it seems to break each word up by placing a + between them. So for example you get this... Come+and+check+out+Welcome+to+theSocialDeal,+they+have+this+great+local+deal,+if+we+all+buy+it+then+we+get+it+cheaper! Today's+Deal:+4+hours+of+extreme+MTB+action+at+John+Doe+Extreme+Trail+Centre+for+the+price+of+1+hour Click+this+link+to+check+it+out:+ which should be this... Come and check out Welcome to theSocialDeal, they have this great local deal, if we all buy it then we get it cheaper! Today's Deal: 4 hours of extreme MTB action at John Doe Extreme Trail Centre for the price of 1 hour Click this link to check it out: Here is the php function, does anyone know what this could be and how i can stop it? function share_mail($team) { global $login_user_id; global $INI; if (!$team) { $team = array( 'title' => $INI['system']['sitename'] . '(' . $INI['system']['wwwprefix'] . ')', ); } $pre[] = "Come and check out {$INI['system']['sitename']}, they have this great local deal, if we all buy it then we get it cheaper!"; if ( $team['id'] ) { $pre[] = "Today's Deal: {$team['title']}"; $pre[] = "Click this link to check it out: "; $pre[] = $INI['system']['wwwprefix'] . "/team.php?id={$team['id']}&r={$login_user_id}"; $pre = mb_convert_encoding(join("\n\n", $pre), 'UTF-8', 'UTF-8'); $sub = "The Deal: {$team['title']}"; } else { $sub = $pre[] = $team['title']; } $sub = mb_convert_encoding($sub, 'UTF-8', 'UTF-8'); $query = array( 'subject' => $sub, 'body' => $pre, ); $query = http_build_query($query); return 'mailto:?'.$query; } Hi all, I am just starting out in the world of php and have got this far with a lot of googling. But I'm really stuck with this part now. I have a function that works perfectly for display on a page, eg <?php echo quickquote(); ?> function quickquote() { global $db; global $cart; $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $quickquote[] = 'Quote Required:<br />'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM products WHERE id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $quickquote[] = ''.$qty.''; $quickquote[] = ' x '; $quickquote[] = '' . $model . ''; $quickquote[] = ' (' . $type . '- '; $quickquote[] = ''. $basin . '- '; $quickquote[] = ''. $top . ')'; $quickquote[] = '<br />'; } $quickquote[] = 'End of Quick Quote Request'; } else { $quickquote[] = 'The quote cart is empty.'; } return join('',$quickquote); } However, i am trying to include this in an email message: if(!$error) { $messages="From: $email <br>"; $messages.="Name: $name <br>"; $messages.="Email: $email <br>"; $messages.="Phone: $phone <br>"; $messages.="Message: $message <br>"; $messages.="Quick Quote Request: $quickquote <br>"; $mail = mail($to,$subject,$messages,$headers); The email also works perfectly with the exception that the data is not there from $quickquote. I've tried all sorts of variations and suggested solutions from the web but nothing I've tried has been successful so far. It's amazing that I've got this far so I don't want to give up on it, but I'm just completely stumped ... All information and help very much appreciated. Cheers K i wanting users to be able to update there email address and check to see if the new email already exists. if the email is the same as current email ignore the check. i have no errors showing up but if I enter a email already in the db it still accepts the new email instead of bringing the back the error message. Code: [Select] // email enterd from form // $email=$_POST['email']; $queryuser=mysql_query("SELECT * FROM members WHERE inv='$ivn' ") or die (mysql_error()); while($info = mysql_fetch_array( $queryuser )) { $check=$info['email']; // gets current email // } if($check!=$email){ // if check not equal to $email check the new email address already exists// $queryuser=mysql_query("SELECT * FROM members WHERE email='$email' "); //$result=mysql_query($sql); $checkuser=mysql_num_rows($queryuser); if($checkuser != 0) { $error= "0"; header('LOCATION:../pages/myprofile.php?id='.$error.''); } } cheers Hello, I am working with a SMTP class to send an email. It's all working perfectly fine, but when the email is received (sent from the online form), and I open my email and click reply, there are two email addresses. The correct one (which I entered when I sent the email), and my ftp username for the site?? I've got three files that could effect this, but I was unable to locate any problems: mailer.php ( smtp send mail class) mail.php ( submission data: title, subject, etc. ) contact_form.php ( form for submission ) I am only including the file which I think is applicable (mail.php), but let me know if you would also like to see the mailer.php class. Current output: reply-to ftpusername@domainname.com, correct_from_email@fromemail.com mail.php: <?php set_time_limit(120); function sendHTMLmail($from, $to, $subject, $message) { $message = wordwrap($message, 70); // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= "From: $from\r\n"; // Mail it mail($to, $subject, $message, $headers); } function sendHTMLmail2($fromid, $to, $subject, $message) { echo $fromid; echo $to; echo $subject; echo $message; include_once("mailer.php"); $mail = new PHPMailer(); $mail->IsMail(); // SMTP servers $mail->Host = "localhost"; $mail->From = $fromid; $mail->FromName = $fromid; $mail->IsHTML(true); $mail->AddAddress($to, $to); $mail->Subject = $subject; $mail->Body = $message; $mail->AltBody = "Please enable HTML to read this"; $mail->Send(); exit; } function isValidEmail($email) { return eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$", $email); } class smtp_mail { var $host; var $port = 25; var $user; var $pass; var $debug = false; var $conn; var $result_str; var $charset = "utf-8"; var $in; var $from_r; //mail format 0=normal 1=html var $mailformat = 0; function smtp_mail($host, $port, $user, $pass, $debug = false) { $this->host = $host; $this->port = $port; $this->user = base64_encode($user); $this->pass = base64_encode($pass); $this->debug = $debug; $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($this->socket) { $this->result_str = "Create socket:" . socket_strerror(socket_last_error()); $this->debug_show($this->result_str); } else { exit("Initialize Faild,Check your internet seting,please"); } $this->conn = socket_connect($this->socket, $this->host, $this->port); if ($this->conn) { $this->result_str = "Create SOCKET Connect:" . socket_strerror(socket_last_error()); $this->debug_show($this->result_str); } else { exit("Initialize Faild,Check your internet seting,please"); } $this->result_str = "Server answer:<font color=#cc0000>" . socket_read($this->socket, 1024) . "</font>"; $this->debug_show($this->result_str); } function debug_show($str) { if ($this->debug) { echo $str . "<p>\r\n"; } } function send($from, $to, $subject, $body) { if ($from == "" || $to == "") { exit("type mail address please"); } if ($subject == "") $sebject = "none title"; if ($body == "") $body = "none content"; $All = "From:$from;\r\n"; $All .= "To:$to;\r\n"; $All .= "Subject:$subject;\r\n"; if ($this->mailformat == 1) { $All .= "Content-Type:text/html;\r\n"; } else { $All .= "Content-Type:text/plain;\r\n"; } $All .= "Charset:" . $this->charset . ";\r\n\r\n"; $All .= " " . $body; $this->in = "EHLO HELO\r\n"; $this->docommand(); $this->in = "AUTH LOGIN\r\n"; $this->docommand(); $this->in = $this->user . "\r\n"; $this->docommand(); $this->in = $this->pass . "\r\n"; $this->docommand(); if (!eregi("235", $this->result_str)) { $this->result_str = "smtp auth faild"; $this->debug_show($this->result_str); return 0; } $this->in = "MAIL FROM: $from\r\n"; $this->docommand(); $this->in = "RCPT TO: $to\r\n"; $this->docommand(); $this->in = "DATA\r\n"; $this->docommand(); $this->in = $All . "\r\n.\r\n"; $this->docommand(); if (!eregi("250", $this->result_str)) { $this->result_str = "Send mail faild!"; $this->debug_show($this->result_str); return 0; } $this->in = "QUIT\r\n"; $this->docommand(); socket_close($this->socket); return 1; } function docommand() { socket_write($this->socket, $this->in, strlen($this->in)); $this->debug_show("Client command:" . $this->in); $this->result_str = "server answer:<font color=#cc0000>" . socket_read($this->socket, 1024) . "</font>"; $this->debug_show($this->result_str); } } ?> Here is one of my emails. Delivered-To: jason@gmail.com Received: by 10.204.57.134 with SMTP id c6cs22321bkh; Tue, 13 Sep 2011 07:23:32 -0700 (PDT) Received: by 10.101.168.12 with SMTP id v12mr3751263ano.48.1315923810914; Tue, 13 Sep 2011 07:23:30 -0700 (PDT) Return-Path: <contact@big.com> Received: from big.com (big.com [173.0.59.100]) by mx.google.com with ESMTP id c19si889696anj.173.2011.09.13.07.23.29; Tue, 13 Sep 2011 07:23:29 -0700 (PDT) Received-SPF: pass (google.com: domain of contact@big.com designates 173.0.59.100 as permitted sender) client-ip=173.0.59.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of contact@big.com designates 173.0.59.100 as permitted sender) smtp.mail=contact@big.com; dkim=neutral (body hash did not verify) header.i=@big.com Received: by big.com (Postfix, from userid 33) id 1BDCE2F4041A; Tue, 13 Sep 2011 10:23:20 -0400 (EDT) DKIM-Signatu v=1; a=rsa-sha256; c=simple/simple; d=big.com; s=mail; t=1315923800; bh=ysNGlrscqmqCPbqxJlWWHLaW3SU6MgDVQCze+cevPS4=; h=To:Subject:Message-ID:Date:MIME-Version:Sender:From:Reply-To: Content-Type; b=PDPCRvKGQRP3LeeDNhZQwbX6aMXOZEyqRXV1E+kuDDq05NYRIrmJCcQRhwEIaSosh yoZ0pF5wtrXjgY1KA0hgee7qzSVDhweguBfOydn1qE6nsL1pq CQgsHmtvu9dwPGw9z uUEHM9bg5DwiG0RT5KLYf4oZTJmJpc8n2oyK26/I= To: jason@gmail.com Subject: Closed Beta Invitation from Jason Gordon Message-ID: <87847890-050333@big.com> Date: Tue, 13 Sep 2011 10:38:17 -0400 MIME-Version: 1.0 X-Mailer: PHP-5.3.8 X-Sender: "big" <contact@big.com> X-Priority: 3 Organization: big Errors-To: contact@big.com Sender: contact@big.com From: "big" <contact@big.com> Reply-To: "big" <contact@big.com> Content-Type: multipart/alternative; boundary=87847890 --48673093 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit <a href="http://big.com/u/jasonGordon?utm_source=beta_invite&utm_medium=email&utm_content=referer_name&utm_campaign=join_beta" alt="Jason Gordon's profile" title="Jason Gordon's profile">Jason Gordon</a> invited you to join the newest community of entreprenuers and investors, big. Why participate in our closed beta? Here you will be able to find, research and connect with entrepreneurs or investor so much easier than ever before. You will be one of the first people to ever lay eyes on our exclusive software! Sign up by clicking <a href="http://big.com/join?9b782e=&key=7RG5poe9lgxmUSIcQTPji8EtFMnXyOYW3Cf&utm_source=beta_invite&utm_medium=email&utm_content=sign_up&utm_campaign=join_beta" title="big Beta Referral">here</a> If the link does not work, go to <a href="http://big.com" title="big">big.com</a>, click "Join big" and enter your closed beta access key. Your closed beta access key is: 7RG5poe9lgxmUSIcQTPji8EtFMnXyOYW3Cf Please leave us feedback so that we can improve our software. big Team --48673093 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Closed Beta Invitation</title> </head> <body> <table width="500px" cellspacing="0" cellpadding="13" style="border: 1px solid #e7e7e7;"> <tr> <td> <table cellspacing="0" cellpadding="5" bgcolor="#ffffff" width="480px" style="border: 1px solid #999999;"> <tr> <td bgcolor="#489fcc" cellspacing="15" style="border-bottom: 1px solid #999999; border-top: 0; border-left: 0; border-right: 0; font-family: verdana; letter-spacing: 1px; font-weight: bold; color: white;" width="480px"> big </td> </tr> <tr> <td> <table style="line-height: 26px; font-family: arial; font-size: 13px;" width="100%" cellspacing="10" cellpadding="0"> <tr> <td width="100%"> <table style="line-height: 26px; text-align: justify;" width="100%" cellpadding="0" cellspacing="0"> <tr> <td width="100%"> <a href="http://big.com/u/jasonGordon?utm_source=beta_invite&utm_medium=email&utm_content=referer_name&utm_campaign=join_beta" alt="Jason Gordon's profile" title="Jason Gordon's profile">Jason Gordon</a> invited you to join the newest community of entreprenuers and investors, big. Why participate in our closed beta? Here you will be able to find, research and connect with entrepreneurs or investor so much easier than ever before. You will be one of the first people to ever lay eyes on our exclusive software! </td> </tr> </table> </td> </tr> <tr> <td align="center" width="100%"> <table style="border-top: 1px solid #b8b8b8; border-bottom: 1px solid #b8b8b8;" width="100%" cellpadding="0" cellspacing="5"> <tr> <td width="100%" align="center"> Sign up by clicking <a href="http://big.com/join?9b782e=&key=7RG5poe9lgxmUSIcQTPji8EtFMnXyOYW3Cf&utm_source=beta_invite&utm_medium=email&utm_content=sign_up&utm_campaign=join_beta" title="big Beta Referral">here</a> </td> </tr> </table> </td> </tr> <tr> <td width="100%" style="text-align: justify;"> If the link does not work, go to <a href="http://big.com" title="big">big.com</a>, click "Join big" and enter your closed beta access key. Your closed beta access key is: </td> </tr> <tr> <td align="center" width="100%"> <table bgcolor="#e6e6e6" style="border: 1px solid #b8b8b8;" width="100%" cellpadding="0" cellspacing="5"> <tr> <td width="100%" align="center"> 7RG5poe9lgxmUSIcQTPji8EtFMnXyOYW3Cf </td> </tr> </table> </td> </tr> <tr> <td width="100%"> Please leave us feedback so that we can improve our software. </td> </tr><tr> <td width="100%"> big Team </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </body> </html> --48673093-- My headers function is... Code: [Select] function mail_header ($type, $random_hash) { $type = (int)$type; if ($type === 0) { $boundary = $random_hash; $x_mailer = phpversion(); $time_stamp = date("r"); $headers = 'Message-ID: <'.$boundary.'-050333@big.com>' . "\r\n"; $headers .= 'Date: ' . $time_stamp . "\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'X-Mailer: PHP-' . $x_mailer . "\r\n"; $headers .= 'X-Sender: "big" <contact@big.com>' . "\r\n"; $headers .= 'X-Priority: 3' . "\r\n"; $headers .= 'Organization: big' . "\r\n"; $headers .= 'Errors-To: contact@big.com' . "\r\n"; $headers .= 'Sender: contact@big.com' . "\r\n"; $headers .= 'From: "big" <contact@big.com>' . "\r\n"; $headers .= 'Reply-To: "big" <contact@big.com>' . "\r\n"; $headers .= 'Return-Path: "big" <contact@big.com>' . "\r\n"; $headers .= 'Content-Type: multipart/alternative; boundary=' . $boundary . "\r\n"; } return $headers; } I am working on a web form in PHP which accepts a Paypal Email address from the user. I need to authenticate (validate or check) if the Paypal email address entered is a valid Paypal email account. Please reply. All comments and feedback are welcomed. Thank you! 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. Hi, I'm new here and new to php. My first attempt at a php project actually so I'm hoping to get some help. I want people to register at my site but I don't want them to put false emails on it. So I used the coding from this website http://www.phpeasystep.com/workshopview.php?id=24 to provide codings for forms and email confirmation links. The process worked up to when I click on the confirmation link (at testing) from the email and the link returns to a blank webpage. No data is transferred from "temp_members_db" table to "registered_members" table at all. I'll attach print screen of my tables. Hoping that someone can point out to me where I'm going wrong as I can't seem to get myself out of this one. Hello, When a user sends a message using my contact form, they will get a confirmation to the supplied email to confirm that the email has been recieved, one problem is, the auto-reply message displays "donotreply@website.com" at the bottom of it, here is some of my code: //AUTO-REPLY CLIENT CODE START $confirmation = $visitor_email; $consubject="Your message has been recieved"; $body2 = "Hello $name, \nThe below message has now been recieved.\n\n >> $user_message <<\n\nWe will reply to you shortly.\n\nThank you,\n\nThe website Team.\n\n\nThis is an automated message, please do not reply to it.\n". $fromnoreply = 'donotreply@website.com'; //AUTO-REPLY CLIENT CODE END //TO WEBMAIL CODE START $to = $your_email; $subject="Contact form - $name"; $from = $visitor_email; $from = $your_email; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $body = "A user $name submitted the contact form:\n". "Name: $name\n". "Email: $visitor_email \n". "Message: \n ". "$user_message\n". "IP: $ip\n"; //TO WEBMAIL CODE END //headers $headers = "From: $from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; $headers2 = "From: $fromnoreply \r\n"; $headers2 .= ""; // the important stuff!, yes definately! JAMES mail($to, $subject, $body,$headers); mail($confirmation, $consubject, $body2,$headers2); header('Location: ?sent'); //where shall i go once message is sent?? Possibly here. *wink* The above code automatically sends the below email to the client aswell as sending the clients message to me. Code: [Select] Hello Bob Smith, The below message has now been recieved. >> This is a test << We will reply to you shortly. Thank you, The website Team. This is an automated message, please do not reply to it. donotreply@website.com My objective is to remove the displayed email at the bottom of the message. Many thanks 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. |