Jump to content

Search the Community

Showing results for tags 'email'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








  1. I've decided to share my post from the JavaScript forum here in case this is the more appropriate place. It's involving MODALS with Bootstrap & JQuery and my question is below. Thank you.
  2. I'm working on a Contact Form for my website. It works, except the "Phone" field doesn't show a phone number in the sent message. It's just blank where the number should be displayed. What am I doing wrong? - Thanks HTML: <div class="contact-form"> <h2 class="style">Contact Us</h2> <form action="contact.php" method="post" id="form"> <div> <span><label>NAME</label></span> <span><input name="cf_name" type="text" class="textbox"></span> </div> <div> <span><label>EMAIL</label></span> <span><input name="cf_email" type="text" class="textbox"></span> </div> <div> <span><label>PHONE</label></span> <span><input name="cf_phone" type="text" class="textbox"></span> </div> <div> <span><label>MESSAGE</label></span> <span><textarea name="cf_message"> </textarea></span> </div> <div> <span><input type="submit" value="Send"></span> </div> </form> </div> PHP: <?php $field_name = $_POST['cf_name']; $field_email = $_POST['cf_email']; $field_phone = $_POST['cf_phone']; $field_message = $_POST['cf_message']; $mail_to = 'somebody@invalid.com'; $subject = 'Message from a website visitor '.$field_name; $body_message = 'From: '.$field_name."\n"; $body_message .= 'E-mail: '.$field_email."\n"; $body_message .= 'Phone: '.$field_phone."\n"; $body_message .= 'Message: '.$field_message; $headers = 'From: '.$field_email."\r\n"; $headers .= 'Reply-To: '.$field_email."\r\n"; $mail_status = mail($mail_to, $subject, $body_message, $headers); if ($mail_status) { ?> <script language="javascript" type="text/javascript"> alert('Thank you for the message. We will contact you shortly.'); window.location = 'index.html'; </script> <?php
  3. Sigmahokies

    PHP email

    Hi everyone, Can anyone help me underatdn why my email in php didn't work. I set up the email form in web, seem it didn't send at all. I put boolean with email, then I tested to fill out text to send email, then it said it didn't send email at all. What did I do wrong? <?php $error = ""; if($_SERVER['REQUEST_METHOD'] == "POST") { if (empty($_POST['email'])) { $error = "<tr><td colspan='2'>E-mail is required</td></tr>"; } elseif (empty($_POST['FirstName'])) { $error = "<tr><td colspan='2'>First Name is required</td></tr>"; } elseif (empty($_POST['LastName'])) { $error = "<tr><td colspan='2'>Last Name is required</td></tr>"; } elseif (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { $error = "<tr><td colspan='2'>Invalid e-mail format</td></tr>"; } else { $first = $_POST['FirstName']; $last = $_POST['LastName']; $email = $_POST['email']; $comment = $_POST['comment']; $title = $_POST['Title']; $emailGary = "XXXX@gmail.com"; if(mail($emailGary, $title, $comment)) { $sent = "<tr><td colspan='2'>E-mail has been sent</td></tr>"; } else { $sent = "<tr><td colspan='2'>E-mail has not sent</td></tr>"; } } } ?> <body class="background"> <h5><a href="#garydtaylor">XXXX</a></h5> <div class="w3-row"> <div class="w3-col" style="width:300px; text-align: left; padding-left: 50px;"><p>Hello</p></div> <div class="w3-rest w3-round" style="text-align: left; padding-left: 50px;"><p>Hello</p> <form action="resume.php" method="post"> <table cellpadding="5"> <tr><td>* First Name:</td><td><input type="text" name="FirstName"></td></tr> <tr><td>* Last Name:</td><td><input type="text" name="LastName"></td></tr> <tr><td>* Title:</td><td><input type="text" name="Title"></td></tr> <tr><td>* Email:</td><td><input type="text" name="email"></td></tr> <tr><td valign="top">* Comment:</td><td><textarea maxlength="5000" cols="18" rows="6" type="text" name="comment"></textarea></td></tr> <tr></tr><td></td><td><input type="submit" name="submit" class="w3-round" style="background: maroon; color: white; height: 25px; width: 175px;" value="E-mail to Gary Taylor"></td> <?php echo $error ?> <?php echo $sent ?> </table> </form> </div> </div> </div> </body> </html> Can you help me? Of course, i will use CSS to make it decoration as style, but I want to make sure it works. Thanks, Gary
  4. Hello! What is needed to make this form work? The answer may be obvious to most, but I have limited knowledge of html, css, and trying to understand php through the tutorials. I have tried searching similar questions but haven't been able to apply answers to my form. I have modified the form taken from the Parallax template and created a php page, but when I hit the SEND MESSAGE it goes to a 404 error page. I have the website up on a test site, http://debschneiderdesign.com/NextChapter/home.html#home Thanks, Deb <form action="/NextChapter/form-to-email.php" method="post" target="blank" > <div class="w3-row-padding" style="margin:0 -16px 8px -16px"> <div class="w3-half"> <input class="w3-input w3-border" type="text" placeholder="Name" required name="Name"> </div> <div class="w3-half"> <input class="w3-input w3-border" type="text" placeholder="Email" required name="Email"> </div> </div> <input class="w3-input w3-border" type="text" placeholder="Message" required name="Message"> <button class="w3-button w3-dark-grey w3-right w3-section" type="submit"> <i class="fa fa-paper-plane"></i> SEND MESSAGE</a> </button> </form>
  5. Hi. Not sure if this is the right area for this but wasn't sure where it would fit exactly. I have a website hosted by A2Hosting which is currently using Wordpress and utilizing ContactForm7. The contact form used to use an outlook email and when a user filled it out, I would get it. The problem is occurring now since I've signed up for a GSuite email to use for my domain. After adding that email to ContactForm7, it fails to send me the email each time and tells me it's failed to send. I've tried using Easy WP SMTP without luck and also WP Mail SMTP. I haven't found a solution to this problem yet. Does anyone have any ideas? Thank you.
  6. Ok, not sure if this is the right forum or not so please point me in the right direction if it's not. Before I dig into the how, I want to know if it's possible to have users request a link through an email link and .. 1) if their email is an approved users they get an email with the link 2) if their email is NOT approved they get a "sorry, you need to be authenticated" message I have a DB of approved emails already on the server. Would it be easier to have the sorry message be an email or can I create a modal that pops up? Also, if they get the sorry message, pretty sure it's possible to send an email back to me indicating an unauthorized request was made, right?
  7. I have a form written using HTML5 and CSS3, final validation is performed on submit with JavaScript. Then, the form will be sent to the server, most likely using PHP's mail() function. I don't recall how to include two items such as these in a form's action="...", I'd deeply appreciate if someone could refresh my memory! Thank you
  8. I downloaded a piece of software from github but I can not really get it working, so I would like to get some tips of people who have used this. The name of the script is PHPMailer. I have the latest version. I decided to use gmail for smtp. with autentication. In the troubleshooting they recommended to use composer, but I dont get what / why they want it. What is composer used for? As far as i get it is used to run php commands from a command line. This my script: <?php // Import PHPMailer classes into the global namespace // These must be at the top of your script, not inside a function use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; //Load composer's autoloader //require 'vendor/autoload.php'; require 'A:\wamp64\www\PHPMailer\src\Exception.php'; require 'A:\wamp64\www\PHPMailer\src\PHPMailer.php'; require 'A:\wamp64\www\PHPMailer\src\SMTP.php'; $mail = new PHPMailer(true); // Passing `true` enables exceptions try { //Server settings $mail->SMTPDebug = 4; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'my.own.gmail@gmail.com'; // SMTP username $mail->Password = '12345fake'; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; // TCP port to connect to //Recipients $mail->setFrom('my.own.gmail@gmail.com', 'My Own Gmail'); $mail->addAddress('recipient.person999@gmail.com', 'John Doe'); // Add a recipient // $mail->addAddress('ellen@example.com'); // Name is optional // $mail->addReplyTo('info@example.com', 'Information'); // $mail->addCC('cc@example.com'); // $mail->addBCC('bcc@example.com'); //Attachments // $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments // $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name //Content $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'To John Doe (test mail) '; $mail->Body = 'This is the HTML message body <b>in bold!</b>'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } ?> when running the script I dont receive an email and I get the following output with a message: 2018-01-05 13:21:25 Connection failed. Error #2: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed [A:\wamp64\www\PHPMailer\src\SMTP.php line 404] SMTP Error: Could not connect to SMTP host. 2018-01-05 13:21:25 CLIENT -> SERVER: QUIT see the complete output here: I'm curious what causes this error and would like to solve it.
  9. I have been using the same script for years to send an email. However, php 7.1 on goddady is new to me, so that mite be the problem. Here is what I have. $message = wordwrap($message,70); $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; mail($to, $subject, $message, $headers); I am not getting emails. What is the problem here?
  10. If, when logging in, a user enters an incorrect password multiple times, the account is locked and an email notice is sent. The email notice ends with this strange sentence: "If this was you, you can safely ignore this email and you will be able to sign in again at 1." In particular: 'at 1' conveys absolutely no information!
  11. Hi. I am relatively new to using PHP and am working on building a contact form. It's pretty much good to go and it sends to my email, however, I am having the issue where it just sends this information to my email and not what the user put in, just leaving the message blank. Name: Email: Phone: Message: I'm not exactly sure what I am doing incorrectly. Also is there way to improve my code to make sure it gets in my inbox and not my spam? I've included the PHP and the HTML regarding the form. Here's the PHP. <?php $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; $formcontent=" From: $name \n Email: $email \n Phone: $phone \n Message: $message"; $recipient = "contact@immersivewebdesign.com"; $subject = "Contact Form"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); echo "Thank You!" . " -" . "<a href='http://immersivewebdesign.com/' style='text-decoration:none;color:#ff0099;'> Return Home</a>"; ?> Here's the HTML form. <div class="container"> <div class="col-lg-offset-4 col-lg-4" id="panel"> <h2>Get In Touch</h2> <form action="mail.php" method="post"> <div class="group"> <input type="text" name="name" required> <span class="highlight"></span> <span class="bar"></span> <label>Name</label> </div> <div class="group"> <input type="email" email="email" required> <span class="highlight"></span> <span class="bar"></span> <label>Email</label> </div> <div class="group"> <input type="tel" phone="phone" required> <span class="highlight"></span> <span class="bar"></span> <label>Phone</label> </div> <div class="group"> <input type="text" message="message" required> <span class="highlight"></span> <span class="bar"></span> <label>Message</label> </div> <div class="group"> <center> <button type="submit" class="btn btn-warning">Send <span class="glyphicon glyphicon-send"></span></button></center> </div> </form> </div> </div> Thank you for your help.
  12. I have a php password reset form that when used many users do not receive the email: http://amac.us/member-login-help/ It works for most major email providers but AOL email and Apple email users don't receive them nor are the in their spam or junk folders. Any advice on how to fix this on going issue?
  13. My first question: I have a message like this: notice: undefined offset 0 I use an input form to check with dns_get_record and DNS_MX whether the domain of an email exists. I can check the emails if the domain does exist, but a wrong domain like: mail@verynonexistingdomain.com throws in the notice undefined offset 0 so does an empty input. <html> <center> <br> email input :<br> <form action="#" method = "post"> <input type ="text" name ="mail"> <br> <input type="submit" name = "click" value ="zend"> </form> <?php $domain =''; $data =''; var_dump($_POST['click']); var_dump($_POST['mail']); if (isset($_POST['mail'])) { echo $_POST['mail']; $input = $_POST['mail']; } // // function check_address($input){ list($user, $domain) = explode('@', $input); $data= dns_get_record($domain, DNS_MX); if($data[0]['host']==$domain&&!empty($data[0]['target'])) { return $data[0]['target']; } else { }} echo check_address($input); Echo '<br><br>'; echo $input . " : " ; if(check_address($input) ) { echo('<br>This MX records exists; I will accept this email as valid.<br> '); } else { echo('<br>No MX record exists; Invalid email.<br>'); } echo '</center>'; ?> </html> I had it working without the form part so with a constant variable, but when I added the form it threw the error. I tried several options, but cant find the logic behind executing a good input without throwing an error and a bad domain giving this notice. Anyone any idea?
  14. Hi Guys, I have a slight problem with some of my code. I have a series of tables running down a page with each table containing different data. All looks fine when I look at it as a HTML page but when I use it as an Email 2/3 elements move for some reason, is there a way I can make sure these elements won't move? The code is in the backend of a program I use and gets called as Emails are generated for different subjects. Thanks in advance, Craig.
  15. Hi, what is w3schools email address? office mail address, perhaps?
  16. Hi, I am using express framework form to get inputs from user and sending it as email by using node mailer. However i am unable to receive the image and system type (Combo box).I am new to node.kindly help. ### My HTML code ``` <div class="container"> <p style="font-size:24px;">ONLINE SUPPORT REQUEST</p> <hr size="2%;"width="50%;"> <form role="form" name="myForm" onsubmit="return(validate());" action="" method="POST" > <div class="form-group"> <label for="name">What is your name?</label> <input type="text" class="form-control" id="text" name="fname" placeholder="name"> </div> <div class="form-group"> <label for="cname">What is your company name?</label> <input type="text" class="form-control" id="text" name="cname" placeholder="company name"> </div> <div class="form-group"> <label for="email">What is your email address?</label> <input type="email" class="form-control" id="email" name="email" placeholder="Enter email"> </div> <div class="form-group"> <label for="phone">What is your phone number?</label> <input type="text" class="form-control" id="text" name="phone" placeholder=" phone number with area code"> </div> <div class="form-group"> <label for="one">Is this an emergency? </label> <input type="radio" class="form-control" id="text" name="emergency" value="No"> NO <input type="radio" class="form-control" id="text" name="emergency" value="Yes"> YES </div> <div class="form-group"> <label for="one">Do you require a phone call when we begin working on your ticket? </label> <input type="radio" class="form-control" id="text" name="phonecall" value="No"> NO <input type="radio" class="form-control" id="text" name="phonecall" value="Yes"> YES </div> <div class="form-group"> <label for="combo" name="systemtype"> What is your system platform</label> <br> <select> <option value="volvo">Microsoft Windows</option> <option value="saab">Mac OS X</option> <option value="opel">Linux</option> <option value="audi">IOS</option> <option value="5">Android</option> <option value="6">Others</option> </select> </div> <div class="form-group"> <label for="uploadfile"> Please attach a screenshot if applicable.</label> <input type="file" class="form-control" id="text" name="attachment" size="50"> <br> <input type="submit" value="Upload File" /> </div> <div class="form-group"> <label for="name">What is the subject of your support request?</label> <input type="text" class="form-control" id="text" name="supportrequest" placeholder="suport subject"> </div> <div class="form-group"> <label for="comment">Please describe the support issue in detail </label> <textarea class="form-control" rows="5" id="comment" name="urcomments"></textarea> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> <br> ``` ### My server Code ```js var express = require('express'); var app = express(); var fs = require("fs"); var bodyParser = require('body-parser'); var multer = require('multer'); // Create application/x-www-form-urlencoded parser var urlencodedParser = bodyParser.urlencoded({ extended: false }) app.use(express.static('public')); var upload = multer({ dest: './uploads' }); app.get('/client-support.htm', function (req, res) { res.sendFile( __dirname + "/" + "client-support.htm" ); }) app.post('/process_post', urlencodedParser, function (req, res) { // Prepare output in JSON format response = { fname:req.body.fname, cname:req.body.cname, email:req.body.email, phone:req.body.phone, emergency:req.body.emergency, phonecall:req.body.phonecall, systemtype:req.body.systemtype, attachment:req.body.attachment, supportrequest:req.body.supportrequest, urcomments:req.body.urcomments }; console.log(response); res.end(JSON.stringify(response)); console.log(req.files.file.name); console.log(req.files.file.path); console.log(req.files.file.type); var file = __dirname + "/" + req.files.file.name; fs.readFile( req.files.file.path, function (err, data) { fs.writeFile(file, data, function (err) { if( err ){ console.log( err ); }else{ response = { message:'File uploaded successfully', filename:req.files.file.name }; } console.log( response ); res.end( JSON.stringify( response ) ); }); }); //sudan file upload edit end //sudan edited node mailer code below var nodemailer = require('nodemailer'); // create reusable transporter object using the default SMTP transport // setup e-mail data with unicode symbols var mailOptions = { from: 'xxxxxxxx.com', // sender address to: 'xxxxxxxxx.com', // list of receivers subject: 'Client Support Page - Client Details', // Subject line text: 'you have a new submission with folowwing details....Name:'+req.body.fname+'cname:'+req.body.cname+'Email:'+req.body.email+'Phone:'+req.body.phone+'emergency:'+req.body.emergency+'phonecall:'+req.body.phonecall+'systemtype:'+req.body.systemtype+'attachment:'+req.body.attachment+'supportrequest:'+req.body.supportrequest+'urcomments:'+req.body.urcomments, // plaintext body html: '<table border="1" style="width:100%"><tr style="background-color:#373737;color:#ffffff;"><td><b>DETAILS LIST</b></td><td><b>CLIENT DETAILS</b></td></tr><tr style="background-color: #eee;"><td><b>Name:</b></td><td>'+req.body.fname+'</td></tr><tr><td><b>Email:</b></td><td>'+req.body.email+'</td></tr><tr style="background-color: #eee;"><td><b>Phone:</b></td><td>'+req.body.phone+'</td></tr><tr><td><b>emergency:</b></td><td>'+req.body.emergency+' </td></tr><tr style="background-color: #eee;"><td><b>phonecall:</b></td><td>'+ req.body.phonecall +' </td> </tr><tr><td><b>systemtype:</b></td><td>'+req.body.systemtype +'</td></tr><tr style="background-color: #eee;"><td><b>attachment:</b></td><td>'+req.body.attachment +' </td></tr><tr><td><b>supportrequest:</b></td><td>'+ req.body.supportrequest +' </td></tr></table>'// html body }; // send mail with defined transport object transporter.sendMail(mailOptions, function(error, info){ if(error){ return console.log(error); } console.log('Message sent: ' + info.response); }); }) var server = app.listen(8081, function () { var host = server.address().address var port = server.address().port })
  17. Hi, I have a details screen where visitors to the website can leave their contact info. I have some javascript rules to validate some of the fields when the visitor is filling them out so they cannot leave certain fields empty. I have an email field where aswell as stopping the visitor leaving the field blank i want a validation check so it looks for the presence of "@" and a "." within the field. But I am having trouble getting this implemented. Currently my code for the blank checks looks like this (with the email field in the last block) :- </script><script language="javascript" type="text/javascript">function validate_form ( ){valid = true; if (document.networkOpportunity.contactName.value == "") { alert ( "Please enter the name of the contact for the opportunity." ); document.networkOpportunity.contactName.focus(); document.networkOpportunity.contactName.style.backgroundColor = "#d7edf8"; valid = false; } else if (document.networkOpportunity.companyName.value == "") { alert ( "Please enter the company name that the opportunity is for." ); document.networkOpportunity.contactName.style.backgroundColor = "#FFFFFF"; document.networkOpportunity.companyName.focus(); document.networkOpportunity.companyName.style.backgroundColor = "#d7edf8"; valid = false; } else if (document.networkOpportunity.serviceRequired.value == "") { alert ( "Please enter the details of the service you require." ); document.networkOpportunity.companyName.style.backgroundColor = "#FFFFFF"; document.networkOpportunity.serviceRequired.focus(); document.networkOpportunity.serviceRequired.style.backgroundColor = "#d7edf8"; valid = false; } else if (document.networkOpportunity.contactEmail.value == "") { alert ( "Please enter the email we can contact you on." ); document.networkOpportunity.serviceRequired.style.backgroundColor = "#FFFFFF"; document.networkOpportunity.contactEmail.focus(); document.networkOpportunity.contactEmail.style.backgroundColor = "#d7edf8"; valid = false; } Any help with how to add the extra validation on the contactEmail field to look for "@" and "." will be greatly appreciated.
  18. luisda2994

    Usage of mail()

    Hello, I need to be able to send a form to a real email address using mail(), however every solution I find has to do with uploading the website to a host, and due to the nature of my project that's not possible. It must run in my own computer and still be capable of sending emails. Any example, code or help appreciated. Thanks
  19. Hello, Im a bit lost with this project, I cant seem to find the problem and I sure could use an extra set of eyes to look it over. when the form is submitted it comes back to the error page and the emails are not sent. any ideas? Thanks in advance! <?phpfunction ValidateEmail($email){ $pattern = '/^([0-9a-z]([-.w]*[0-9a-z])*@(([0-9a-z])+([-w]*[0-9a-z])*.)+[a-z]{2,6})$/i'; return preg_match($pattern, $email);}if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['formid'] == 'form344'){ $mailto = $_POST['unit'];if(isset($_POST['unit'])) { $units['M17'][] = 'email@email.com, email@email.com'; $units['M16'][] = 'email@email.com'; $to = implode(",",$units[$_POST['unit']]); $mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto; $subject = 'Transfer'; $message = ''; $success_url = './success.php'; $error_url = './error.php'; $error = ''; $eol = "n"; $max_filesize = isset($_POST['filesize']) ? $_POST['filesize'] * 1024 : 1024000; $boundary = md5(uniqid(time())); $header = 'From: '.$mailfrom.$eol; $header .= 'Reply-To: '.$mailfrom.$eol; $header .= 'MIME-Version: 1.0'.$eol; $header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol; $header .= 'X-Mailer: PHP v'.phpversion().$eol; if (!ValidateEmail($mailfrom)) { $error .= "The specified email address is invalid!n<br>"; } if (!empty($error)) { $errorcode = file_get_contents($error_url); $replace = "##error##"; $errorcode = str_replace($replace, $error, $errorcode); echo $errorcode; exit; } $internalfields = array ("submit", "reset", "send", "filesize", "formid", "captcha_code", "recaptcha_challenge_field", "recaptcha_response_field"); $message .= $eol; foreach ($_POST as $key => $value) { if (!in_array(strtolower($key), $internalfields)) { if (!is_array($value)) { $message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol; } else { $message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol; } } } $body = 'This is a multi-part message in MIME format.'.$eol.$eol; $body .= '--'.$boundary.$eol; $body .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol; $body .= 'Content-Transfer-Encoding: 8bit'.$eol; $body .= $eol.stripslashes($message).$eol; if (!empty($_FILES)) { foreach ($_FILES as $key => $value) { if ($_FILES[$key]['error'] == 0 && $_FILES[$key]['size'] <= $max_filesize) { $body .= '--'.$boundary.$eol; $body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol; $body .= 'Content-Transfer-Encoding: base64'.$eol; $body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol; $body .= $eol.chunk_split(base64_encode(file_get_contents($_FILES[$key]['tmp_name']))).$eol; } } } $body .= '--'.$boundary.'--'.$eol; if ($mailto != '') { mail($mailto, $subject, $body, $header); }mail($mailto, $subject, $body, $header); header('Location: '.$success_url); exit;}}if (session_id() == ""){ session_start();}if (!isset($_SESSION['username'])){ header('Location: ./notloggedin.php'); exit;}if (isset($_SESSION['expires_by'])){ $expires_by = intval($_SESSION['expires_by']); if (time() < $expires_by) { $_SESSION['expires_by'] = time() + intval($_SESSION['expires_timeout']); } else { unset($_SESSION['username']); unset($_SESSION['expires_by']); unset($_SESSION['expires_timeout']); header('Location: ./notloggedin.php'); exit; }}if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['formid'] == 'form1'){ $mailto = $_POST['unit'];if(isset($_POST['unit'])) { $units['M17'][] = 'email@email.com, email@email.com'; $units['M16'][] = 'email@email.com'; $to = implode(",",$units[$_POST['unit']]); $mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto; $subject = '911'; $message = ''; $success_url = './success.php'; $error_url = './error.php'; $error = ''; $eol = "n"; $max_filesize = isset($_POST['filesize']) ? $_POST['filesize'] * 1024 : 1024000; $boundary = md5(uniqid(time())); $header = 'From: '.$mailfrom.$eol; $header .= 'Reply-To: '.$mailfrom.$eol; $header .= 'MIME-Version: 1.0'.$eol; $header .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'.$eol; $header .= 'X-Mailer: PHP v'.phpversion().$eol; if (!ValidateEmail($mailfrom)) { $error .= "The specified email address is invalid!n<br>"; } if (!empty($error)) { $errorcode = file_get_contents($error_url); $replace = "##error##"; $errorcode = str_replace($replace, $error, $errorcode); echo $errorcode; exit; } $internalfields = array ("submit", "reset", "send", "filesize", "formid", "captcha_code", "recaptcha_challenge_field", "recaptcha_response_field"); $message .= $eol; foreach ($_POST as $key => $value) { if (!in_array(strtolower($key), $internalfields)) { if (!is_array($value)) { $message .= ucwords(str_replace("_", " ", $key)) . " : " . $value . $eol; } else { $message .= ucwords(str_replace("_", " ", $key)) . " : " . implode(",", $value) . $eol; } } } $body = 'This is a multi-part message in MIME format.'.$eol.$eol; $body .= '--'.$boundary.$eol; $body .= 'Content-Type: text/plain; charset=ISO-8859-1'.$eol; $body .= 'Content-Transfer-Encoding: 8bit'.$eol; $body .= $eol.stripslashes($message).$eol; if (!empty($_FILES)) { foreach ($_FILES as $key => $value) { if ($_FILES[$key]['error'] == 0 && $_FILES[$key]['size'] <= $max_filesize) { $body .= '--'.$boundary.$eol; $body .= 'Content-Type: '.$_FILES[$key]['type'].'; name='.$_FILES[$key]['name'].$eol; $body .= 'Content-Transfer-Encoding: base64'.$eol; $body .= 'Content-Disposition: attachment; filename='.$_FILES[$key]['name'].$eol; $body .= $eol.chunk_split(base64_encode(file_get_contents($_FILES[$key]['tmp_name']))).$eol; } } } $body .= '--'.$boundary.'--'.$eol;}}?>
  20. Hello, I created an order form on my website that takes the user's inputs, send confirmation emails to them and myself (order@), and then inserts the order into a mySQL database. The emails used to work, but now, for some reason, they never get sent. The email address it is supposed to be sending it to works and I have validated that nothing is getting blocked in SPAM, etc. The code for the email portion is below. I have tried debugging myself, but I get no errors on the mail() portion of the code. Any help that could be offered would be greatly appreciated. Thank you. if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "order@idrinktoremember.com"; $email_subject = "We've Got an Order!"; 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.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['address']) || !isset($_POST['city']) || !isset($_POST['state']) || !isset($_POST['zip']) || !isset($_POST['opener']) || !isset($_POST['stain']) || !isset($_POST['memory']) || !isset($_POST['catcher'])) { died('We are sorry, but please ensure you filled in all required items. Click back to check.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // required $address = $_POST['address']; // required $city = $_POST['city']; // required $state = $_POST['state']; // required $zip = $_POST['zip']; // required $opener = $_POST['opener']; // required $stain = $_POST['stain']; // required $memory = $_POST['memory']; // required $catcher = $_POST['catcher']; // required $comments = $_POST['comments']; // not required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Order details below.nn"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."n"; $email_message .= "Last Name: ".clean_string($last_name)."n"; $email_message .= "Email: ".clean_string($email_from)."n"; $email_message .= "Telephone: ".clean_string($telephone)."n";$email_message .= "Address: ".clean_string($address)."n";$email_message .= "City: ".clean_string($city)."n";$email_message .= "State: ".clean_string($state)."n";$email_message .= "Zip Code: ".clean_string($zip)."n";$email_message .= "Opener: ".clean_string($opener)."n";$email_message .= "Stain Selected: ".clean_string($stain)."n";$email_message .= "Memory Requested: ".clean_string($memory)."n";$email_message .= "Catcher Requested: ".clean_string($catcher)."n";$email_message .= "Comments: ".clean_string($comments)."n"; //create email headers $email_us = "order@idrinktoremember.com";$headers = "From: $email_us rn";$headers .= "Reply-To: $email_us rn";$headers .= "Return-Path: $email_usrn";$headers .= "X-Mailer: PHP rn";if(mail($email_to, $email_subject, $email_message, $headers)){ echo '';}else{ echo 'Error';}//send order confirmation email$email_subject_confirmation = "Congratulations, your order has been submitted!";$email_message_confirmation .= "The details of your order are below. Please review.nn";$email_message_confirmation .= "First Name: ".clean_string($first_name)."n"; $email_message_confirmation .= "Last Name: ".clean_string($last_name)."n"; $email_message_confirmation .= "Email: ".clean_string($email_from)."n"; $email_message_confirmation .= "Telephone: ".clean_string($telephone)."n";$email_message_confirmation .= "Address: ".clean_string($address)."n";$email_message_confirmation .= "City: ".clean_string($city)."n";$email_message_confirmation .= "State: ".clean_string($state)."n";$email_message_confirmation .= "Zip Code: ".clean_string($zip)."n";$email_message_confirmation .= "Opener Selected: ".clean_string($opener)."n";$email_message_confirmation .= "Stain Selected: ".clean_string($stain)."n";$email_message_confirmation .= "Memory Requested: ".clean_string($memory)."n";$email_message_confirmation .= "Catcher Requested: ".clean_string($catcher)."n";$email_message_confirmation .= "Comments: ".clean_string($comments)."n";$email_message_confirmation .= "nnWe will be contacting you shortly with a prototype of your design!n";$email_message_confirmation .= "nThe MemoraBEERLia Team";$headers = "From: $email_us rn";$headers .= "Reply-To: $email_us rn";$headers .= "Return-Path: $email_usrn";$headers .= "X-Mailer: PHP rn";if(mail($email_from, $email_subject_confirmation, $email_message_confirmation, $headers)){ echo '';}else{ echo 'Error';}
  21. Hi, Just wanted to ask people's opinions around responsive email templates and compatibility in most versions of outlook. I've been yet to find a responsive template that will still work well in versions of outlook and was wondering if anyone can shed light on the subject as to whether there are any templates/methods that still display well with older email clients? Thanks Ben
  22. Salam or Hello @ All, It's me Bilal since a very long ago, today I'm posting this topic because I'm dive into a problem which is: I want to send a email after collecting data from html form which is pretty simple with the help of PHP but can the same functionality can be performed by using just JavaScript only? if so please discuss the possibilities on this topic. Don't be tell about the mailto function of the html because it is not good at all. I'm waiting for your pretty responses......
  23. Hi good people of w3, I'd been using the tutorials on this site a lot in an attempt to get the email enquiry form working for the website I've been putting together for the place I'm currently employed at. This isn't exactly my forte, I'm pretty decent when it comes to html but php is an animal I'm only just starting to become familiar with.I have an issue currently where particular parts of the form are required to be filled in, and I can successfully generate errors when this does not occur. However, the errors do not actually stop the email from being sent and hence we end up with incomplete enquiries on the other side when the form is not correctly filled in.If anyone could provide some advice as to a means to make the errors stop the email from being sent, that would be much appreciated. The relevant code is below. <?php// define variables and set to empty values$nameErr = $emailErr = $partErr = $phoneErr = "";$name = $email = $part = $comments = $model = $brand = $phone = $contact_method = $product = $breakdown = "";if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Name is required"; } else { $name = test_input($_POST["name"]); // check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $nameErr = "Only letters and white space allowed"; } } if (empty($_POST["email"])) { $emailErr = "Email is required"; } else { $email = test_input($_POST["email"]); // check if e-mail address is well-formed if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; } } if (empty($_POST["phone"])) { $contact_methodErr = "Phone number is required"; } else { $phone = test_input($_POST["phone"]); } $contact_method = test_input($_POST["contact_method"]); $brand = test_input($_POST["brand"]); $product = test_input($_POST["product"]); $model = test_input($_POST["model"]); $breakdown = test_input($_POST["breakdown"]); if (empty($_POST["part"])) { $partErr = "Part number or description is required"; } else { $part = test_input($_POST["part"]); } $comments = test_input($_POST["comments"]); } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data;}// Function to validate against any email injection attemptsfunction IsInjected($str){ $injections = array('(n+)', '(r+)', '(t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; }} //Validate firstif(IsInjected($customer_email)){ echo "Bad email value!"; exit;} $email_from = 'sales@speedyspares.com';//<== update the email address $email_subject = "Online Enquiry"; $email_body = '<html><body>'; $email_body .= '<table rules="all" style="border-color: #666;" cellpadding="10">'; $email_body .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" . $name = $_POST["name"] . "</td></tr>"; $email_body .= "<tr><td><strong>Email:</strong> </td><td>" . $email = $_POST["email"] . "</td></tr>"; $email_body .= "<tr><td><strong>Phone:</strong> </td><td>" . $phone = $_POST["phone"] . "</td></tr>"; $email_body .= "<tr><td><strong>Preferred Method of Contact:</strong> </td><td>" . $contact_method = $_POST[ "contact_method"] . "</td></tr>"; $email_body .= "<tr><td><strong>Brand:</strong> </td><td>" . $brand = $_POST["brand"] . "</td></tr>"; $email_body .= "<tr><td><strong>Product:</strong> </td><td>" . $product = $_POST["product"] . "</td></tr>"; $email_body .= "<tr><td><strong>Model:</strong> </td><td>" . $model = $_POST["model"] . "</td></tr>"; $email_body .= "<tr><td><strong>Breakdown Required:</strong> </td><td>" . $breakdown = $_POST["breakdown"] . "</td></tr>"; $email_body .= "<tr><td><strong>Part:</strong> </td><td>" . $part = $_POST["part"] . "</td></tr>"; $email_body .= "<tr><td><strong>Comments:</strong> </td><td>" . $comments = $_POST["comments"] . "</td></tr>"; $email_body .= "</table>"; $email_body .= "</body></html>"; $to = "sales@speedyspares.com";//<== update the email address $headers = "From: $email_from rn"; $headers .= "Reply-To: $email rn"; $headers .= "MIME-Version: 1.0rn"; $headers .= "Content-Type: text/htmlrn"; //Send the email! mail($to,$email_subject,$email_body,$headers); //done. redirect to thank-you page. header('Location: thankyou.html'); ?><form method="post" name="enquiry-form" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <h6><strong><span class="redasterisk">*</span></strong>denotes a required field</h6> <h6>Name:<span class="error">* <?php echo $nameErr;?></span><br> <input name="name" type="text" size="50"> <br> E-mail:<span class="error">* <?php echo $emailErr;?></span><br> <input name="email" type="text" size="50"> <br> Phone:<span class="error">* <?php echo $phoneErr;?></span><br> <input name="phone" type="text" size="50"> <br /> Preferred Contact Method:<br /> <input type="radio" name="contact" value="email" /> Email <input type="radio" name="contact" value="phone" /> Phone <br /> Brand:<br> <select name="brand"> <option value="Sony">SONY</option> <option value="Sharp">SHARP</option> <option value="Hills">HILLS</option> <option value="Other">OTHER</option> </select><br /> Product:<br> <select name="product"> <option value="TV">TV/PROJECTOR</option> <option value="VIDEO">HOME VIDEO/DVD/BLU-RAY</option> <option value="AUDIO">HOME AUDIO/THEATRE SYSTEM</option> <option value="CAMERA">DIGITAL STILL CAMERA</option> <option value="CAMCORDER">VIDEO CAMERA/CAMCORDER</option> <option value="VAIO">PERSONAL COMPUTER (VAIO)</option> <option value="EREADER">eBOOK READER</option> <option value="PAUDIO">PERSONAL AUDIO</option> <option value="CAUDIO">CAR AUDIO</option> <option value="FRIDGE">REFRIDGERATOR</option> <option value="MICROWAVE">MICROWAVE</option> <option value="OTHER">OTHER</option> </select><br /> Model :<br /><em>(eg. KDL-46HX800)</em><br> <input type="text" name="model" size="50"> <br /> <input type="checkbox" name="breakdown" value="Yes" /> Request Breakdown<br /> Part number/description:<span class="error">* <?php echo $partErr;?></span><br /><em>(e.g. UWA-BR100 Wi-fi Adaptor)</em><br /> <input type="text" name="part" size="50"> <br> Comments:<br> <textarea name="comments" cols="50" rows="5">Please supply any additional information that may assist with your enquiry. (color/size/location etc.)</textarea> <br /> (Please do not use this form for submission of credit card information)</h6> <h5> <input type="submit" name="submit" value="Submit"> <input type="reset" name="reset" value="Reset"> </h5> </form>
  24. Hello internet, I tried asking this question once already but there were no responses. Does this mean my question is not written well - or there are no suggestions... Here is my question... The issue of the day is this… I have a successful form that submits user information to my database through a php file. Using chrome it will send the user information to the database but will not kick out an email. This is strange. IE/Safari work just fine – but Chrome will not work. What small nuance am I missing?
  25. Before I put encrypted JS code into my website, can anyone tell me if this source is trustworthy? What I mean is, does Webtools hide something nasty into the encryption in addition to what I type into the window? I want to keep my email address safe from robots. That is, I want to encrypt <a href="mailto:MYemail@MYdomain.com">...</a> I've created a dummy email address and tested it. It seems to work fine, but I don't want it if they sell the address to a spammer. I looking for protection from email skimmers, not ultimate security. I doubt someone would sift the rare JS encrypted websites for one email address. ( ...or am I being naive?) Who out there has some knowledge about this? Thank you!
  • Create New...