Search the Community
Showing results for tags 'sendmail'.
-
<?php if(isset($_POST['txtEmail'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "xyz@abc.com"; $email_subject = "Subject"; $email_from = "abc@xyz.com"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below."; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['txtName']) || !isset($_POST['txtEmail']) || !isset($_POST['txtAddress']) || !isset($_POST['txtContact']) || !isset($_POST['txtUpload'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $name = $_POST['txtName']; // required $email = $_POST['txtEmail']; // required $address = $_POST['txtAddress']; // required $contact = $_POST['txtContact']; // not required $upload = $_POST['txtUpload']; // required $email_message = "Form Details are below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Full Name: ".clean_string($name)."\n\n"; $email_message .= "Address: ".clean_string($address)."\n\n"; $email_message .= "Email ID: ".clean_string($email)."\n\n"; $email_message .= "Contact No.: ".clean_string($contact)."\n\n"; $email_message .= "File: ".clean_string($upload)."\n\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <?php } ?> i am a rookie in php I got 2 problems 1) I am not able to insert a code for file upload in the above code. 2) In other type of form (with different textfields).i have a text (it is like a disclaimer) in the html form which i want it in email too.
-
hello to you all!.. i have a question about the mail function , i just make a contac form and i try to send it to my gmail account for testing.. it seems that i have no error in the code , when i check the /log/maillog file i show this message: i dont see any error message so i dont know where is tha problem, i hope someone help me ! Aug 8 08:37:11 localhost sendmail[1230]: starting daemon (8.14.7): SMTP+queueing@01:00:00 Aug 8 08:37:11 localhost sendmail[1231]: r780c7Pb008212: r78CbBte001231: sender notify: Warning: could not send message for past 4 hours Aug 8 08:37:11 localhost sm-msp-queue[1304]: starting daemon (8.14.7): queueing@01:00:00 Aug 8 08:37:12 localhost sendmail[1231]: r78CbBte001231: to=root, delay=00:00:01, xdelay=00:00:01, mailer=local, pri=31801, dsn=2.0.0, stat=Sent
-
Hi, I managed to set up a simple smtp with sendmail and gmail in the PHP mail function. The thing is, is it possible to change the "from" email address to a different one, than the gmail account I'm using? No matter which $from I assign, the from address is always my gmail account, which I am using to send mails. Thanks
-
Hi Guys, I am trying to create a script which send a customer an invoice when they place an order. I have written the following code and this works when sent to an email address which is opened using gmail or the iPhone email client, but Microsoft Outlook screams a great big no at me, and just shows me the html in plain text. Any thoughts anyone? I have included the code below: <?php include("includes/conn.php"); $id=1; $random_hash = md5(date('r', time())); $subject="Red Van Tool Sales - Invoice: "; $headers = "From: sales@redvantoolsales.co.uk" . "\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; /*$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $user=isset($_COOKIE['user']) ? $_COOKIE['user'] : null; $sql="select * from user where user_email='$user'"; $sql_res=mysqli_query($conn, $sql) or die(mysqli_error($conn)); while($array=mysqli_fetch_array($sql_res)) { $uid=$array['user_id']; } */ $sql="select * from orders inner join payment_options on orders.payment_options_id=payment_options.payment_options_id inner join postage_options on orders.delivery_id=postage_options.postage_options_id inner join user_address on orders.delivery_address_id=user_address.user_address_id inner join user on orders.user_id=user.user_id where orders.orders_id='$id'"; $sql_res=mysqli_query($conn, $sql) or die(mysqli_error($conn)); $count=mysqli_num_rows($sql_res); if($count==0) { //header("Location:noauth.php"); echo "fail"; } else { while($array=mysqli_fetch_array($sql_res)) { $order_id=$array['orders_id']; $subject .= $order_id; $order_date=date("d/m/Y", $array['orders_date']); $orders_total=number_format($array['orders_total'],2); $order_subtotal=number_format($orders_total/1.2,2); $vat=number_format($orders_total-$order_subtotal,2); $shipping_total=number_format($array['shipping_total'],2); $payment_fee=number_format($array['payment_fee'],2); $payment_options_name=$array['payment_options_name']; $postage_options_name=$array['postage_option_name']; $user_forename=$array['user_forename']; $user_surname=$array['user_surname']; $address_address=$array['address_address']; $address_city=$array['address_city']; $address_postcode=$array['address_postcode']; $shipping_time=$array['postage_option_shipping_time']; $shipping_time = $shipping_time*86400; $expected_arrival=$array['orders_date']+$shipping_time; $expected_arrival=date("d/m/Y", $expected_arrival); $emailto = $array['user_email']; } } ob_start(); //Turn on output buffering ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="http://www.redvantoolsales.co.uk/invoice.css" media="print"> <link rel="stylesheet" type="text/css" href="http://www.redvantoolsales.co.uk/invoice.css" media="screen"> </head> <body> <div id="cont"> <div id="container"> <div id="topbar"> <img class="logo" src="http://www.redvantoolsales.co.uk/images/logo.png"> <div id="companyaddress">Red Van Tools<br>Address<br>City<br>Postcode<br>VAT: 000000000<br>sales@redvantoolsales.co.uk<br>01633 000000<br>www.redvantoolsales.co.uk</div> </div> <div id="nextbar"> <div id="customeraddress"><?php echo $user_forename . " " . $user_surname; ?><br><?php echo $address_address; ?><br><?php echo $address_city; ?><br><?php echo $address_postcode; ?></div> <div id="invoicedetail">INVOICE <?php echo $order_id; ?><br><?php echo $order_date; ?></div> </div> <div id="orderdetailbar"> <table> <tr><th width="333">Payment Method</th><th width="333">Order Date</th><th width="333">Estimated Delivery Date</th></tr> <tr><td><?php echo $payment_options_name; ?></td><td><?php echo $order_date; ?></td><td><?php echo $expected_arrival; ?></td></tr> </table> </div> <div id="orderitembar"> <table> <tr><th width="120">Quantity</th><th width="500">Details</th><th width="120">Unit Price (£)</th><th width="120">VAT</th><th width="120">Net Subtotal (£)</th></tr> <?php $sql="select * from order_item inner join products on order_item.product_id=products.product_id inner join price on products.product_id=price.product_id where orders_id='$id'"; $sql_res=mysqli_query($conn, $sql) or die(mysqli_error($conn)); while($array=mysqli_fetch_array($sql_res)) { $total = number_format($array['product_price']*$array['product_qty'],2); echo "<tr><td>" . $array['product_qty'] . "</td><td>" . $array['product_name'] . "</td><td>" . number_format($array['product_price'],2) . "</td><td>20%</td><td align=\"right\">" . $total . "</td></tr>"; } ?> </table> </div> <div id="totals"> <table> <tr><td>Net Total</td><td><?php echo $order_subtotal; ?></td></tr> <tr><td>VAT</td><td><?php echo $vat; ?></td></tr> <tr><td><b>GBP Total</b></td><td><b>£<?php echo $orders_total; ?></b></td></tr> </table> </div> </div> </div> </body> </html> <?php $message1 = ob_get_clean(); mail( $emailto, $subject, $message1, $headers ); ?> Thanks guys!
-
I'm getting the following error on a contact form I'm trying to implement: Fatal error: Uncaught Error: Undefined constant "secretcode" in /home/foxclo98/test.foxclone.com/contact.php:33 Stack trace: #0 {main} thrown in /home/foxclo98/test.foxclone.com/contact.php on line 33 Here's the full code of the contact form: <?php $errorlevel=error_reporting(); error_reporting($errorlevel & ~E_WARNING); //...code that generates notices error_reporting($errorlevel); // initialization session_start(); $email_contact = "help@foxclone.com"; $email_website = "webmaster@foxclone.com"; // definition of permitted types/subject/category. use to dynamically build the option list, // pre-selecting any existing choice, and used in the validation logic $permitted_types = ['Questions', 'Report Problem', 'Suggestion', 'Other', 'Website Problem']; $secretcode = ['nospam']; $post = []; // array to hold a trimmed working copy of the form data $errors = []; // array to hold user/validation errors // post method form processing if($_SERVER['REQUEST_METHOD'] == 'POST') { // trim all the data at once $post = array_map('trim',$_POST); // if any of the fields are arrays, use a recursive call-back function here instead of php's trim function // inputs: name, email, type/subject/category, message - all required // validate the inputs $errors = []; //Other validation stuff. if ($post['secretcode'] != 'nospam') { $errors[secretcode] = 'You did not enter the correct secret code.'; } if($post['name'] === '') { $errors['name'] = 'Name is required.'; } if($post['email'] === '') { $errors['email'] = 'Email is required.'; } else { // while it is true that the following email format validation will produce an error // for an empty value, you should specifically tell the visitor what is wrong with what // they submitted if (false === filter_var($post['email'], FILTER_VALIDATE_EMAIL)) { $errors['email'] = 'The Email Address you entered does not appear to be valid.'; } } if($post['type'] === '') { $errors['type'] = 'You must select a Type/Subject/Category.'; } else { // you will only see the following error due to a programming mistake or someone/something submitting their own values if(!in_array($post['type'],$permitted_types)) { $errors['type'] = 'The selected Type is invalid.'; // you would want to log the occurrence of this here... } } if($post['message'] === '') { $errors['message'] = 'Message is required.'; } else { if(strlen($post['message']) < 10) { $errors['message'] = 'The Message must be at least 10 characters.'; } } // if no errors, use the submitted data if(empty($errors)) { // apply htmlentities() to help prevent cross site scripting when viewing the received email in a browser $formcontent = htmlentities("From: {$post['name']}\r\nEmail: {$post['email']}\r\nSubject: {$post['type']}\r\nMessage: {$post['message']}", ENT_QUOTES); if ($post['type'] === "Website Problem") { $recipient=$email_website; } else { $recipient=$email_contact; } $email = $post['email']; // add $post['email'] as a Reply-to: header if desired, it is one, valid email address at this point $mailheader = "From: $email\r\n" ; $mailheader .= "Cc: $email\r\n"; if(!mail($recipient, $post['type'], $formcontent, $mailheader)) { // an error // setup the user error message $errors['mail'] = 'The email could not be sent, the site owner has been notified.'; // system error handling goes here... - datatime, get the last error message, include the mail parameter values... // at this point, all parameters are either an internal value, have been validated they they are just an expected // value/format, or have had htmlentities() applied. } // if no errors at this point, success if(empty($errors)) { $_SESSION['success_message'] = "Mail Sent. Thank you {$post['name']}, we will contact you shortly.."; die(header("Refresh:0")); } } } // html document starts here... ?> <?php // display any success message if(!empty($_SESSION['success_message'])) { // for demo purposes, just output it as a paragraph. add any markup/styling you want echo '<p>'; echo htmlentities($_SESSION['success_message'], ENT_QUOTES); echo " - <a href='index.php#home' style='color:#ff0099;'> Return Home</a>"; echo '</p>'; unset($_SESSION['success_message']); } ?> <?php // display any errors if(!empty($errors)) { // for demo purposes, just output them as a paragraph. add any markup/styling you want echo '<p>'; echo implode('<br>',$errors); echo '</p>'; } ?> <?php // (re)display the form here..., re-populating the fields with any existing values ?> <?php require_once("header.php");?> <style> input, select { width: 20rem; line-height:30px; border:2px solid #2f496e; padding: 0; margin: 0; height: 30px; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; font: 500 1rem sans-serif; background: #fff; } .input { text-indent: 3px; } </style> </head> <body> <?PHP require_once("navbar.php"); ?> <!--****************** * CONTACT * *******************--> <div class="head__h1"> Need help? Have a suggestion? Why not send us an email?</div> <div class="subtext"> You'll receive a copy of your inquiry for your records </div> <div class ="download"> <div class="cont__row" style="background-color: #d9b44a;"> <div class="cont__column"> <form method="POST"> <label>Secret Code:</label><br> <input type="text" name="secretcode" id="secretcode" placeholder="Type nospam here"> <br> <br> <label>Name</label><br> <input type="text" name="name"><br> <br> <label>Email</label><br> <input type="email" name="email"><br> <br> <label>Select a Category</label> <br> <select name="type" id="category" size="1"> <option value=''> </option> <option value='Questions'>Questions</option> <option value="Report Problem">Report Problem</option> <option value='Suggestion'>Suggestion</option> <option value='Other'>Other</option> <option value="Website Problem"> Website Problem</option> </select> </div> <div class="cont__column"> <label>Message</label><br> <textarea name="message" rows="10" cols="50" style="font: 500 1rem sans-serif"></textarea><br> <br> <div class="button"> <input type="image" id="myimage" src="images/email1.jpg" style="height:40px; width:160px;"/> </form> </div> </div> </div> </div> <?PHP require_once("footer.php"); ?> I'd appreciate ssome help on this.