This is meant to be up in the next week or so, but I am having a lot of trouble getting the site to send emails to an address specified in an input box.
I need to use wp_mail as I need to be able to pass php variables (email, body AND attachment) to an email.
I have set up the form correctly as far as I can see, but after searching around a bit I found out that using JQuery (AJAX specifically) was the best/only way to do this, but I have no idea how that all works.
I am hoping someone here can explain this to me so I can get this working as quickly as possible.
In my shortcode, this is added to the page(ignore the script function, failed attempt):
<div class="downloadHolder">
<h3>Download</h3>
<p style="margin-bottom: 20px;">Please note: FTB files can only be used if you have Free The Blobs on Android or iOS.</p>
<a href="<?php echo $intro;?>" download="<?php echo basename($intro) ?>" class="demoBtn">Download for PC</a>
<!--<a href="#" class="demoBtn">Demo</a>--><br>
<input type="text" name="emailValue" placeholder="Email Address" class="emailInput" style="text-align: center;">
<br><span>(We do NOT collect email addresses.)</span><br><br>
<button onclick="echoSendMail()" class="downloadBtn" style="width: 100% !important;">Email for Mobile</button>
</div>
<script>
function echoHello(){
alert("<?PHP emailSend(); ?>");
}
</script>
And later in that same php file, I have this function($intro is the url to an uploaded file (the attachment)):
function emailSend(){
$to = $_GET['emailValue'];
$subject = 'Download for'.basename($intro);
$msg = 'Your download for'.basename($intro).'is attached to this email.';
$headers = 'From: My Name <myname@mydomain.com>' . "\r\n";
$mail_attachment = array(get_post_meta($post -> ID, $key = 'podcast_file', true));
wp_mail($to, $subject, $msg, $headers, $mail_attachment);
}
<form action="">
element?