Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APPEND command error: BAD ['invalid rfc5322 message: Sender should not be present if equal to From'] #159

Closed
majorminors opened this issue Aug 28, 2023 · 3 comments

Comments

@majorminors
Copy link

General informations

  • system/distribution (with version): Ubuntu 22.04 LTS
  • offlineimap version (offlineimap -V): offlineimap v8.0.0, imaplib2 v3.06, Python v3.8.10, OpenSSL 1.1.1f 31 Mar 2020
  • Python version: Python v3.8.10 (from offlineimap -V output)
  • server name or domain: Proton Mail
  • CLI options: nil

Configuration file offlineimaprc

[general]
accounts = proton
pythonfile = /path/to/a/password/function.py

[Account proton]
localrepository = proton-local
remoterepository = proton-remote

autorefresh = 0.2

quick = 10

postsynchook = notmuch new

[Repository proton-local]
type = Maildir
localfolders = /path/to/maildir

sync_deletes = yes

[Repository proton-remote]
type = IMAP
remoteport = 1143
remotehost = 127.0.0.1
remoteuser = [email protected]
remotepasseval = get_pass()

keepalive = 60
holdconnectionopen = yes

expunge = yes

folderfilter = lambda foldername: foldername not in ['Labels.', 'Labels']

ssl = no

pythonfile (if any)

import sys

pwd = 'proton bridge password'

if len(sys.argv) == 1:
def get_pass():
return pwd
elif sys.argv[1] == 'mutt':
print('set imap_pass=' + pwd)
else:
print('error')

Logs, error

...
Folder Trash [acc: proton]:
Copy message UID -1 (1/1) proton-local:Trash -> proton-remote:Trash
ERROR: Saving msg ([email protected]) folder 'Trash', repo 'proton-remote'failed (error). Server responded: APPEND command error: BAD [b'invalid rfc5322 message: Sender should not be present if equal to From']. Data: b'KJLL287 APPEND Trash () "27-Aug-2023 12:33:47 +0100" {79306}\r\n'
...

Steps to reproduce the error

Run offlineimap (with no CLI options) after using mutt to move an email from INBOX to any other folder. In this case, to Trash.

From and Sender are indeed equal, more or less. In this case:
From: "PALM REPORT by Poolsuite" [email protected]
Sender: PALM REPORT by Poolsuite [email protected]

If I manually delete the sender line from the email, then offlineimap returns to work normally.

I am assuming this is some issue with protonmail thinking that offlineimap is trying to give it a badly formatted email so perhaps the fault is with badly formatted emails. Just wondering if there's something I can do to stop this from happening without manually locating and deleting the sender line in these cases.

@thekix
Copy link
Member

thekix commented Nov 22, 2023

Hi @majorminors

Thanks a lot for the report. I tried to send me an email to protonmail using mutt, setting the sender the from with the same string and protonmail removes the "Sender" line. I tryid to add the sender with double quotes, and the same.

How can I reproduce the error? Should we implement a method to remove the sender line if is equal to the From line (with or without double quotes)?

Best regards,
kix

@majorminors
Copy link
Author

Interesting! I hadn't been back to check this issue in a while, and I'm realising it's because I haven't encountered the problem in a while (previously at was at least once every couple days). Either someone (proton?) Have fixed the issue on their end, or I'm unconsciously screening the mails I know are a problem. Let me wait until a known problem sender hits my inbox and ill see if it still happens.

As for the solution you mention---automatically removing the sender---seems sensible to me given the RFC formatting recommendation in the error. But also I'd just be trusting proton that this is correct email formatting.

@majorminors
Copy link
Author

So, I just deleted an email from the same source as the one that I used to illustrate this issue (Palm report), and offlineimap managed it with no issues.

Interestingly, unlike your attempt, protonmail doesn't appear to have stripped the 'Sender' field---they're still the same:

From: PALM REPORT by Poolsuite [email protected]
Sender: PALM REPORT by Poolsuite [email protected]

Although I note the double quotes are gone from the 'From' field. Not sure if that's important.

Anyway, I guess I'll close the issue, since it's solved for me somehow. If you want to re-open it for testing, feel free, and I'll be happy respond as I can to help out.

I'll also mention that it was resolved on my issue on the old offlineimap repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants