emersion / hydroxide

A third-party, open-source ProtonMail CardDAV, IMAP and SMTP bridge
MIT License
1.64k stars 126 forks source link

Post request failed upon saving drafts with Thunderbird #174

Open Spoons opened 3 years ago

Spoons commented 3 years ago

Hey, this is a great project and I appreciate the work that has been put into it.

When Thunderbird attempts to save a message into the drafts folder, I observe the following output:

2021/05/02 21:28:24 CardDAV server listening on 127.0.0.1:3657
2021/05/02 21:28:24 IMAP server listening on 127.0.0.1:1143
2021/05/02 21:28:24 SMTP server listening on 127.0.0.1:1025
2021/05/02 21:28:37 User "username" logged in via IMAP
2021/05/02 21:28:37 Synchronizing mailbox Drafts...
2021/05/02 21:28:38 Synchronizing mailbox Drafts: done.
2021/05/02 21:28:38 request failed: POST https://mail.protonmail.com/api/messages: [2000] The Sender is required

I may be misunderstanding the intention of the output but the From and To fields are selected/filled respectively.

emersion commented 3 years ago

Yup, this is a hydroxide bug.

streaps commented 3 years ago

Is there an easy way to fix it?

faithanalog commented 3 years ago

having the same issue in Claws

as2875 commented 2 years ago

The problem seems to be that the message that is submitted in the POST request to the /messages endpoint has "Sender" set to null.

The problem appears to be in smtp/smtp.go in the function SendMail. Lines 65 onwards are where the MIME headers are parsed to generate the Sender field. The message is defined on line 120. I don't know enough Go to submit a patch but perhaps this will be useful for a fellow user.

Albator11 commented 1 year ago

I think I found the problem. It's not actually in smtp/smtp.go but in imap/message.go on line 426.

The message is getting created without defining a sender:

msg := &protonmail.Message{
    ToList:    protonmailAddressList(toList),
    CCList:    protonmailAddressList(ccList),
    BCCList:   protonmailAddressList(bccList),
    Subject:   subject,
    Header:    formatHeader(mr.Header),
    AddressID: fromAddr.ID,
}

so I think it supposed to be something like this: (fromAddrStr was defined earlier in the function, it's the same as fromList[0].Address)

msg := &protonmail.Message{
    ToList:    protonmailAddressList(toList),
    CCList:    protonmailAddressList(ccList),
    BCCList:   protonmailAddressList(bccList),
    Subject:   subject,
    Header:    formatHeader(mr.Header),
    AddressID: fromAddr.ID,
    Sender: &protonmail.MessageAddress{
        Address: fromAddrStr,
        Name:    fromList[0].Name,
    },
}

This seemed to work for me... it successfully creates a draft of the message you're writing... except it doesn't seem to update the draft once it's created, rather it creates a new draft every time. I have no idea how to fix that. (I probably could figure it out if I spend more time on it)

Hopefully this is helpful to someone now that 2 years have passed since the last post on this thread...

Tommimon commented 9 months ago

The issue is still relevant in version 0.2.27

Albator11 commented 9 months ago

The issue is still relevant in version 0.2.27

Yeah... sadly it seems this project hasn't been getting much attention... I'd be tempted to help out more and create some pull requests &c. but it seems that it's almost a dead project? I sure hope not though...

emersion commented 9 months ago

It's in maintenance mode. I only use the SMTP part of this project, and I try to review PRs that come in, but it's not on the top of my priority list.