Friday, March 16, 2018

How to jvalidate the array type input box using jquery[SOLVED]


Hey guy ,

After lot of R&D I have updated the core library for dynamic validation input box for below updated and example , it might be help you for validation.

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.validate.js"></script>

jQuery(function() {

jQuery("#winner_register").validate({
  errorElement: 'small',
  focusInvalid: true,
  invalidHandler: function(form, validator){
   if (!validator.numberOfInvalids())
   return;
   jQuery('html, body').animate({
   scrollTop: jQuery(validator.errorList[0].element).offset().top-300
   }, 100);
  },
  rules: {
   
   'ftk_email[]': {
    required: true,
    email: true,
   }
   
  },
  messages: {
   
   'ftk_email[]': {
    required: "Please enter FTK Email.",
    email: "Please enter a valid FTK Email.",
   }
   
  },
  submitHandler: function(form) {
   customvalidation();
   jQuery('#ajax_check_send').text('Submitting...');
   form.submit();
   jQuery('#ajax_check_send').text('');
   // avoid to execute the actual submit of the form.
  }
 });

});
<form method="post" name="winner_register" id="winner_register" action="" class="form-validate" autocomplete="off" novalidate="novalidate">
<input type="text" class="required form-control" name="ftk_email[]" id="ftk_email_1" value="" title="Please enter FTK Email.">
<small class="error" generated="true" for="ftk_email_1" style="display:none"></small>
<input type="text" class="required form-control" name="ftk_email[]" id="ftk_email_2" value="" title="Please enter FTK Email.">
<small class="error" generated="true" for="ftk_email_2" style="display:none"></small>
 <input type="submit" name="compAdd" value="Submit" title="Submit" id="submitButton" class="create_btn btn-intel btn">
</form>
updated the below code on jquery validate library
jquery.validate.js
checkForm: function() {
    this.prepareForm();
    for (var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++) {
        if (this.findByName(elements[i].name).length != undefined && this.findByName(elements[i].name).length > 1) {
            for (var cnt = 0; cnt < this.findByName(elements[i].name).length; cnt++) {
                this.check(this.findByName(elements[i].name)[cnt]);
            }
        } else {
            this.check(elements[i]);
        }
    }
    return this.valid();
}

Wednesday, February 21, 2018

How to resolve DMARC and DKIM pass in mailer header in php

Hey    , Guy

I am sharing my experienced which I faced lot of effort to resolve the DKIM and DMARC fail issue on email sent.

Finally I resolved the issue using changing the header below and validate the html tag in your email body.


Here is the result of pass by google and test mailer

SPF:PASS with IP 203.85.210.401 Learn more
DKIM:'PASS' with domain gmail.com Learn more
DMARC:'PASS' 

function sendNewsLetter($id='', $to_name='', $to_address=''){

    $from_name    = 'Phptechnicalgroups';
    $from_address = 'contact@phptechnicalgroups.com';
    $reply_address = 'no-reply@phptechnicalgroups.com';
//hiddenUrl variable call when user read the email to identify
 $hiddenUrl      = 'http://phptechnicalgroups.blogspot.in/captcha.php?type=mailer_socialhub_february_2018&id='.$id;

$maildescription ='<html>
<head>

</head>

<body style="margin: 0; padding: 0;">
    <div style="display: none;">
        <img alt="" src="'.$hiddenUrl.'" width="0px" height="0px">
    </div>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Phptechnicalgroup - Social Hub Updates - January 2018</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
</body>
</html>';
     $subject  = "Subject your email";
    $mime_boundary = "----boundary text----".MD5(TIME().$id.TIME());
    $additional ='webmaster@phptechnicalgroups.blogspot.in';
    $headers .= 'Date:' .date('r', $_SERVER['REQUEST_TIME']) . "\r\n";
    $headers .= "Message-ID:<" . $_SERVER['REQUEST_TIME'] . md5($_SERVER['REQUEST_TIME']) .$id. "@" . $_SERVER['SERVER_NAME'] . ">\r\n";
    $headers .= "Return-Path:".$from_name."<".$reply_address.">\r\n";
    $headers .= "X-Mailer: PHP v".phpversion()."\r\n";
    $headers .= "X-Originating-IP:".$_SERVER['SERVER_ADDR']."\r\n";
    $headers .= "List-Unsubscribe: <mailto:".$from_address.">\r\n";
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= 'From: Intel Network Builders <contact@phptechnicalgroups.blogspot.in>' . "\r\n";
    $headers .= 'Bcc:  <nayakr.bikash@gmail.com>' . "\r\n";
    $headers .= 'Reply-To: Intel Network Builders <no-reply@phptechnicalgroups.blogspot.in>' . "\r\n";
    $headers .= "Content-Type: multipart/mixed; boundary=\"$mime_boundary\"\r\n";

//Create Email Body (HTML)
    $message = "--$mime_boundary\n";
    $message .= "Content-Type: text/html; charset=UTF-8\n";
    $message .= "Content-Transfer-Encoding: 8bit\n\n";
    $message .= "<html>\n";
    $message .= "<body>\n";
    $message .= $maildescription;
    $message .= "</body>\n";
    $message .= "</html>\n";
    $message .= "--$mime_boundary\n";
    
    $mailsent = mail($to_address, $subject, $message, $headers,'-f'.$additional);
    return ($mailsent)?(true):(false);
  }

Hopefully it will help you , thank you!