Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6805351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:34:33+00:00 2026-05-26T19:34:33+00:00

On my WordPress site I am trying to mail() the output of a function

  • 0

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>

Updated Code

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>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 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.

Expected Output

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:34:34+00:00Added an answer on May 26, 2026 at 7:34 pm

    On line 34:

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

    should be

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

    That’s why it keeps saying the mail is not sent. It has been sent but you didn’t set the variable you are checking.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a WordPress site that has six lists on a page,
i have a wordpress site and i am trying to add a phpbb3 forum
I am trying to set up a page on a wordpress site that displays
I'm switching a Wordpress site from Apache to Nginx. We're trying to obfuscate the
I've restructured a WordPress site that's hosted on a Windows server, so I'm trying
I'm moving a locally developed wordpress site to a client's server so I'm trying
I'm trying to build a site based on Wordpress for a client. Eventually it
I am trying to implement WordPress into quite a large site with a complex
I'm trying to get the menu on my WordPress site to align center. I
I am trying to integrate the Jquery UI select menu, in my wordpress site.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.