On my small WordPress site I'm attempting to mail() the creation of a function yet it's neglecting to return the output and can return hard coded results placed within the while loop.

Basically things i am asking is exactly what within this code is wrong and just how will i repair it. I'd prefer to be tutored with what I've done wrong than "Have fixed code copy" if whatsoever possible.

I'm intentionally trying to step back from built-in WordPress functions and calls

EDIT: After I echo $string; it shows using the expected output formatted when i intended, using the exclusion from the contents between ob_start() and ob_end_clean().

The functions are fetching the information correctly it simply isn't being incorporated within the email to become sent, that is being sent it simply seems blank. When sent as plaintext the e-mail contents are the following

<html><br /><br /></html>

Updated Code

I simply looked over the creation of the code, using the intent of exhibiting it for you so that you can begin to see the outcome and that i observed this is incorporated in-place of all of the outputted emails, because of a "bonus feature" of 1 of my plug ins, I don't know which, because this is nothing I've coded. Incorporated inline because of not meeting status needs to publish a lot more than two hyperlinks.

<p>ward@halifaxonline.com.au<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 very best of my understanding scripts can't be run in emails, but surely this could not result in a failure to show the relaxation from the code, just render the scripts useless.

Expected Output

Online 34:

mail($to, 'Test', $string, $headers) ;

ought to be

$sent = mail($to, 'Test', $string, $headers) ;

This is exactly why it keeps saying the mail isn't sent. It's been sent however, you did not set the variable you're checking.