I am trying to make a popup contact form with a file upload field when I submit the form it says
The email has been sent!
but on the receiver email, I don't get any email. I have tried many solutions but no luck here. is my popup model code with form processing PHP code?
<div class="modal fade price-quote" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<span class="modal-title" id="lineModalLabel">Contact <?php echo (get_the_title($listing_id) != "") ? get_the_title($listing_id) : "Directory" ; ?>
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">✕</span>
<span class="sr-only">Close</span>
</button>
</span>
</div>
<div class="modal-body">
<!-- content goes here -->
<?php
$user_info = get_userdata(get_current_user_id());
?>
<?php if (is_user_logged_in() != true ) { ?>
<div class="alert alert-danger registration-error" style="margin-left:0px">You must be
register to send a message. <a href="/signup/" class="font-weight-bold">Sign Up</a>
</div>
<?php }
if ( is_user_logged_in() ) {
?>
<form id="send_message_pop" enctype="multipart/form-data">
<div class="form-group col-md-12 col-sm-12">
<input type="email" name="email" placeholder="Email" class="form-control"
value="<?php echo esc_attr($user_info->user_email) ? esc_attr($user_info->user_email) : "" ?>">
</div>
<div class="form-group col-md-12 col-sm-12">
<input type="text" name="name" placeholder="Name" class="form-control"
value="<?php echo esc_attr($user_info->display_name) ? esc_attr($user_info->display_name) : ""?>">
</div>
<?php
// print_r($user_info);
// $phone = get_user_meta($current_user->ID,'_sb_ph_num_',true);
// echo $phone;
?>
<div class="form-group col-md-12 col-sm-12">
<input type="text" name="phone_no" placeholder="Phone number" class="form-control"
value="">
</div>
<div class="form-group col-md-12 col-sm-12">
<input type="text" name="zip_code" placeholder="Zip Code" class="form-control"
value="">
</div>
<div class="form-group col-md-12 col-sm-12">
<textarea id="sb_forest_message" name="message" placeholder="Message"
placeholder="<?php echo __('Type here...', 'adforest');?>" rows="3" class="form-control"
data-parsley-required="true"
data-parsley-error-message="<?php echo __('This field is required test.', 'adforest');?>"></textarea>
</div>
<div class="form-group col-md-12 col-sm-12">
<label for='uploaded_file'>Select A File To Upload:</label>
<input type="file" name="file" id="file"></div>
<div class="form-group col-md-12 col-sm-12">
<?php echo do_shortcode("[bws_google_captcha]"); ?>
</div>
<div class="clearfix"></div>
<div class="col-md-12 col-sm-12 margin-bottom-20 margin-top-20">
<input type="hidden" name="ad_post_id" value="<?php echo esc_attr($pid);?>" />
<input type="hidden" name="usr_id" value="<?php echo get_current_user_id();?>" />
<button type="submit" id="send_ad_message"
class="btn btn-theme btn-block"><?php echo __('Send Message', 'adforest');?></button>
</div>
</form>
<?php } ?>
<?php
$post_id = esc_attr($pid);
$post_title = get_the_title( $post_id );
global $wpdb;
$wpdb_prefix = $wpdb->prefix;
$wpdb_tablename = $wpdb_prefix.'postmeta';
$post_id_email = $wpdb->get_results( "SELECT * FROM $wpdb_tablename WHERE post_id = '$post_id' AND meta_key = '_wpbdp[fields][22]'", OBJECT);
foreach ($post_id_email as $meta)
{
$business_email = $meta->meta_value; // Set single meta as array
}
$post_link = get_permalink($post_id);
$mail_from_id = get_current_user_id();
$mail_from_info = get_userdata($mail_from_id);
$mail_from = $mail_from_info->user_email;
$user_name = $mail_from_info->display_name;
if($business_email !== ""){
$mail_to = $business_email;
}else{
$mail_to_id = esc_attr($poster_id);
$mail_to_info = get_userdata($mail_to_id);
$mail_to = $mail_to_info->user_email;
}
if(isset($_GET['email'])){
$get_email = $_GET['email'];
$get_msg = $_GET['message'];
$subject = "You Have a New Reply!";
$attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name'])));
$filename = $_FILES['file']['name'];
$boundary =md5(date('r', time()));
$headers = "From: 'The Builders Market' <$mail_from>";
$headers .= "MIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\"";
$message = "<html>
<head>
</head>
<body>
<table class='body' style='border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f6f6f6; width: 100%;' border='0' cellspacing='0' cellpadding='0'>
<tbody>
<tr>
<td style='font-family: sans-serif; font-size: 14px; vertical-align: top;'> </td>
<td class='container' style='font-family: sans-serif; font-size: 14px; vertical-align: top; display: block; max-width: 580px; padding: 10px; width: 580px; margin: 0 auto !important;'>
<div class='content' style='box-sizing: border-box; display: block; margin: 0 auto; max-width: 580px; padding: 10px;'>
<table class='main' style='border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background: #fff; border-radius: 3px; width: 100%;'>
<tbody>
<tr>
<td class='wrapper' style='font-family: sans-serif; font-size: 14px; vertical-align: top; box-sizing: border-box; padding: 20px;'>
<table style='border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;' border='0' cellspacing='0' cellpadding='0'>
<tbody>
<tr style='font-family: Helvetica Neue,Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;'>
<td class='alert' style='font-family: Helvetica Neue,Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 16px; vertical-align: top; color: #000; font-weight: 500; text-align: center; border-radius: 3px 3px 0 0; background-color: #fff; margin: 0; padding: 20px;' align='center' valign='top' bgcolor='#fff'><img class='alignnone size-medium' src='https://www.thebuildermarket.com/wp-content/uploads/2020/06/slider-5.png' alt='' width='500' height='200' /></td>
</tr>
<tr>
<td style='font-family: sans-serif; font-size: 14px; vertical-align: top;'>
<p>Greetings<strong>,</strong></p>
<p>Good news! Your project posting ".$post_title." has a reply.</p>
<p>Your message is from: ".$user_name."</p>
<p>Here is your message: ".$get_msg." </p>
<p>To see your message click here: $post_link</p>
<p>As a reminder, here are a few tips when dealing with pros:</p>
<ol>
<li>The pro doesn’t have any of your personal contact info, so if you’re interested please make sure to contact the pro directly.</li>
<li>Quotes are non-binding. There are many variables that pros need to have in order to give you accurate pricing. Although Builders Market is the best way to get a preliminary quote, it’s recommended to meet with the pro in-person to review the project in-depth.</li>
<li>Make sure to verify the pro before doing business. It’s your responsibility to make sure that the pro is qualified to complete your project. We are currently working on vetting pros, so if a pro has met our qualifications you’ll see a “Vetted” badge on their business listing profile. Please encourage pros to become “Vetted”.</li>
<li>If the message is spam or inappropriate please let us know immediately. Replying to project postings is currently free, so we apologize if you receive unwanted messages.</li>
<li>If the message from the pro doesn’t meet your standards, you should let the pro know that they need to send better messages. </li>
</ol>
<p style='font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;'>The Builder Market</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<div class='footer' style='clear: both; padding-top: 10px; text-align: center; width: 100%;'>
<table style='border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;' border='0' cellspacing='0' cellpadding='0'>
<tbody>
<tr>
<td class='content-block powered-by' style='font-family: sans-serif; font-size: 12px; vertical-align: top; color: #999999; text-align: center;'><a style='color: #999999; text-decoration: underline; font-size: 12px; text-align: center;' href='http://buildersmarket.com/' target='_blank' rel='noopener'>Builders Market</a>.</td>
</tr>
</tbody>
</table>
</div>
</div>
</td>
<td style='font-family: sans-serif; font-size: 14px; vertical-align: top;'> </td>
</tr>
</tbody>
</table>
</body>
</html>
--_1_$boundary
Content-Type: multipart/alternative; boundary=\"_2_$boundary\"
--_2_$boundary
Content-type:text/html;charset=UTF-8
Content-Transfer-Encoding: base64
$message
--_2_$boundary--
--_1_$boundary
Content-Type: application/octet-stream; name=\"$filename\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
$attachment
--_1_$boundary--";
if ( mail($mail_to,$subject,$message,$headers) ) {
echo "The email has been sent!";
} else {
echo "The email has failed!";
}
}
?>
</div>
</div>
</div>
</div>