I am sending an email to my outlook account every time the <a> is clicked. I want that the message has the title of the wordpress post where the link was clicked, however, it is not printed in the email. It's not recognizing the_title(); to get post title. Other problem is that the email is going into the spam folder.
how to fix this?
<a href="#" onclick="callFunction();">Report</a>
<script type="text/javascript">
function callFunction(){
<?php
$message = ''.the_title();
$to = "my@outlook.com";
$subject = "Expired post report";
$from = "reporting@website.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
?>
}
</script>
Aucun commentaire:
Enregistrer un commentaire