Jump to content

whitt

Members
  • Posts

    44
  • Joined

  • Last visited

Posts posted by whitt

  1. How do you know it was successful? You just return true no matter what.

    The mail function returns a boolean, you should use that.

    mail($to,$email_subject,$email_body,$headers);
    return true;

    One other thing I noticed, is headers need to be separated with \r\n, not just \n.

    $headers = "From: whitegatescattery.com\n";
    $headers .= "Reply-To: email@gmail.com";

    As far as the appending error messages in your second code block, it's probably because you do a var_dump(), which sends that output back to the browser.

    How do you mean return true all the time?

  2. <?php
    // check if fields passed are empty
    if(empty($_POST['name'])      ||
       empty($_POST['email'])     ||
       empty($_POST['phone'])     ||
       empty($_POST['message']) ||
       !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
       {
      echo "No arguments Provided!";
      return false;
       }
      
    $name = $_POST['name'];
    $email_address = $_POST['email'];
    $message = $_POST['message'];
    $phone = $_POST['phone'];
      
    // create email body and send it  
    $to = 'email@gmail.com'; // put your email
    $email_subject = "Contact form submitted by:  $name";
    $email_body = "You have received a new message. \n\n".
              " Here are the details:\n \nName: $name \n ".
              "Email: $email_address\n Phone: $phone\n Message \n $message";
    $headers = "From: whitegatescattery.com\n";
    $headers .= "Reply-To: email@gmail.com"; 
    mail($to,$email_subject,$email_body,$headers);
    return true;      
    ?>
    
    

    This worked with Gmail i dont get why this 

     

     

    <?php
    
    require_once './libPHPMailerAutoload.php';
    // check if fields passed are empty
    // check if fields passed are empty
    
    $name = $_POST['name'];
    $email_address = $_POST['email'];
    $message = $_POST['message'];
    $phone = $_POST['phone'];
    
    if(empty($_POST['name'])      ||
       empty($_POST['email'])     ||
       empty($_POST['phone'])     ||
       empty($_POST['message']) ||
       !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
       {
      echo "No arguments Provided!";
      return false;
       }
      
    
    $mail = new PHPMailer;
    $mail->isSMTP();
    $mail->SMTPAuth= true;
    $mail->SMTPDebug = 1;
    
    
    $mail->Host = 'smtp-mail.outlook.com';
    $mail->Username = 'email';
    $mail->Password = 'pass';
    $mail->SMTPSecure = 'tls';
    $mail->Port = 587;
    
    $mail->From = $email_address;
    $mail->FromName = $name;
    $mail->addReplyTo('reply@outlook.com','reply');
    $mail->addAddress('@outlook.com','me');
    
       $mail->isHTML(true);
       $mail->Subject = "Contact Form has been submitted";
       $mail->Body = "You have received a new message. <br><br>".
                      " Here are the details:<br> Name: $name <br> Phone Number: $phone <br>".
                      "Email: $email_address<br> Message <br> $message";
    
    var_dump($mail->send());
    return true;			
    
    
    ?>
    

    Is causing my ajax to append my fail message

  3. <?php
    require_once 'PHPMailerAutoload.php';
    // check if fields passed are empty
    if(empty($_POST['name'])  		||
       empty($_POST['email']) 		||
       empty($_POST['message'])	||
       !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
       {
    	echo "No arguments Provided!";
    	
       }
    	
    $name = $_POST['name'];
    $email_address = $_POST['email'];
    $message = $_POST['message'];
    	
    
    $mail = new PHPMailer;
    $mail->isSMTP();
    $mail->SMTPAuth= true;
    $mail->SMTPDebug = 1;
    
    
    $mail->Host = 'smtp-mail.outlook.com';
    $mail->Username = 'email';
    $mail->Password = 'pass';
    $mail->SMTPSecure = 'tls';
    $mail->Port = 587;
    
    $mail->From = $email_address;
    $mail->FromName = $name;
    $mail->addReplyTo('reply@outlook.com','reply');
    $mail->addAddress('testytestersontesting@outlook.com','Testy Testerson');
    
       $mail->isHTML(true);
       $mail->Subject = "Contact Form has been submitted";
       $mail->Body = "You have received a new message. <br><br>".
                      " Here are the details:<br> Name: $name <br> Phone Number: $phone <br>".
                      "Email: $email_address<br> Message <br> $message";
    
    echo var_dump($mail->send());
    return true;			
    ?>
    

    I just flat out cannot see why this does not work , the script on its own works but when i try to integrate it into the form i get my ajax sending back my error alert.

  4. This may seem obvious, but it has't been mentioned.  Have you turned on SMTP error reporting?  

    /*
    * $mail->SMTPDebug = 0; disable debugging, 0 is the default)
    * $mail->SMTPDebug = 1; echo errors and server responses
    * $mail->SMTPDebug = 2; echo errors, server responses and client messages
    */
    $mail->SMTPDebug = 1;
    

    I'm not as familiar with PHPMailer, but with other classes/frameworks, you can pass additional headers.  That may be where you want to research, specifically for MS mail.  BTW, I've used part of your ajax script to update on of my own.  I like how your handling post submit UI feedback. Good luck

     

    If my AJAX is working it has to be on the PHP end

  5. Literally 5 minutes later and i get this "





    2015-03-06 11:59:37 CLIENT -> SERVER: EHLO localhost 2015-03-06 11:59:37 CLIENT -> SERVER: STARTTLS 2015-03-06 11:59:37 CLIENT -> SERVER: EHLO localhost 2015-03-06 11:59:38 CLIENT -> SERVER: AUTH LOGIN 2015-03-06 11:59:38 CLIENT -> SERVER: bWF0dGhld3B3aGl0dGluZ3RvbkBvdXRsb29rLmNvbQ== 2015-03-06 11:59:38 CLIENT -> SERVER: TWF2ZXJpY2s4OQ== 2015-03-06 11:59:39 CLIENT -> SERVER: MAIL FROM: 2015-03-06 11:59:39 CLIENT -> SERVER: RCPT TO: 2015-03-06 11:59:39 CLIENT -> SERVER: DATA 2015-03-06 11:59:39 CLIENT -> SERVER: Date: Fri, 6 Mar 2015 11:59:37 +0000 2015-03-06 11:59:39 CLIENT -> SERVER: To: Matthew Whittington 2015-03-06 11:59:39 CLIENT -> SERVER: From: matthewpwhittington@outlook.com 2015-03-06 11:59:39 CLIENT -> SERVER: Reply-To: sender 2015-03-06 11:59:39 CLIENT -> SERVER: Subject: Testing Email 2015-03-06 11:59:39 CLIENT -> SERVER: Message-ID: <26e958edff522d3f6a43f03aaf8bab81@localhost> 2015-03-06 11:59:39 CLIENT -> SERVER: X-Priority: 3 2015-03-06 11:59:39 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.9 (https://github.com/PHPMailer/PHPMailer/) 2015-03-06 11:59:39 CLIENT -> SERVER: MIME-Version: 1.0 2015-03-06 11:59:39 CLIENT -> SERVER: Content-Type: multipart/alternative; 2015-03-06 11:59:39 CLIENT -> SERVER: boundary="b1_26e958edff522d3f6a43f03aaf8bab81" 2015-03-06 11:59:39 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: --b1_26e958edff522d3f6a43f03aaf8bab81 2015-03-06 11:59:39 CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: This is a Test Email 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: --b1_26e958edff522d3f6a43f03aaf8bab81 2015-03-06 11:59:39 CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: This is a Test Email ssl 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: --b1_26e958edff522d3f6a43f03aaf8bab81-- 2015-03-06 11:59:39 CLIENT -> SERVER: 2015-03-06 11:59:39 CLIENT -> SERVER: . 2015-03-06 11:59:40 SMTP ERROR: DATA END command failed: 550 5.3.4 Requested action not taken; To continue sending messages, please sign in to your account. 2015-03-06 11:59:40 SMTP Error: data not accepted. bool(false) 2015-03-06 11:59:40 CLIENT -> SERVER: QUIT 2015-03-06 11:59:40 SMTP ERROR: QUIT command failed:" @outlook.com>@outlook.com>@outlook.com>@outlook.com>

  6. I did a basic just send an email PHP scrip i have the emails going to my in box with this 

     

    <?php
    
    require_once 'PHPMailerAutoload.php';
    
    $mail = new PHPMailer;
    $mail->isSMTP();
    $mail->SMTPAuth= true;
    
    
    
    $mail->Host = 'smtp-mail.outlook.com';
    $mail->Username = 'myemail@outlook.com';
    $mail->Password = 'pass';
    $mail->SMTPSecure = 'tls';
    $mail->Port = 587;
    
    $mail->From = 'sender@outlook.com';
    $mail->FromName = $name;
    $mail->addReplyTo('sender@outlook.com',$name);
    $mail->addAddress('myemail@outlook.com',me);
    
    $mail->Subject = 'Testing Email';
    $mail->Body = 'This is a Test Email ssl';
    $mail->AltBody ='This is a Test Email';
    
    var_dump($mail->send());
    
    ?>
    
  7. Besides the possible issues with your script, also understand that ANY of the Microsoft email domains (outlook, hotmail, live, msn) are very very hard to have an email arrive in the inbox.  They have very strict rules in place to prevent spam, so make sure to check your spam box before deciding that the email has never arrived.  Try sending it to a yahoo or gmail address too and see if it arrives there.  Those email domains are far less strict.

    With Gmail when the form is submitted i get a suspicious sign in attempt email from Gmail.

  8. I am attempting to create a php AJAX contact form , however the email never seems to arrive in my outlook.
     

    /*
      Jquery Validation using jqBootstrapValidation
       example is taken from jqBootstrapValidation docs 
      */
    $(function() {
    
     $("input,textarea").jqBootstrapValidation(
        {
         preventSubmit: true,
         submitError: function($form, event, errors) {
          // something to have when submit produces an error ?
          // Not decided if I need it yet
         },
         submitSuccess: function($form, event) {
          event.preventDefault(); // prevent default submit behaviour
           // get values from FORM
           var name = $("input#name").val();  
           var email = $("input#email").val();
           var phone = $("input#phone").val();  
           var message = $("textarea#message").val();
            var firstName = name; // For Success/Failure Message
               // Check for white space in name for Success/Fail message
            if (firstName.indexOf(' ') >= 0) {
    	   firstName = name.split(' ').slice(0, -1).join(' ');
             }        
    	 $.ajax({
                    url: "./bin/contact_me.php",
                	type: "POST",
                	data: {name: name,phone:phone, email: email, message: message},
                	cache: false,
                	success: function() {  
                	// Success message
                	   $('#success').html("<div class='alert alert-success'>");
                	   $('#success > .alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
                		.append( "</button>");
                	  $('#success > .alert-success')
                		.append("<strong>Your message has been sent. </strong>");
     		  $('#success > .alert-success')
     			.append('</div>');
     						    
     		  //clear all fields
     		  $('#contactForm').trigger("reset");
     	      },
     	   error: function() {		
     		// Fail message
     		 $('#success').html("<div class='alert alert-danger'>");
                	$('#success > .alert-danger').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
                	 .append( "</button>");
                	$('#success > .alert-danger').append("<strong>Sorry "+firstName+" it seems that my mail server is not responding...</strong> Could you please email me directly ? Sorry for the inconvenience!");
     	        $('#success > .alert-danger').append('</div>');
     		//clear all fields
     		$('#contactForm').trigger("reset");
     	    },
               })
             },
             filter: function() {
                       return $(this).is(":visible");
             },
           });
    
          $("a[data-toggle=\"tab\"]").click(function(e) {
                        e.preventDefault();
                        $(this).tab("show");
            });
      });
     
    
    /*When clicking on Full hide fail/success boxes */ 
    $('#name').focus(function() {
         $('#success').html('');
      });
    
    
    <?php
    
    
    require("../lib/phpmailer/PHPMailerAutoload.php");
    
    if(empty($_POST['name'])        ||
       empty($_POST['email'])       ||
       empty($_POST['phone']) ||
       empty($_POST['message']) ||
       !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
       {
        echo "No arguments Provided!";
        return false;
       }
    
        $m             = new PHPMailer();
        $m->IsSMTP();
        $m->SMTPAuth   = true;
        $m->SMTPDebug  = 2;                    
        $m->Host       = "smtp-mail.outlook.com";
       
                          
                         
        $m->Username   = ""; 
        $m->Password   = "";
        $m->SMTPSecure = 'tls';
        $m->Port       = 587;  
       
        
        $m->addAddress('EXAMPLE@outlook.com', $name);
    
        $name = $_POST['name'];
    $email_address = $_POST['email'];
    $phone = $_POST['phone'];
    $message = $_POST['message'];
    
        
        $m->Subject = "Contact Form has been submitted";
        $m->Body = "You have received a new message. <br><br>".
                      " Here are the details:<br> Name: $name <br> Phone Number: $phone <br>".
                      "Email: $email_address<br> Message <br> $message";
       
    
    if(!$m->Send()) {
          echo "Mailer Error: " . $m->ErrorInfo;
          exit;
        } 
    ?>
    
  9. Im struggling with how to filter items that have multiple categorises say if i wanted to search for a shoe that is good for walking and hiking in my database?

    Shoe_id
    Shoe name
    color_id

    type_id

    colors

    color_id

    color

     

    type

    type_id

    type

    My problem is what do i do in a situations like this? say a shoe is good for walking and running? aka type 1 and 2 

    shoe id 1 shoe name nike color id 1 type id 1 and 2   

  10. how about if say theres a shoe type say

    types
    type_ID
    type 
    but i wanted a shoe to be for basket ball and running

     

     Shoes:

    ID = 1, Name = 'Nike Free'

     

    Colors

    ID = 1, Name = 'Grey'

    ID = 2, Name = 'Yellow'

     

    Type 

    type_id 1

    type running

    type_id 2

    type basketball

     

    Shoe_colors:

    ID = 1, Shoe_id = 1, Color_id = 1 type = 1 and 2 ??

    ID = 2, Shoe_id = 1, Color_id = 2

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.