title: Function is not not working inside PHP mail body
body: <p>I'm using this to send a basic email:</p>
  
  <pre><code>// Email details
  $name = 'Davo';
  $recipient = 'info@davo.com';
  $from = 'sender@example.com'
  $subject = 'Testing';
  
  // All plugins
  function the_plugins() {
      $the_plugs = get_option('active_plugins'); 
      foreach($the_plugs as $key =&gt; $value) { 
          $string = explode('/',$value); print $string[0] . '&lt;br /&gt;';
      }
  }
  
  // Message
  $body = '&lt;p&gt;Hello' . $name . ',&lt;/p&gt;';
  $body .= '&lt;p&gt;Your website has these plugins:&lt;/p&gt;';
  $body .= the_plugins();
  $body .= '&lt;p&gt;Have a nice day.&lt;/p&gt;';
  
  $headers[]  = 'Content-type:text/html;charset=UTF-8';
  $headers[]  = 'From' . $name. ' &lt;' . $from . '&gt;';
  $headers[]  = 'Reply-To: ' . $from;
  $headers[]  = 'MIME-Version: 1.0';
  wp_mail($recipient, $subject, $body, $headers);
  </code></pre>
  
  <p>The only things that does not work is <code>the_plugins()</code> function does not show anything in the email that arrives. Instead it's just empty in the line where I expect to see the list of plugins, and looks like this:</p>
  
  <pre><code>Hello Davo,
  Your website has these plugins:
  
  Have a nice day.
  </code></pre>
  
  <p>FYI <code>the_plugins()</code> function works. I am able to <code>echo the_plugins(); exit;</code> right after the function and it returns a list of the plugins, so the function itself is not the problem.</p>
  
  <p>Any suggestions on how to get around this?</p>