[PR #508] [MERGED] load profiles when attaching a file, so smtp drafts are correctly saved #859

Closed
opened 2026-02-25 21:36:27 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/cypht-org/cypht/pull/508
Author: @kroky
Created: 8/30/2021
Status: Merged
Merged: 9/29/2021
Merged by: @jasonmunro

Base: masterHead: bugfix/smtp-imap-draft-file-attachment


📝 Commits (1)

  • c163446 load profiles when attaching a file, so smtp drafts are correctly saved into a linked imap profile drafts folder; additionally send local attachments saved to first draft as part of imap draft sending procedure - otherwise, attachments stay on the server and are never sent out

📊 Changes

3 files changed (+8 additions, -0 deletions)

View changed files

📝 modules/profiles/setup.php (+1 -0)
📝 modules/smtp/modules.php (+6 -0)
📝 modules/smtp/setup.php (+1 -0)

📄 Description

... into a linked imap profile drafts folder; additionally send local attachments saved to first draft as part of imap draft sending procedure - otherwise, attachments stay on the server and are never sent out

@henrique-borba I think saving imap drafts when smtp/imap profile is setup is your work, can you check out these fixes? The main problem I was hunting is missing files in the sent email after attaching them to a message. However, I found another bug as well. In short:

  1. Profiles were not loaded upon auto-saving an imap draft when attaching a file. This made the actual draft miss the attachments.
  2. Even with the above fix, attachments still were not sent out when compose form was submitted. This was because the attachments are saved locally with Cypht draft ids (0, 1, 2, etc.) while imap drafts have IDs equal to the message UID from the remote imap folder. So, when sending out the email, attachments were not related properly due to mismatch of IDs. I added a temporary fix here - whenever a draft with ID > 0 is sent we also add the default attachments saved to draft ID 0. This fixed the immediate issue we have but is not perfect as it might interfere with Cypht drafts when no profiles are used - in that case, if you save draft 0 (upload 1 file), save draft 1 with another file and send draft 1, file from draft 0 will be sent as well. I think a proper fix here implies properly parsing the saved imap draft (when this feature is used) and reattaching the files to the sent email. This means:
    a) delete local attachments when imap draft is saved as those are saved as part of the imap message
    b) show attachments to the imap draft in the compose form when editing an imap draft
    c) send those attachments even if they are not locally uploaded when submitting the compose form

If you have a different/easier to implement idea, I am also fine but I think this imap draft feature needs some updates in order to work fine with attachments.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cypht-org/cypht/pull/508 **Author:** [@kroky](https://github.com/kroky) **Created:** 8/30/2021 **Status:** ✅ Merged **Merged:** 9/29/2021 **Merged by:** [@jasonmunro](https://github.com/jasonmunro) **Base:** `master` ← **Head:** `bugfix/smtp-imap-draft-file-attachment` --- ### 📝 Commits (1) - [`c163446`](https://github.com/cypht-org/cypht/commit/c1634467bfe8a2492acc1fa2eb7062a523848200) load profiles when attaching a file, so smtp drafts are correctly saved into a linked imap profile drafts folder; additionally send local attachments saved to first draft as part of imap draft sending procedure - otherwise, attachments stay on the server and are never sent out ### 📊 Changes **3 files changed** (+8 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `modules/profiles/setup.php` (+1 -0) 📝 `modules/smtp/modules.php` (+6 -0) 📝 `modules/smtp/setup.php` (+1 -0) </details> ### 📄 Description ... into a linked imap profile drafts folder; additionally send local attachments saved to first draft as part of imap draft sending procedure - otherwise, attachments stay on the server and are never sent out @henrique-borba I think saving imap drafts when smtp/imap profile is setup is your work, can you check out these fixes? The main problem I was hunting is missing files in the sent email after attaching them to a message. However, I found another bug as well. In short: 1. Profiles were not loaded upon auto-saving an imap draft when attaching a file. This made the actual draft miss the attachments. 2. Even with the above fix, attachments still were not sent out when compose form was submitted. This was because the attachments are saved locally with Cypht draft ids (0, 1, 2, etc.) while imap drafts have IDs equal to the message UID from the remote imap folder. So, when sending out the email, attachments were not related properly due to mismatch of IDs. I added a temporary fix here - whenever a draft with ID > 0 is sent we also add the default attachments saved to draft ID 0. This fixed the immediate issue we have but is not perfect as it might interfere with Cypht drafts when no profiles are used - in that case, if you save draft 0 (upload 1 file), save draft 1 with another file and send draft 1, file from draft 0 will be sent as well. I think a proper fix here implies properly parsing the saved imap draft (when this feature is used) and reattaching the files to the sent email. This means: a) delete local attachments when imap draft is saved as those are saved as part of the imap message b) show attachments to the imap draft in the compose form when editing an imap draft c) send those attachments even if they are not locally uploaded when submitting the compose form If you have a different/easier to implement idea, I am also fine but I think this imap draft feature needs some updates in order to work fine with attachments. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-25 21:36:27 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cypht#859
No description provided.