PHP - Sending Mail Through Smtp Is Not Sending To Cc Or Bcc Email Address
From our website we are connecting to GMAIL to send our emails through SMTP. For some reason it is not sending the emails to the CC or BCC email address event though GMAIL shows it was included in the email. Am I missing something in the below code?
Code: [Select] $currentTime = time(); $emailTo = "redbrad0@domain.com"; $emailCC = "brad@domain.com"; $emailBCC = "events@domain.com"; $emailSubject = "TEST Email at (" . $currentTime . ")"; $emailBody = "This is the body of the email"; $headers = array(); if (!empty($emailTo)) $headers['TO'] = $emailTo; if (!empty($emailCC)) $headers['CC'] = $emailCC; if (!empty($emailBCC)) $headers['BCC'] = $emailBCC; if (!empty($emailSubject)) $headers['Subject'] = $emailSubject; $headers['From'] = "events@domain.com"; $mime = new Mail_mime("\n"); $mime->setTXTBody($emailBody); $body = $mime->get(); $headers = $mime->headers($headers); $mail = Mail::factory('smtp', array ('host' => 'ssl://smtp.gmail.com', 'auth' => true, 'port' => 465, 'username' => 'events@domain.com', 'password' => 'thepasswordhere')); try { $result = $mail->send($emailTo, $headers, $emailBody); } catch (TixException $ex) { echo "<font color=red>Error:" . $ex->getCode() . "</font><br>"; } echo "Emailed at (" . $currentTime . ")<br>"; die; Similar TutorialsHi I really would appreciate if some phpfreak can help me with this please . I need to my contact page send emails so that when recipient receives it, it comes with the correct domain (same as the web address) it is coming from rather than the server name. At the moment they are coming as abcd20@elessar.nocdirect.com and would like them come as abcd20@myowndomain.com (lets say my password for that email is 'zzzaaa' and the domain was myowndomain.com ) Here is my email contact php script which works fine and hopefully would not have to change too much. My Contact form is posting to 'send.php' . On top of my contacts page there is a js script for 'jquery.js' and some jQuery stuff for validation.. Have seen many scripts but could not adapt to my existing send.php script. Can you please help? ------ Content of 'send.php' ----------------------------------- <?php if(!$_POST) exit; $email = $_POST['email']; //$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS'; if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){ $error.="Invalid email address entered"; $errors=1; } if($errors==1) echo $error; else{ $values = array ('name','email','phone','message'); $required = array('name','email','phone','message'); $your_email = "abcd20@myowndomain.com"; $email_subject = "New Message: ".$_POST['subject']; $email_content = "New message:\n"; foreach($values as $key => $value){ if(in_array($value,$required)){ if ($key != 'subject' && $key != 'company') { if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; } } $email_content .= $value.': '.$_POST[$value]."\n"; } } if(@mail($your_email,$email_subject,$email_content)) { echo 'Message sent!'; } else { echo 'ERROR!'; } } ?> -------------------------------------------------------------------------------- Hi, I am looking for a script which will help me to send prebuilt e-mail to people with attachments. Something like this >>> To : [ ________________ ] <--Textbox Subject : [ _____________] <-- Subject Main body : [___________________] [___________________] [___________________] [___________________] [___________________] <-- with html [ Submit ] I would like to attach 5 photos in .jpg which are hosted on server. Now everything is prebuilt except "To : " as peoples email ID will always change. When Submit is clicked, main body Data and attachment will be sent to "To :" person with SMTP and not php mail() Well I have covered till sending mail with SMTP, using PEAR PHP, but I am not able to send attachments i.e. photos. I have 2 pages, index.php - 1st page which includes form and button sendmail.php - Includes all function and main data Following is the code of sendmail.php <?php include("Mail.php"); include('Mail/mime.php'); $to = $_POST["to_textbox"]; $from = $_POST["from_textbox"]; $subject = $_POST["subject_textbox"]; $message = $_POST["content_textbox"]; $headers = "From: " . $from . "\r\n"; /* SMTP server name, port, user/passwd */ $smtpinfo["host"] = "xbc.pqr.com"; $smtpinfo["port"] = "465"; $smtpinfo["auth"] = true; $smtpinfo["username"] = "user"; $smtpinfo["password"] = "pass"; /////////////////Attachments Section Start ////////////// $file = '/home/xyzuser/public_html/xbx.pqr.com/mail1/img/linux_logo.jpg'; $crlf = "\n"; $mime = new Mail_mime($crlf); $mime->addAttachment($file, 'image/jpeg'); //do not ever try to call these lines in reverse order $attach= $mime->get(); ///////////////Attachment Section ends //////////////// /* Create the mail object using the Mail::factory method */ $mail_object =& Mail::factory("smtp", $smtpinfo); /* Ok send mail */ $mail_object->send($to, $headers, $subject, $message, $attach); ?> Now problem is, it is not sending linux tux logo from "img" folder i.e. mail sent with just text from previous page's textbox. It is not handling with attachment i.e. photo, what to do ? Thanks to http://pear.php.net/manual/en/packag...me.example.php Is this true, i have cookies on my site till i send a form which fires off two emails. the cookies are not only deleted, but i can reset the cookie to the proper values unless i delete all my cookies!! any ideas? $config = Array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.gmail.com', 'smtp_port' => '465', 'smtp_user' => 'removed@removed.nothing', 'smtp_pass' => 'removed' ); but I can't send that email... It show error like this... A PHP Error was encountered Severity: Warning Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) Filename: libraries/Email.php Line Number: 1673 A PHP Error was encountered Severity: Warning Message: fwrite(): supplied argument is not a valid stream resource Filename: libraries/Email.php Line Number: 1816 Hi I am very new to PHP. I'm wanting a feedback form on my website where the form is sent via SMTP rather than sendmail. I have checked that php is working by doing this code: Code: [Select] <?php error_reporting(E_ALL); ini_set('display_errors', True); $path = '/home/****/php'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); echo("<p>Sending PEAR Mail.php...</p>"); require('Mail.php'); $from = "Info <info@***.co.uk>"; $to = "Info <info@***.co.uk>"; $subject = "Hi - Test message!"; $body = "Hi,\n\nHow are you?"; $host = "mail.***.co.uk"; $username = "info@***.co.uk"; $password = "***"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } ?> This works fine. I then created a form in my contact page: Code: [Select] <form name="feedbackform" action="form-mailer2.php" method="post"> <input type="hidden" name="Required" value="Name,Comments"> <p>Name: <input name="Name" size="30"> <span class="formsmall">required</span></p> <p>E-mail: <input name="Email" size="30"> <span class="formsmall">optional</span></p> <p>Feedback/Comments:</p> <p><textarea name="Comments" rows="5" cols="40"></textarea></p> <p><input type="submit" value="Submit" name="submitform"><input type="reset" value="Reset" name="reset"></p> </form> I then used the code based on the php initial example and the code file that would get the form details from the contact page and send to the email address via smtp. I have left the validations in - although if these are no good please feel free to tell me! I will want to put a captcha in but need to look into that yet. Anyway, the code I have created is now this (which is saved in the file form-mailer2.php): Code: [Select] <?php error_reporting(E_ALL); ini_set('display_errors', True); $path = '/home/****/php'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); echo("<p>Sending PEAR Mail.php...</p>"); require('Mail.php'); $mailfrom = "info@***.co.uk"; $mailTo = "info@***.co.uk"; $mailSubject = "Web Feedback"; $mailHost = "mail.***.co.uk"; $mailPort = "25"; $mailAuth = "true"; $mailPassword = "****"; // Get the form fields. $name = $_POST['Name']; $email = $_POST['Email']; $comments = $_POST['Comments']; $reqFields = $_POST['Required']; // I find including the time/date useful for record-keeping. // Note that it is the web server's time/date, not yours // or the sender's. $date = date("l jS F Y, g:i A"); // A simple yet reasonably effective email address validator. if ((!ereg(".+\@.+\..+", $email)) || (!ereg("^[a-zA-Z0-9_@.-]+$", $email))) { $errorMessages .= "<li>Invalid email address: $email</li>"; } // Make sure required fields are filled in. $checkFields = explode(",",$reqFields); while(list($theField) = each($checkFields)) { if(!$$checkFields[$theField]) { $errorMessages .= "<li>Missing $checkFields[$theField]</li>"; } } // If there are errors, display them and a back button. if($errorMessages) { ?> <p>Errors were found on the form.</p> <ul> <?php echo $errorMessages; ?> </ul> <p><input type="button" value="Back" onClick="history.back()"></p> <?php } // No errors, send the message and print out success message. else { // Build the email. $body = " Name: $Name Email: $Email Phone: $Phone ----- Comments ----- $Comments -------------------- $headers["From"] = $mailTo; $headers["To"] = $mailTo; $headers["Subject"] = $mailSubject; $params["host"] = $mailHost; $params["port"] = $mailPort; $params["auth"] = $mailAuth; $params["username"] = $mailTo; $params["password"] = $mailPassword; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($mailTo, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } // I would rather redirect to a different thank you page but both of next options don't work when taking out: echo("<p>Message successfully sent!</p>"); //RedirectToURL("thank-you.php"); or header(Location: "thank-you.php" ); ?> Depending on what I change about I either get: The website cannot display the page or a list of undefinable variables. If anyone is able to understand the php and notice where the problem lies I would be so grateful. Thank you. Hi, I'm trying to make an order form in php, basically I want the email to be sent to different email address in different email format, but I'm stuck with the code, can anyone help me with this, please? I've been trying to figure it out for a couple of days but I still can't solve it, my background is not in programming so, I think this must be really easy for programmers, but it's been causing me a headache. Below is the code that I've been stuck. <?PHP /* SUBJECT AND EMAIL VARIABLE */ $emailSubject = ' crystal ashley order form '; $webMaster = 'tjoengkikitjahyadi@gmail.com, james.k.tj@gmail.com '; /* gathering data variable */ $emailField = $_POST['email'] ; $recipientField = $_POST['recipient'] ; $nameField = $_POST['name'] ; $phoneField = $_POST['phone'] ; $codeField = $_POST['code'] ; $quantityField = $_POST['quantity'] ; $hearField = $_POST['hear'] ; $classField = $_POST['class'] ; $commentsField = $_POST['comments'] ; $body = <<<EOD <br><hr><br> Email : $email <br> Recipient : $recipient <br> Phone : $phone <br> Code : $code <br> Code : $code2 <br> Hear from : $hear <br> Interested in : $class <br> Comments : $comments <br> <br> EOD; $headers = "From : $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); Email : $email <br> Name : $name <br> Phone : $phone <br> Code : $code <br> Code : $code2 <br> Hear from : $hear <br> Interested in : $class <br> Comments : $comments <br> <br> EOD; $headers = "From : $email\r\n"; $headers = "To : $recipient\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /*results rendered as html*/ $theResults = <<<EOD <html> <head> <title>Real Yoga Enquiry Form</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- body { background-color: #f1f1f1; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; line-height: normal; font-weight: normal; color: #666666; text-decoration: none; } --> </style> </head> <div> <div align="left">Thank you for your interest! Your email will be answered very soon!</div> </div> </body> </html> EOD; echo "$theResults"; ?> Hi folks, I just found this group and joined up! I have encountered a problem that I am not sure how to resolve, and I hope someone can assist. I run this query against my MySQL database: mysql_select_db($database_commdb, $commdb); $query_rsEmailAddress = "SELECT admin_email FROM tbl_admins WHERE admin_id = 1"; $rsEmailAddress = mysql_query($query_rsEmailAddress, $commdb) or die(mysql_error()); $row_rsEmailAddress = mysql_fetch_assoc($rsEmailAddress); $totalRows_rsEmailAddress = mysql_num_rows($rsEmailAddress); ...and want to use the result to populate the "mail to" field for my response form. (I'm doing this to avoid having my email address posted in a page to be skimmed.) I presently use this: $to = rsEmailAddress['admin_email']; I do some empty fields checking before submitting the form. However, when I click on submit, my form, tells me I have empty fields and will not process when there are NO empty fields. HOWEVER, if I hard-code my email address in the variable "$to" all is well, the form processes correctly, I get the email, etc... So I suspect the problem lies somewhere in the way I have constructed the $to variable. I have scratched my head till I am going bald(er) and my scalp is bleeding!!! HELP!! Please!! Everything 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); As my titel indicates, I have a problem with a piece of code I wrote some time ago. Everything in my mail form is fine and the mails do get send. But they don't always arrive (checked spam folder). Hotmail or example arrives but a normal email adres from a provider does not. Could this have something to do with SMTP ? could I add this to my code ? I tryed some but so far it does not work, In the code below you can see my working code as it is & the tests I tryed and didn't work out that well. Code: [Select] <?php $fromemail="No-Reply <ikwerkthuis.be>"; // change here if you want $toemail=$naarwie; // change here if you want $sub="Online info aanvraag"; // change here if you want $success_page_name="bedankt.html"; ////// do not change in following if($_SERVER['REQUEST_METHOD']=="POST") { $fieldnm_1=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_1'])); $fieldnm_2=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_2'])); $fieldnm_3=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_3'])); $fieldnm_4=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_4'])); $fieldnm_5=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_5'])); $fieldnm_6=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_6'])); $fieldnm_7=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_7'])); $contentmsg=stripslashes('<br><b><font style=color:#CC3300>'. $sub .'</font></b><br> <table width=708 border=0 cellpadding=2 cellspacing=1 bgcolor=#CCCCCC> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Voornaam *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_1 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Achternaam *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_2 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>E-mail *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_3 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Telefoon *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_4 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Werkstatus *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_5 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Leeftijd *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_6 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Regio *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_7 .'</td> </tr> </table><br> Contactpersoon: '. $naarwie .'<br> IP: '. $IP .'<br> Date: '. $DATE .'<br> Time: '. $TIME .' '); //// $headers = "MIME-Version: 1.0 "; $headers .= "Content-type: text/html; charset=iso-8859-1 "; $from=$fromemail; $headers .= "From: ".$from." "; @mail($toemail,$sub,$contentmsg,$headers);?> The code below is the code I tryed to apply to the code above that work. Code: [Select] <?php $fromemail="No-Reply <noreply@ikwerkthuis.be>"; // change here if you want $toemail=$naarwie; // change here if you want $sub="Online info aanvraag"; // change here if you want $success_page_name="bedankt.html"; $host = "ikwerkthuis.be"; $username = "noreply@ikwerkthuis.be"; $password = "hl2012"; ////// do not change in following if($_SERVER['REQUEST_METHOD']=="POST") { $fieldnm_1=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_1'])); $fieldnm_2=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_2'])); $fieldnm_3=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_3'])); $fieldnm_4=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_4'])); $fieldnm_5=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_5'])); $fieldnm_6=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_6'])); $fieldnm_7=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_7'])); $contentmsg=stripslashes('<br><b><font style=color:#CC3300>'. $sub .'</font></b><br> <table width=708 border=0 cellpadding=2 cellspacing=1 bgcolor=#CCCCCC> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Voornaam *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_1 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Achternaam *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_2 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>E-mail *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_3 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Telefoon *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_4 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Werkstatus *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_5 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Leeftijd *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_6 .'</td> </tr> <tr> <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Regio *:</b> </td> <td width=565 align=left valign=top bgcolor=#FFFFFF>'. $fieldnm_7 .'</td> </tr> </table><br> Contactpersoon: '. $naarwie .'<br> IP: '. $IP .'<br> Date: '. $DATE .'<br> Time: '. $TIME .' '); //// $headers = "MIME-Version: 1.0 "; $headers .= "Content-type: text/html; charset=iso-8859-1 "; $from=$fromemail; $headers .= "From: ".$from." "; $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); @mail = $smtp->send($toemail,$sub,$contentmsg,$headers); ?> I hope someone can help me out. Thanks in advance ! I have an HTML form that I have a "select" drop-down menu that is selecting the name of the person you should send to. The names are being pulled from the Database, and here is what that code for the drop-down in the form looks like: <?php echo '<select name= "First_Name" , "Last_Name">'; while( $array = mysql_fetch_assoc($result) ) { $text_for_select = $array["First_Name"] . " " . $array["Last_Name"]. " " . $array["District"]; $value_for_select = $array["First_Name"] . " " . $array["Last_Name"] . "_" . $array["id"]; echo "<option></option>\n"; echo "<option value=\"$value_for_select\">$text_for_select</option>\n"; } echo '</select>';?> This works perfectly. However, what I want it to do is send the form to the email address of the person that is selected in the drop-down. The email address' are already entered in each record of the database in a field called "Email". I am using the $value_for_select variable to pull the id of the record, but I am unsure how to then tell the form to send to the email address of that record? Anybody know a way that this can be done? Here is the code of the for that should be sent: <?php if($_POST){ $to = $email; $subject = "WHAT SHOULD THIS BE"; $message = "Date: $date\n\r". "Dear $First_Name, $Last_Name,\n\r". "Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah.Blah Blah BLah..\n\r". "Sincerely,\n". "$name \n". "$street \n". "$city, $zip \n". "$email \\n". $headers = "From: $email"; mail($to, $subject, $message, $headers); // SUCCESS! echo '<p class="notice">'. 'Thank you for your submission. '. '</p>'; // clear out the variables for good-housekeeping unset($date,$legislator,$bill,$name,$street,$city,$zip,$email); $_POST = array(); } ?> Please help! Okay, below is my mailer for a contact form i created. On one site it works fine. I even have it sending to several addresses from the othersite. However this site it doesnt want to work. PHP5 and mail() function is active. <?php $Name = Trim(stripslashes($_POST['fullname'])); $EmailFrom = Trim(stripslashes($_POST['email'])); $EmailTo = "james@jd-creations.co.uk"; $Subject = Trim(stripslashes($_POST['subject'])); $answer = Trim(stripslashes($_POST['answer'])); $Comments = Trim(stripslashes($_POST['message'])); $Subject = "The Reason - Contact Us"; // validation $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (Trim($answer)!=="20") $validationOK=false; if (Trim($Name)=="") $validationOK=false; if (Trim($Comments)=="") $validationOK=false; if (Trim($Subject)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=../contact/error2.php\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Email: "; $Body .= $EmailFrom; $Body .= "\n"; $Body .= "Comments: "; $Body .= $Comments; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=../contact/sent.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=../contact/error.php\">"; } ?> now i know it is wroking because it takes me to the sent.php page. not error.php i think it worked once. now not at all. Hi Everyone, I am trying to send email with the mail() function as per instructions at: http://php.net/manual/en/function.mail.php without success. The mail sends but when it arrives it doesn't render properly, I see all of the html tags with the data that's sent. My code is below: Code: [Select] <?php function processFormData($array, $form) { $errors = NULL; $message = NULL; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers = "From: <chuck@deneb-consulting.com>" . "\r\n"; $headers .="Cc: <tinwakr@bell.net>" . "\r\n"; $headers .= "Reply-to: <chuck@deneb-consulting.com>" . "\r\n"; $headers .= "X-Mailer: PHP/" .phpversion() . "\r\n"; foreach($array as $key => $value) { //if any of the form values are empty catch them and add to error array if(empty($value) && $key != 'submit') { //build error list $errors .= '"' . str_replace('_', ' ', $key) . '" is a required field!<br />'; } else if(!empty($value) && $key != 'submit') { //capture values and insert them into a session variable $_SESSION[$key] = $value; } } if(empty($errors)) { $message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\r\n"; $message .= '<html><head><title>' . $form .'</title></head>' . "\r\n" . '<body><table border="1">' . "\r\n"; foreach($array as $key => $value) { //regular expression check for phone number if(str_replace('_', ' ', $key) == 'Phone Number' && !preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $value)) { return 'Please enter a valid phone number!'; } //regular expression check for email if(str_replace('_', ' ', $key) == 'Email Address' && !preg_match("/^[A-Z0-9._%-]+@[A-Z0-9][A-Z0-9.-]{0,61}[A-Z0-9]\.[A-Z]{2,6}$/i", $value)) { return 'Please enter a valid email address!'; } if($key != 'submit') { $message .= '<tr><td>' . $key . '</td><td>' . $value . '</td></tr>' . "\r\n"; } } $message .= '</table></body></html>' . "\r\n"; mail("chuck@deneb-consulting.com", $form, str_replace("_", " ", $message), $headers); return 'Thank you, someone will contact you shortly.'; } else { return $errors; } } ?> Thanks in advance for all replies, Chuck I have no idea what im doing wrong but this just isnt working, theres no error messages but im not getting any of the emails. Here is all the code that i had anything to do with editing, i have removed any personal info from it. Code: [Select] <?php $dbhost = 'localhost'; $dbuser = ' '; $dbpass = ' '; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db(" ", $conn); $result = mysql_query("SELECT ****, ********** FROM **** WHERE name='*****'"); while($row = mysql_fetch_array($result)) { $message = "<p><u><b><font size=\"5\" color=\"#800080\">********************</font></b></u></p> <p><b><font color=\"#800080\" size=\"4\">**************************************************</font></b></p> <p><b><font color=\"#800080\">*********</font></b> <b><font color=\"#333333\">**********</font></b></p> <p><b><font color=\"#800080\">********</font></b> <font color=\"#333333\"><b>***********</b></font></p> <p><font color=\"#800080\"><b>*******</b></font> <font color=\"#333333\"><a href=\"***********************************************</a></font></p> <p> </p>"; } $query=mysql_query('SELECT `email`,`name` FROM `users`'); //grab emails and names from database while($row = mysql_fetch_array($query)) //start a loop to send an email to each individual { //mail function with $row['email'] as the email address //I'm using phpmailer as an example here - - > include_once('phpMailer/class.phpmailer.php'); $mail = new PHPMailer(); // defaults to using php "mail()" $body = $message; //message inside the email $mail->From = "**************"; //email address that the email is being sent from $mail->FromName = "*************"; //more in depth for who the mail is from. $mail->Subject = "***********************************"; //The subject for the message //$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->AddAddress($row[email], $row['name']); } mysql_close($conn); ?> I have a notification system that notifies users of new comments, inside the email I have images, some of the logo, some of different people, everything shows up fine on my computer (yahoo email), however in the iPhones email application no images show up, there are just the blue squares with the question marks in them. I'm not sure what I'm missing. Code: [Select] $from = "Kithell <notifications@kithell.com>"; $headers = "From:" . $from ."\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $subject = name($from_id, 'fl').$action; $message = '<html><body> <style>@charset "utf-8"; /* CSS Document */ .e-container { background-color: #FFF;position: relative;width: 90%;min-height:1px;margin-right: auto;margin-left: auto; } .e-container .e-m-header { padding: 2px; background-image: url(http://www.kithell.com/assets/tall-grey-header.png); background-repeat: repeat-x; border: 1px solid #CCC; background-position: bottom; display: block; text-align: center; } .e-container p { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; color: #666; vertical-align: text-top; display: inline-block; } .e-container .e-usr-photo { display: inline-block; margin: 10px; float: left; background-color: #F4F4F4; } .e-container p a { font-weight: bold; color: #3F60A3; text-decoration: underline; padding: 0px; float: left; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 0px; } .e-container .e-quotes { font-size: 20px; font-weight: bold; color: #999; font-family: Tahoma, Geneva, sans-serif; display: block; padding: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 75px; margin-top:10px; } .e-container .e-message { font-size: 13px; color: #333; padding: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 10px; clear: none; display: inline; }</style> <div class="e-container"><div class="e-m-header"><img src="http://www.kithell.com/assets/kithell-logo.png" /></div><img class="e-usr-photo" src="http://www.kithell.com/'.photo($from_id, 55).'" /><br /><p><a target="_blank" href="http://www.kithell.com/#/profile&id='.$from_id.'">'.name($from_id, "fl").' </a> '.$action.'<div class="e-quotes">"<p class="e-message">'.nl2br(htmlentities(stripslashes($message))).'</p>"</div></p></div></body></html>'; mail($to,$subject,$message,$headers); Hi I have a simply working SMTP form, however I need this to send to a yahoo.com email address, what can I add to achieve this? SmtpConfig.php ============== <?php //Server Address $SmtpServer="91.186.30.25"; $SmtpPort="25"; //default $SmtpUser="things@wilsoncarandvanrental.co.uk"; $SmtpPass="things123"; ?> SmtpClass.php ============= <?php class SMTPClient { // A function for Setting up SMTP function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body) { $this->SmtpServer = $SmtpServer; $this->SmtpUser = base64_encode ($SmtpUser); $this->SmtpPass = base64_encode ($SmtpPass); $this->from = $from; $this->to = $to; $this->subject = $subject; $this->body = $body; //Setting Default port Value if ($SmtpPort == "") { $this->PortSMTP = 25; } else { $this->PortSMTP = $SmtpPort; } } //Sending the Mail function SendMail () { if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP)) { fputs ($SMTPIN, "EHLO ".$HTTP_HOST."\r\n"); $talk["hello"] = fgets ( $SMTPIN, 1024 ); fputs($SMTPIN, "auth login\r\n"); $talk["res"]=fgets($SMTPIN,1024); fputs($SMTPIN, $this->SmtpUser."\r\n"); $talk["user"]=fgets($SMTPIN,1024); fputs($SMTPIN, $this->SmtpPass."\r\n"); $talk["pass"]=fgets($SMTPIN,256); fputs ($SMTPIN, "MAIL FROM: <".$this->from.">\r\n"); $talk["From"] = fgets ( $SMTPIN, 1024 ); fputs ($SMTPIN, "RCPT TO: <".$this->to.">\r\n"); $talk["To"] = fgets ($SMTPIN, 1024); fputs($SMTPIN, "DATA\r\n"); $talk["data"]=fgets( $SMTPIN,1024 ); fputs($SMTPIN, "To: <".$this->to.">\r\nFrom: <".$this->from.">\r\nSubject:".$this->subject."\r\n\r\n\r\n".$this->body."\r\n.\r\n"); $talk["send"]=fgets($SMTPIN,256); //CLOSE CONNECTION AND EXIT ... fputs ($SMTPIN, "QUIT\r\n"); fclose($SMTPIN); // } return $talk; } } ?> mail.php ======== <?php //Include Class And Config include('SmtpConfig.php'); include('SmtpClass.php'); //Check the Request Method if($_SERVER["REQUEST_METHOD"] == "POST") { $to = $_POST['to']; $from = $_POST['from']; $subject = $_POST['sub']; $body = $_POST['message']; // Send the mail Using the class $SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body); $SMTPChat = $SMTPMail->SendMail(); } // After Exit, show the form ?> <form method="post" action=""> To:<input type="text" name="to" /> From :<input type='text' name="from" /> Subject :<input type='text' name="sub" /> Message :<textarea name="message"></textarea> <input type="submit" value=" Send " /> </form> Probably quite straight form, but of course I don#t know how :0) Much appreciated. I'm setting up a newsletter thing for my website. I have a newsletter table in MySQL: Quote +----------------+------+--------+ | email | mens | womens | +----------------+------+--------+ | test2@test.com | 1 | 1 | | test1@test.com | 1 | 0 | +----------------+------+--------+ I am using a HTML form and this PHP code I learn't from the manual, which sends out e-mail's. PHP: if ($_POST['newsletter'] == 'Mens') { $to = ''; $subject = $_POST['subject']; $body = $_POST['body']; $header = 'From: Me Someone <me@someone.com>'; mail($to, $subject, $body, $header); } What I want to do with the above code is send out an e-mail to all the e-mails in my MySQL database that are tagged '1' under mens. How would I go about doing this? I'm guessing I will have to use a MySQL query in the $to = ''; that goes something like this: $to = '$query (select from `newsletters` where `email` = 1'); ? Hello to all out there! this is my first post,so my question may sound a bit simple. :] I am studying PHP and MySQL and I tried to make a mailing form based on a mysql database. My problem occured when I tried to use the PEAR mail object. Here is my code: // THE INCLUDED FILES require_once ("attach_file.php" ); require_once ("Mail.php" ); require_once ("Mail\mime.php" ); //THE VARIABLES TAKEN FROM THE HTML FORM OR JUST CREATED FOR THE CONSTRUCTION OF THE EMAIL $my_email = "something@gmail.com"; $email_subject = mysql_real_escape_string(trim( $_POST['email_subject']),$server_connect ); $email_body = mysql_real_escape_string(trim( $_POST['email_body'] ),$server_connect ); $attached_file = $destination ; // the $destination variable comes from the copy() function in attach_file.php $username = "the_username@gmail.com"; $password = "the_password"; $host = "smtp.gmail.com"; $attach = new Mail_mime(); $attach -> addAttachment($attached_file); $email_body = $attach->get(); $extraheaders = array('from'=>$my_email,'to'=>$email_etaireias,'subject'=>$email_subject,'Bcc'=>$email_etaireias); $headers = $attach -> $headers($extraheaders); // HERE GIVES ME AN ERROR!!! -->Fatal error: Method name must be a string $smtp_info = array('host'=>$host,'auth'=>TRUE,'username'=>$username,'password'=>$password); $smtp = Mail::factory('smtp',$smtp_info); //loop through every single line of the database until there are no more lines with data //and store each line in 3 different variables that i can use while ( $row = mysql_fetch_array($result) ) { $onoma_etaireias = $row['onoma_etaireias']; $email_etaireias = $row['email_etaireias']; $website_etaireias = $row['website_etaireias']; } //construct the mail function . The @ is supressing the errors created .remove it and they will be shown. $mail = @$smtp->send($email_etaireias,$headers,$email_body); As i searched here and there for a solution, i found that it has something to do with the way the mail-mime object creates the body of the email . I also tried to find a solution from the PEAR documentation. do i create the headers someway wrong????? Hi
I am trying to use mail(), but when I try it i am not receiving the email. Code is as follows
$username=$_POST['username']; $email=$_POST['email']; $password=$_POST['password']; //email user $from='registrations@ispeedwayscores.com'; $to=$email; $subject='Thank you for registering at iSpeedwayScores'; $message ='<html> <body bgcolor="#000000" style="color:#FF9900; font:Verdana, Arial, Helvetica, sans-serif"> <center> <h1>Welcome to iSpeedwayScores</h1> <br/> <p>Hi!</p> <br> <p>Thank you for joining iSpeedwayScores, this is your <b>FREE</b> online speedway scorecard site.</p> <p>Your login details are provided below:</p> Username: '.$username.'<br/> Password: '.$password.'<br/> <p>We hope you enjoy using the site, if you do, please tell others, if not please tell us</p> <h3>iSpeedwayScores</h3> </body> </html>'; //end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; //options to send to cc+bcc $headers .= "Bcc: mark@bravo14.co.uk"; // now lets send the email. if(mail($to, $subject, $message, $headers)){ $message=" Message sent successfully"; $regsuccess = "Message sent successfully"; } else{ $message=" Message not sent"; $regfailure ="Message not sent"; } <?php $site_email = $row["example@madhost.co"]; $email25=$_REQUEST['email']; $action=$_REQUEST['action']; if ($action=="") /* display the contact form */ { ?> <form id="ContactForm" action="" method="POST" enctype="multipart/form-data"> <input type="hidden" name="action" value="submit"> <div> <div class="wrapper"> <span>Your Name:</span> <input type="text" class="input" name="name" maxlenght="15"> </div> <div class="wrapper"> <span>Your E-mail:</span> <input type="text" class="input" name="email" > </div> <div class="textarea_box"> <span>Your Message:</span> <textarea name="textarea" cols="1" rows="1"></textarea> </div> <input type="submit" class="button1"> <a href="contact.php" class="button1">Clear</a> </div> </form> <?php } else /* send the submitted data */ { $name=$_REQUEST['name']; $email=$_REQUEST['email']; $message=$_REQUEST['textarea']; if (($name=="")||($email=="")||($message=="")) { echo "All fields are required, please fill <a href=\"\">the form</a> again."; } else{ $from="From: $name<$email>\r\nReturn-path: $email"; $subject= $subject1; mail($to =$site_email, $message, $from); echo " <div class=\"contactform\"> Thank you for contacting us, please wait for our reply! </div> "; } } ?>The only problem is that im not recieving the email :/ Any Help ? I would really appreciate it and thank you I have found it a bit strange recently how i stopped receiving online emails from my website, we havnt changed the code as far as i am aware. but for some reason neither the user or staff receives an email the code below is our process for the mail. please could somebody advise why? <?php $host="localhost"; // Host name $username="HIDDEN"; // Mysql username $password="HIDDEN"; // Mysql password $db_name="HIDEEN"; // Database name $tbl_name="HIDDEN"; // Table name $name = $_POST['name']; $email = $_POST['email']; $web = $_POST['web']; $tel = $_POST['tel']; $sub = $_POST['sub']; $message = $_POST['message']; $ip = $_SERVER['REMOTE_ADDR']; $datetime=date("d-m-y"); //date time // validation function is_valid_email($email) { return preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s]+\.+[a-z]{2,6}))$#si', $email); } if (!is_valid_email($email)) { print "<meta http-equiv=\"refresh\" content=\"0;URL=../Contact/?sent=error\">"; exit; } $validationOK=true; if (Trim($name)=="") $validationOK=false; if (Trim($email)=="") $validationOK=false; if (Trim($tel)=="") $validationOK=false; if (Trim($sub)=="") $validationOK=false; if (Trim($message)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=../Contact/?sent=error\">"; exit; } $EmailFrom = Trim(stripslashes($_POST['email'])); $EmailTo = "info@msukgroup.co"; $Subject2 = Trim(stripslashes($_POST['sub'])); $Name = Trim(stripslashes($_POST['name'])); $Comments = Trim(stripslashes($_POST['message'])); $Subject = "MSUKGroup - Thankyou For Contacting "; // STAFF EMAIL $staffmail = ' <!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" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>MSUKGroup</title> <style> p { margin-top:0; margin-bottom:4px; } </style> </head> <body style="color: #666666; font-size:small; font-family:Franklin Gothic Book"> <table style="width: 516px; height: 42px;" cellspacing="0" cellpadding="0"> <!-- MSTableType="layout" --> <tr> <td valign="top" style="height: 42px; width: 516px"> <table style="width: 500px; height: 42px;" cellspacing="0" cellpadding="0"> <!-- MSTableType="layout" --> <tr> <td valign="top" style="height: 42px; width: 500px"> <img src="http://msukgroup.co/img/logos/orange.png" width="323" height="42" /></td> </tr> </table> </td> </tr> </table> <p>Dear ' . $name . ',</p> <p>Thankyou for contacting the MSUKGroup via our online submission form. A relevant representative will be with you within 24 hours to assist you further with your query. </p> <p>Here is what we gathered from your query:</p> <table style="width: 100%" cellspacing="4" cellpadding="0"> <tr> <td style="width: 60px" align="right"><strong> Name:</strong></td> <td> ' . $name . '</td> </tr> <tr> <td style="width: 60px" align="right"><strong> Email:</strong></td> <td> ' . $email . '</td> </tr> <tr> <td style="width: 60px" align="right"><strong> Website:</strong></td> <td> ' . $web . '</td> </tr> <tr> <td style="width: 60px" align="right"><strong> Tel:</strong></td> <td> ' . $tel . '</td> </tr> <tr> <td style="width: 60px" align="right"><strong> Subject:</strong></td> <td> ' . $sub . '</td> </tr> <tr> <td style="width: 60px" align="right"><strong> Message:</strong></td> <td> ' . $message . '</td> </tr> </table> <p>In the meantime, if you have any unanswered questions please take a look around our website and you&#39;ll find out more about our group and services.</p> <p><img src="http://msukgroup.co/img/logo3.png" width="129" height="21" /></p> <p>Hosting - Designs - eCommerce - Solutions - Events and more...</p> <p><strong>Web:<br /> </strong><a href="http://www.msukgroup.co"><span style="color:#FF7800">http://www.msukgroup.co</span></a></p> <p><strong>Email:<br /> </strong><a href="http://www.msukgroup.co"><span style="color:#FF7800"> info@msukgroup.co</span></a></p> </body> </html> '; // USER EMAIL $usermail = ' <!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" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>MSUKGroup</title> <style> p { margin-top:0; margin-bottom:4px; } </style> </head> <body style="color: #666666; font-size:small; font-family:Franklin Gothic Book"> <table style="width: 516px; height: 42px;" cellspacing="0" cellpadding="0"> <!-- MSTableType="layout" --> <tr> <td valign="top" style="height: 42px; width: 516px"> <table style="width: 500px; height: 42px;" cellspacing="0" cellpadding="0"> <!-- MSTableType="layout" --> <tr> <td valign="top" style="height: 42px; width: 500px"> <img src="http://msukgroup.co/img/logos/orange.png" width="323" height="42" /></td> </tr> </table> </td> </tr> </table> <p>Hello Admin,</p> <p>' . $name . ' has sent a message using the contact form on the site.<br> <strong>Date Message Sent: ' . $datetime . ' <br> IP Address: ' . $ip . ' </strong><br> </p> <p>Here is what we gathered from their query:</p> <table style="width: 100%" cellspacing="4" cellpadding="0"> <tr> <td style="width: 60px" align="right"><strong> Name:</strong></td> <td> ' . $name . '</td> </tr> <tr> <td style="width: 60px" align="right"><strong> Email:</strong></td> <td> ' . $email . '</td> </tr> <tr> <td style="width: 60px" align="right"><strong> Website:</strong></td> <td> ' . $web . '</td> </tr> <tr> <td style="width: 60px" align="right"><strong> Tel:</strong></td> <td> ' . $tel . '</td> </tr> <tr> <td style="width: 60px" align="right"><strong> Subject:</strong></td> <td> ' . $sub . '</td> </tr> <tr> <td style="width: 60px" align="right"><strong> Message:</strong></td> <td> ' . $message . '</td> </tr> </table> <p>He has been notified of a 24 hour wait so please respond within this time frame.</p> <p><img src="http://msukgroup.co/img/logo3.png" width="129" height="21" /></p> <p>Hosting - Designs - eCommerce - Solutions - Events and more...</p> <p><strong>Web:<br /> </strong><a title="MSUKGroup" href="http://www.msukgroup.co"><span style="color:#FF7800">http://www.msukgroup.co</span></a></p> <p><strong>Email:<br /> </strong><a href="http://www.msukgroup.co"><span style="color:#FF7800"> info@msukgroup.co</span></a></p> </body> </html> '; // 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: DO NOT REPLY - MSUKGroup <noreply@msukgroup.co>' . "\r\n"; // Mail it mail($EmailTo, $Subject2, $usermail, $headers); mail($EmailFrom, $Subject2, $staffmail, $headers); // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$db_name")or die("cannot select DB"); $sql="INSERT INTO $tbl_name(name, email, web, tel, sub, message, date, ip)VALUES('$name', '$email', '$web', '$tel', '$sub', '$message', '$datetime', '$ip')"; $result=mysql_query($sql); //check if query successful if($result){ print "<meta http-equiv=\"refresh\" content=\"0;URL=../Contact/?sent=successful\">"; } else { print "<meta http-equiv=\"refresh\" content=\"0;URL=../Contact/?sent=error\">"; } mysql_close(); ?> |