0
anjan 3 Rep.

How i send contact form data to specific email address and how i redirect.  For form design I use this code.

<form name=”sentMessage” id=”contactForm” validate action=”mail.php” method=”post”>
<div class=”row”>
<div class=”col-md-6″>
<div class=”form-group”>
<input type=”text” class=”form-control” name=”name” placeholder=”Your Name *” id=”name” required data-validation-required-message=”Please enter your name.”>
<p class=”help-block text-danger”></p>
</div>
<div class=”form-group”>
<input type=”email” name=”email” class=”form-control” placeholder=”Your Email *” id=”email” required data-validation-required-message=”Please enter your email address.”>
<p class=”help-block text-danger”></p>
</div>
<div class=”form-group”>
<input type=”tel” name=”phone” class=”form-control” placeholder=”Your Phone *” id=”phone” required data-validation-required-message=”Please enter your phone number.”>
<p class=”help-block text-danger”></p>
</div>
</div>
<div class=”col-md-6″>
<div class=”form-group”>
<textarea class=”form-control” name=”messages” dirname=”message” placeholder=”Your Message *” id=”message” required data-validation-required-message=”Please enter a message.”></textarea>
<p class=”help-block text-danger”></p>
</div>
</div>
<div class=”clearfix”></div>
<div class=”col-lg-12 text-center”>
<div id=”success”></div>
<button type=”submit” class=”btn btn-xl” name=”action”>Send Message</button>
</div>
</div>
</form>

 

Below my mail.php

 

if (isset($_POST[’action’])) {

// add_filter(‘wp_mail_content_type’, ‘wpdocs_set_html_mail_content_type’);

$args [’to’] = ‘something010@gmail .com’;
$args [’subject’] = $_POST[’email’];
$args [’body’] = $_POST[’messages’];
$args [’headers’] = $_POST[’name’];

add_filter( ‘wp_mail’, ‘my_wp_mail_filter’ );
function my_wp_mail_filter( $args ) {

$new_wp_mail = array(
‘to’ => $args[’to’],
‘subject’ => $args[’subject’],
‘message’ => $args[’body’]
‘headers’ => $args[’headers’],
);

return $new_wp_mail;
}

header(“Location : http://google.com/”);
}

anjan edited question