opulentfox-29 / protonmail-api-client

This is not an official python ProtonMail API client. it allows you to read, send and delete messages in protonmail, as well as render a ready-made template with embedded images.
GNU General Public License v3.0
20 stars 7 forks source link

Sent message is still encrypted #10

Closed stefanodvx closed 6 months ago

stefanodvx commented 6 months ago

When sending a message, it displays correctly on my ProtonMail app, but it's all encrypted on the recipient client. I'm 100% sure I'm using the right session and private key.

This is my code:

    client = ProtonMail(logging_level=0)
    client.session.proxies = {
        "http": proxy,
        "https": proxy
    }
    client.load_session(f"sessions/{session_id}")
    client.pgp_import(
        private_key=io.StringIO(private_key),
        passphrase=password
    )
    object = object.replace("\n", "<br>")
    object = f"<html><body>{object}</body></html>"
    message = client.create_message(
        recipients=recipients,
        subject=subject,
        body=object
    )
    return client.send_message(message)

And this is how it displays on recipient client (Gmail, in this case): IMG_0065

stefanodvx commented 6 months ago

Also, the preview message is always "hello" (cause of the payload used?). Another fact: this issue does not cover ANY message. Just a few. If you want to reproduce, please give me a private contact and I'll provide the body used. I believe there's an issue with the MIMEText formatting for certain bodies.

stefanodvx commented 6 months ago

Update: if body exceeds 729 characters, it will cause this issue.

opulentfox-29 commented 6 months ago

I believe there's an issue with the MIMEText formatting for certain bodies.

You are right, the problem was that Base64 needs to be split into lines every 76 characters

the preview message is always "hello"

The message preview is always “hello”, because I didn’t know which one to put, there are 3 options:

  1. allow the user to write a preview for the message himself
  2. parsing text from HTML code
  3. do not write preview for the message at all

Now I think that the “hello” preview is a bad idea, so I turned off the preview completely. Your ideas/suggestions?