Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi, how to send encrypted html mail from terminal? The problem I am trying to solve is that I want to send encrypted html message that client upon receiving should show rendered html instead showing html source code as a message.
So far I tried this: import public key of the person I want to send encrypted mail to; then write html message (without <html> tags) in one file; then do gpg --recipient user@example.com--armor --encrypt message where mail should match with the one in public key that I imported previously.
Then I send it with mailx -a 'Content-Type:text/html' -s"title" user@example.com< message.asc
and what I get after decrypt is a message that has html source code instead html message.
I think what you are doing sounds about right, the problem is likely with the client at the destination. It sounds like you are encrypting an HTML file and sending it and they receive it and decrypt it. After decryption, there doesn't seem to be any mail-exchange protocol in place to apply some sort of mime type to render the source code.
Thanks for your answers.
@NyteOwl: they can receive html mail and see it. For example, sending same email unencrypted shows fine. Also sending same html mail via Thunderbird and Enigmail also shows html mail in client (all are using Thunderbird with exactly same setup).
I assume I might be missing some headers but even tried to replicate exact header order by enigmail html mail, I couldn't see the letter. The only thing I see is a blank page yet in source of the mail I see encrypted content.
The only possible way I managed to get closer to the solution is to send it somehow as an attachement by using headers. Then if I right click and choose "Decrypt and open" in Thunderbird, it shows HTML for example in Firefox...
So far I tried a lot of variations and playing with headers using mailx, PHP code with mail function, Drupal Openpgp module and what not. But no luck.
You may want to test a regular (graphic) client which supports GPG and HTML, get message it sends and decrypt it by hand before the receiver to see what does it really look like.
And the content itself should be specification compliant. I think your method does not set the above.
Copi&paste from the web:
Code:
--
As the PGP/MIME RFC 3156 states under section 4, OpenPGP encrypted data
Before OpenPGP encryption, the data is written in MIME canonical format (body and headers).
Following is an example of an RFC822 compliant mail message, which should be processed and displayed as expected.
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=us-ascii
This is only encrypted!
--
In other words: The HTML message you pass should surely need headers to properly identify itself. You may try with a text/html type.
Last edited by BlackRider; 01-18-2013 at 09:30 AM.
I think BlackRider has a point. The encrypted message should declare its mime type as encrypted. Based on the original post, it sounds like the mail client knows the message is encrypted. The issue is that when it arrives it is properly decrypted, but the message that is decrypted has no mime type declaration. How about a DOCTYPE declaration in the HTML? Or perhaps a content-type tag in the HTML?
So you would encrypt the HTML code disposed in this canonical way, and then put the result in a file which conforms to the PGP/MIME specs (RFC 3156) which should be read by the OP.
It seems a task for a custom coded app :-(
Last edited by BlackRider; 01-18-2013 at 09:58 AM.
I know that webservers should supply headers, but I wasn't aware that a header declaration was necessary in an html email. I expect that'll be worth a try. I was thinking something like this:
Lets say mailmessage.html has html code in it (without head, body and html tags). So this gets the file, encrypts, prepare multipart message and sends. This works perfect. (you can test this out by adding --output before --to so it just outputs message with headers and body instead to send it).
So it set multipart / encrypted header, set boundary and added part of the message to be octet-stream.
Now I tried to replicate this and send correct message via PHP. With some changes I managed to do it:
So even with all those advancement, I am still standing on the beginning as I cannot effectively port header combination to PHP for example. So thanks for all the tips and points about headers, its super valuable for me.
If anyone has a bit more understanding in this issue, I d be glad to hear.. I know PHP implementation goes past thread's topic so you can send me PM.
I can't really tell exactly what is going on from your post -- i.e., what the initial code is from -- a shell script? If you are having trouble with the php mail command, you may find PEAR::Mail_Mime useful.
Also, what do you mean by "worked at first, now it doesn't" ?
Moved: This thread is more suitable in the Software forum (not a security issue) and has been moved accordingly to help your thread/question get the exposure it deserves.
Overall I solved the issue. It is related how to properly stack headers and which to encrypt,which to leave outside of encrypted part.
Long story short, this link helped me to get an order of headers. He technically followed exactly how Enigmail does it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.