On my WordPress site I am trying to mail() the output of a function however it is failing to return the output but will return hard coded outputs placed inside the while loop.
Essentially what I am asking is what in this code is wrong and how do I fix it. I would rather be tutored in what I have done wrong than "Have fixed code; copy and paste" if at all possible.
I am purposely trying to stay away from inbuilt WordPress functions and calls
EDIT:
When I echo $string; it displays with the expected output formatted as I intended, with the exclusion of the contents between ob_start() and ob_end_clean().
The functions are fetching the data properly it just is not being included in the email to be sent out, which is being sent it just appears blank. When sent as plaintext the email contents are as follows
<html><br /><br /></html>
I just inspected the output of the code, with the intent of displaying it to you so you can see the outcome and I noticed that this is included in-place of all the outputted emails, due to a "bonus feature" of one of my plugins, I am not sure which one, as this is nothing I have coded. Included inline due to not meeting reputation requirements to post more than two hyperlinks.
<p>[email protected]<script type="text/javascript"> /* <![CDATA[ */ (function(){try{var s,a,i,j,r,c,l=document.getElementById("__cf_email__");a=l.className;if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})(); /* ]]> */ </script><br> <br> </p>
To the best of my knowledge scripts cannot be run in emails, but surely this would not cause a failure to display the rest of the code, just render the scripts useless.