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

  • SEARCH
  • Home
  • 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 7488027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T14:43:04+00:00 2026-05-29T14:43:04+00:00

Is there any way how to send digital signed email with pear Mail? I

  • 0

Is there any way how to send digital signed email with pear Mail?

I thied this code, but it hasnt run.

    <?php
    require_once("Mail.php");
    require_once('Mail\mime.php');

    $recipients = "petr.kostroun@xxx.cz";

    $headers["From"] = "mailer@xxx.cz";
    $headers["To"]      = $recipients;
    $headers["Subject"] = "Zkouska";

    $params["host"] = "mail.xxx.cz";
    $params["username"] = "server@xxx.cz";
    $params["password"] = "xxx";

    $body = "Zkouska Spojeni !";

    $mime = new Mail_mime();

    $fp = fopen("./msg.txt", "w");
    fwrite($fp, $body );
    fclose($fp);

    echo "Sending mail:\n";
    echo "Headers:\n" . print_r($headers);
    echo "\n\nBody:\n$body";
    echo "\n---END OF MAIL BODY---\n";

    openssl_pkcs7_sign("C:/data/www/msg.txt", "C:/data/www/signed.txt", "file://C:/data/www/04.pem", "file://C:/data/www/newkey.pem", $headers);

    $data = file_get_contents("C:/data/www/signed.txt");

    $mime->setTXTBody($data);

    $body = $mime->get();
    $headers = $mime->headers($headers);

    $headers["Content-Type"] = "Multipart/signed; protocol=\"application/pkcs7-signature\"; micalg=sha1; boundary=\"------------ms070206070302000302000502\"";

    $mail_object =& Mail::factory("smtp", $params);
    $mail_object->send($recipients, $headers, $body);
    echo "Email sent";


    ?>

Can somebody give me advice how to solve this issue? Thanks.

**
I found on internet solution, where man can genarate signed email in file with openssl_pkcs7_sign function. I have generated this file, but I dont know how parse this file for $mail_object->send function args. Expecially I dont know how to construct headers array

File content :

MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
From: info@xxx.cz
To: petr.kostroun@xxx.cz, vysledky@xxx.cz
Subject: Zkouska
MIME-Version: 1.0
Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg="sha1"; boundary="----E3E6271C75DBBBCB30B457C24A97B23B"

This is an S/MIME signed message

------E3E6271C75DBBBCB30B457C24A97B23B
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
From: info@xxx.cz
To: petr.kostroun@xxx.cz, vysledky@xxx.cz
Subject: Zkouska

#Zkusebni podepsanej email, neodpovidejte prosim
------E3E6271C75DBBBCB30B457C24A97B23B
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"

MIIE9wYJKoZIhvcNAQcCoIIE6DCCBOQCAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3
DQEHAaCCApswggKXMIICAAIBBDANBgkqhkiG9w0BAQQFADCBnDELMAkGA1UEBhMC
Q1oxFzAVBgNVBAgMDkN6ZWNoIFJlcHVibGljMQ8wDQYDVQQHDAZQcmFndWUxDzAN
BgNVBAoMBkRhbnRlbTERMA8GA1UECwwIRW1wbG95ZWUxFzAVBgNVBAMM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MCMGCSqGSIb3DQEJBDEWBBTW5eHrz1I9fM/YTcek/1RBvTrPqzB5
BgkqhkiG9w0BCQ8xbDBqMAsGCWCGSAFlAwQBKjALBglghkgBZQMEARYwCwYJYIZI
AWUDBAECMAoGCCqGSIb3DQMHMA4GCCqGSIb3DQMCAgIAgDANBggqhkiG9w0DAgIB
QDAHBgUrDgMCBzANBggqhkiG9w0DAgIBKDANBgkqhkiG9w0BAQEFAASBgIUpL8bB
w4UpFJEdUO2f0aIc0nm7XnEtVUPkBhhfAfikSJLjNraLmlwQq0f7R/EHdeUzutvW
nuY8A5NtqNF/Efyy8g19GEXCDgxYMgSiUn8AEhhdUvs7Qe45B3ONgLdYfmnF8yX/
w/ZrUGzcmG46dsH/HPapYFmscmbbm5G1GWdU
------E3E6271C75DBBBCB30B457C24A97B23B--

Thanks for help

  • 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-29T14:43:07+00:00Added an answer on May 29, 2026 at 2:43 pm

    openssl_pkcs7_sign(“C:/data/www/msg.txt”, “C:/data/www/signed.txt”,
    “file://C:/data/www/04.pem”, “file://C:/data/www/newkey.pem”,
    $headers);

    I think you should try:

    openssl_pkcs7_sign("C:/data/www/msg.txt", 
                       "C:/data/www/signed.txt", 
                       "file://C:/data/www/04.pem", 
                       array("file://C:/data/www/newkey.pem","CRT pass"), 
                       $headers);
    

    and sending the header params:

    $data = file_get_contents("C:/data/www/signed.txt");
    $parts = explode("\n\n", $data, 2);
    
    // with mail() function you should
    mail($to, $subject, $parts[1], $parts[0]);
    
    // I suppose in the same way for Pear Mail
    $mail_object =& Mail::factory("smtp", $params);
    $mail_object->send($recipients, $parts[0], $parts[1]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way I can send an email, like any frameworks or something.
is there any way that when i user send an email to admin@xx.com the
Is there any way to send a variable to another function? like for this
Is there any way to send mail at specific time in php? Please give
is there any way to send whats in a text view (im trying to
I know that soap can send XML over http, is there any way to
I was wondering if there was any way through C# or C++ to send
Is there any way to send object / image content type created by Flotr
Is there any way to send a song title to the spotify app from
Is there any way to send a business card to a mobile phone using

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.