title: Issue sending digitally signed emails to Gmail from php
body: <p>I am trying to send digitally signed email messages via PHPBB. I have it working well for all our exchange emails and all the various clients, but it is not working for gmail users. It seems almost like google is not processing/reading the multipart mime type. Maybe I am missing something silly or easy? Thank you for looking!</p>
  
  <p>Here is an example of a test email, the cert is blocked out with #:</p>
  
  <blockquote>
    <p>This is an S/MIME signed message</p>
    
    <p>------############################  Content-Type: text/html; charset="iso-8859-1"</p>
    
    <p>Content-Transfer-Encoding: 8bit</p>
    
    <p>Hello admin,</p>
    
    <p>Congratulations. If you received this email, phpBB is correctly
    configured  to send emails.</p>
    
    <p>In case you require assistance, please visit the phpBB support forums
    -  <a href="https://www.phpbb.com/community/" rel="nofollow noreferrer">https://www.phpbb.com/community/</a></p>
    
    <p>--</p>
    
    <p>------############################  Content-Type:
    application/x-pkcs7-signature; name="smime.p7s" 
    Content-Transfer-Encoding: base64  Content-Disposition: attachment;
    filename="smime.p7s"</p>
    
    #
    
    #
    
    #
    
    #
    
    #
    
    #
    
    #
    
    #
    
    #
    
    #
    
    #
    
    #
    
    #
    
    #
    
    #
    
    #
    
    #
    
    #
    
    #
    
    #
    
    #
    
    <p>------############################--</p>
  </blockquote>
  
  <p>Here is snippet of the code I am using:</p>
  
  <pre><code>// Send message ...
  $mail_to = ($to == '') ? 'undisclosed-recipients:;' : $to;
  $fp = fopen("/var/www/ssl/ext/phpbbservices/digests/includes/msg.txt", "w"); 
  $this-&gt;msg = "".'Content-Type: text/html; charset="iso-8859-1" 
  Content-Transfer-Encoding: 8bit'. "\n\n" .  $this-&gt;msg . "\n";
  fwrite($fp, $this-&gt;msg); 
  fclose($fp);
  
  openssl_pkcs7_sign("/var/www/ssl/ext/phpbbservices/digests/includes/msg.txt", "/var/www/ssl/ext/phpbbservices/digests/includes/signed.txt", file_get_contents("/var/www/ssl/ext/phpbbservices/digests/includes/publicCert.pem"), array(file_get_contents("/var/www/ssl/ext/phpbbservices/digests/includes/privateKey.pem"), 'PASSWORD_FOR_PRIVATE_KEY'), $headers); 
  $data = file_get_contents("/var/www/ssl/ext/phpbbservices/digests/includes/signed.txt");
  
  
  $parts = explode("\n\n", $data, 2);
  $newHeader = explode("\n", $parts[0]);
  
  $newMessage =  $parts[1];
  
  
  $result = phpbb_mail($mail_to, $this-&gt;subject, $newMessage, $newHeader, PHP_EOL, $err_msg);   
  </code></pre>