php contact form sends the mail to spam instead of inbox.
using php with wordpress , tried using contact form 7 but
conflict with bootstrap js made me go back to the core php.
help this form to reach the admin inbox
<?php
if ($_POST[sent]) {
$error = "";
if (!trim($_POST[your_name])) {
$error .= "<p>Please enter your name</p>";
}
if (!filter_var(trim($_POST[your_email]), FILTER_VALIDATE_EMAIL)) {
$error .= "<p>Please enter a valid email address</p>";
}
if (!trim($_POST[your_message])) {
$error .= "<p>Please enter a message</p>";
}
if (!$error) {
//trim($_POST[your_name])." sent you a message from ".get_option("blogname")." website "." on subject "
$email = mail(get_option("admin_email"), trim($_POST[your_subject]), stripslashes(trim($_POST[your_message])), "From: " . trim($_POST[your_name]) . " <" . trim($_POST[your_email]) . ">\r\nReply-To:" . trim($_POST[your_email]));
}
}
?>
<?php get_header(); ?>
<!--contact_part-->
<div class="main-title" style="background-color: #f2f2f2; ">
<div class="container">
<h1 class="main-title__primary">Contact Us</h1>
<h3 class="main-title__secondary">WE ARE WAITING YOU TO GET IN TOUCH WITH US</h3>
</div>
</div>
<div class="master-container">
<div class="map">
<div style="text-decoration:none; overflow:hidden; height:350px; width:100%; max-width:100%;">
<div id="embed-map-display" style="height:100%; width:100%;max-width:100%;">
<iframe style="height:100%;width:100%;border:0;" frameborder="0"
src="https://www.google.com/maps/embed/v1/place?q=qather+dhoha&key=AIzaSyAN0om9mFmy1QN6Wf54tXAowK4eT0ZUPrU"></iframe>
</div>
<a class="embed-map-html" href="https://www.treat-lice.com/head-lice-treatment-101/"
id="authorize-map-data">Head lice treatment 101</a>
<style>#embed-map-display .text-marker {
max-width: none !important;
background: none !important;
}
img {
max-width: none
}</style>
</div>
</div>
<div class="spacer-big"></div>
<div role="main" class="hentry container">
<div class="row">
<div class="col-md-12">
<div class="panel panel-grid widget widget_text panel-last-child">
<h3 class="widget-title">Contact Us</h3>
</div>
</div>
</div>
<div class="spacer"></div>
<div class="row">
<div class="col-md-3">
<div class="textwidget panel widget">
<span class="icon-container"><span class="fa fa-home"></span></span> <b>Emerge trading & contracting
WLL</b><br>
<?= get_template_option_values('your_place'); ?><br>
<?= get_template_option_values('your_place_address'); ?><br><br>
<span class="icon-container"><span class="fa fa-phone"></span></span> <b>
<?= get_template_option_values('cc_email_address'); ?>
,<?= get_template_option_values('cc_contact_numbers'); ?></b><br>
<span class="icon-container"><span class="fa fa-envelope"></span></span><a
href="mailto:info@example.com"><?= get_template_option_values('mail-id'); ?></a>
<br><br>
<span class="icon-container"><span class="fa fa-home"></span></span>
<b><?= get_template_option_values('working_time'); ?></b><br>
<?= get_template_option_values('working_days'); ?>
</div>
<div class="panel widget widget_pt_social_icons panel-last-child">
<a target="_blank" href="http://www.facebook.com/<?= get_template_option_values('facebook_id'); ?>"
class="social-icons__link"><i class="fa fa-facebook"></i></a>
<a target="_blank" href="http://www.twitter.com/<?= get_template_option_values('twitter_id'); ?>"
class="social-icons__link"><i class="fa fa-twitter"></i></a>
</div>
</div>
<div class="col-md-9">
<div lang="en-US" dir="ltr" id="wpcf7-f5-o1" class="wpcf7">
<div id="container">
<div id="content" role="main">
<?php if (have_posts()) while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<!--<h1 class="entry-title"><?php the_title(); ?></h1>-->
<div class="entry-content">
<?php if ($email) { ?>
<p><strong>Message succesfully sent. We will get back to you
shortly.</strong></p>
<?php } else {
if ($error) { ?>
<p><strong>Your messange has not been sent</strong><p>
<?php echo $error; ?>
<?php } else {
the_content();
} ?>
<form novalidate class="wpcf7-form" action="<?php the_permalink(); ?>"
id="contact_me" method="post">
<input type="hidden" name="sent" id="sent" value="1"/>
<div class="row">
<div class="col-xs-12 col-sm-4">
<span class="wpcf7-form-control-wrap your-name">
<input type="text" placeholder="Your Name" class="wpcf7-form-control wpcf7-text"
size="40" value="" name="your_name" id="your_name">
</span><br>
<span class="wpcf7-form-control-wrap your-email">
<input type="email" placeholder="E-mail address"
class="wpcf7-form-control wpcf7-text wpcf7-email" size="40" value=""
name="your_email" id="your_email">
</span><br>
<span class="wpcf7-form-control-wrap your-subject">
<input type="text" placeholder="Subject" class="wpcf7-form-control wpcf7-text"
size="40" value="" name="your_subject" id="your_subject">
</span>
</div>
<div class="col-xs-12 col-sm-8">
<span class="wpcf7-form-control-wrap your-message">
<textarea placeholder="Message" class="wpcf7-form-control wpcf7-textarea"
style="height:220px;" rows="10" cols="40" name="your_message"
id="your_message"></textarea>
</span><br>
<input type="submit" name="send"
class="wpcf7-form-control wpcf7-submit btn btn-primary"
value="SEND MESSAGE">
</div>
</div>
</form>
<?php } ?>
</div><!-- .entry-content -->
</div><!-- #post-## -->
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #container -->
<!--<?php get_sidebar(); ?>-->
</div>
</div>
</div>
</div>
<div class="spacer-big"></div>
答案 0 :(得分:0)
解决了所有麻烦..只需将此一个放在标头参数之后..
$email = mail(get_option("admin_email"),trim($_POST[your_subject]),stripslashes(trim($_POST[your_message])),$headers, "-fsender@domain.com");