I have used WP-Mail-SMTP
to setup the mailer on my WordPress installation.
I have tested it by sending email to my private mail.
I am now trying to send the form data using wp_mail() function[WP].
Below is the code.
<?php
if(isset($_POST["button_pressed"])){
// Checking For Blank Fields..
if($_POST["dname"]==""){
echo "Fill All Fields..";
}
else {
$email=$_POST['email'];
$message = $_POST['dname'];
$headers = 'From:' . "\r\n"; // Sender's Email
$headers .= 'Cc:' . "\r\n"; // Carbon copy to Sender
// Message lines should not exceed 70 characters (PHP rule), so wrap it
// $message = wordwrap($message, 70);
wp_mail("PRIVATE-EMAIL-ADDRESS", $subject, $message, $headers)
echo "Your mail has been sent successfully ! Thank you for your feedback";
}
?>
HTML form
<form>
<div class="row">
<div class="form-group">
<div class="col-sm-6"><input class="form-control" type="text" placeholder="ENTER DOG'S NAME" id="dname" /></div>
<div class="col-sm-6"><input class="form-control" type="text" placeholder="ENTER OWNER'S NAME" id="name" /></div>
</div>
</div>
<input type="submit" value="SUBMIT" />
<input type="hidden" name="button_pressed" value="1" />
</form>
I have tried many tutorials, but none helped. Your comments and suggestions will be very helpful to me. Thanks for your time.
> wp_mail("PRIVATE-EMAIL-ADDRESS"
are you sending to the correct email address?