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 7699591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:30:53+00:00 2026-05-31T22:30:53+00:00

I’m using Mime::Lite to create and send E-Mails. Now I need to add support

  • 0

I’m using Mime::Lite to create and send E-Mails. Now I need to add support for S/Mime-encryption and finally could encrypt my E-Mail (the only Perllib I could install seems broken, so I’m using a systemcall and openssl smime), but when I try to create a mime-object with it, the E-Mail will be broken as soon as I set the Content-Transfer-Encoding to base64. To make it even more curious, it happens only if I set it via $myMessage->attr. If I’m using the constructor ->new everything is fine, besides a little warning which I suppress by using MIME::Lite->quiet(1);

Is it a bug or my fault? Here are the two ways how I create the mime-object.

  1. Setting the Content-Transfer-Encoding via construtor and suppress the warning:

    MIME::Lite->quiet(1); 
    my $msgEncr = MIME::Lite->new(From   =>'me@myhost.com',
                            To     => 'you@yourhost.com',
                           Subject => 'SMIME Test',
                           Data    => $myEncryptedMessage,
                           'Content-Transfer-Encoding' => 'base64');
    
    $msgEncr->attr('Content-Disposition'        =>  'attachment');
    $msgEncr->attr('Content-Disposition.filename'   =>  'smime.p7m');
    $msgEncr->attr('Content-Type' => 'application/x-pkcs7-mime');
    $msgEncr->attr('Content-Type.smime-type' => 'enveloped-data');
    $msgEncr->attr('Content-Type.name' => 'smime.p7m');
    
    $msgEncr->send;             
    
    MIME::Lite->quiet(0);
    
  2. Setting the Content-Transfer-Encoding via $myMessage->attr which breaks the encrypted Data, but won’t cause a warning:

    my $msgEncr = MIME::Lite->new(From  => 'me@myhost.com',
                           To         => 'you@yourhost.com',
                           Subject    => 'SMIME Test',
                           Data => $myEncryptedMessage);
    
    $msgEncr->attr('Content-Disposition'        =>  'attachment');
    $msgEncr->attr('Content-Disposition.filename'       =>  'smime.p7m');
    $msgEncr->attr('Content-Type' => 'application/x-pkcs7-mime');
    $msgEncr->attr('Content-Type.smime-type' => 'enveloped-data');
    $msgEncr->attr('Content-Type.name' => 'smime.p7m');
    $msgEncr->attr('Content-Transfer-Encoding' => 'base64');
    
    $msgEncr->send; 
    

I just don’t get why my message is broken when I’m using the attribute-setter. Thanks in advance for your help!

Besides that i’m unable to attach any file to this E-Mail without breaking the encrypted message again.

  • 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-31T22:30:54+00:00Added an answer on May 31, 2026 at 10:30 pm

    As I said in one comment the difference in setting the encoding in the construtor of the mimeobject or with the ->attr-Setter is, that the construtor just sets the encoding in the mimeheader. By using the ->attr-Setter mime encodes the data with base64.

    So in my case, my previously generated mimeobject – which is base64-encoded and with s/mime encrypted – read from a file needs to set the encoding in the construtor (and suppress the warning) so no more encoding will be done by mime. Otherwise mime will encode the data again and therefore break the encryption and the email itself.

    I finally got attachments to work. To achieve this I create a normal multipart/mixed mimeobject, print this object into a normal file, encrypt this file with openssl smime, read this whole file (except the 6 headerlines) into a variable and use this as the datainput. Additionally I set the Content-Transfer-Encoding to base64 using the construtor (so no encoding is done to my data).

    I hope this will help someone else then me 😉

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

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters

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.