SMTP server should copy sent e-mails to IMAP sent folders

Use this forum if you want to suggest a new feature to hMailServer. Before posting, please search the forum to confirm that it has not already been suggested.
Post Reply
golantrevize
New user
New user
Posts: 4
Joined: 2013-12-27 10:46

SMTP server should copy sent e-mails to IMAP sent folders

Post by golantrevize » 2013-12-27 10:57

Hi everyone, it would be very handy if SMTP server could copy sent e-mails to IMAP sent folder.

This should happen when:
- SMTP authentication is enabled
- An IMAP user with the same name exists
- A flag "Copy to IMAP sent folder" is enabled

This feature allows to save upload bandwidth on clients. No need to send e-mail twice (one for SMTP, one for copying to IMAP sent folder) but just once (for SMTP).
Sent folder is updated later, but this is a download and usually on client side this is easier (think of ADSL lines, much more bandwidth for download than upload).

With this feature, I could disable "copy to send folder" for IMAP client and save a lot of bandwidth.

User avatar
mattg
Moderator
Moderator
Posts: 20447
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: SMTP server should copy sent e-mails to IMAP sent folder

Post by mattg » 2013-12-27 14:40

golantrevize wrote:- A flag "Copy to IMAP sent folder" is enabled
What flag is this?
Where is it defined, and by whom?
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: SMTP server should copy sent e-mails to IMAP sent folder

Post by percepts » 2013-12-27 15:25

If I'm not mistaken doing this is the responsibility of the IMAP client. You just need to read the IMAP client documentation to find out how to do it. iPhones work like that I believe and I guess other IMAP clients do to.

However, if you do send via an SMTP client which is not configured for IMAP then you can write a global rule to do it.
See online docs and do a search on "global rule".

In short the ability to do what you request already exists without need of changes to hMail core.

golantrevize
New user
New user
Posts: 4
Joined: 2013-12-27 10:46

Re: SMTP server should copy sent e-mails to IMAP sent folder

Post by golantrevize » 2013-12-27 20:33

mattg wrote:
golantrevize wrote:- A flag "Copy to IMAP sent folder" is enabled
What flag is this?
Where is it defined, and by whom?
This flag should be in SMTP configuration. It's a part of the feature request.

golantrevize
New user
New user
Posts: 4
Joined: 2013-12-27 10:46

Re: SMTP server should copy sent e-mails to IMAP sent folder

Post by golantrevize » 2013-12-27 20:42

percepts wrote:If I'm not mistaken doing this is the responsibility of the IMAP client. You just need to read the IMAP client documentation to find out how to do it. iPhones work like that I believe and I guess other IMAP clients do to.
This is not part of the IMAP protocol. IMAP protocol just handles incoming mail.
Probably you're using a Gmail account on your iPhone: GMail SMTP server is smart enough to do exactly the trick I want to do. You send your e-mail with Google SMTP, then on server side, your email is copied to IMAP Sent folder. On your iPhone, mail client is configured NOT to copy a sent message to IMAP Sent folder. This is done automatically when configuring a GMail account. When you update your sent folder on iPhone, you get all sent messages. GMail server copied them for you.

This is the key point.

Standard e-mail send with SMTP + IMAP: you send e-mails data twice.
- send via SMTP
- copy to IMAP sent folder
(IMAP client is configured to copy sent emails to IMAP sent folder)

GMail e-mail send with SMTP + IMAP: you send e-mails data once.
- send via SMTP
- server copies from SMTP to IMAP sent folder
(IMAP client is configured to NOT copy sent emails to IMAP sent folder)

I hope it's clear.
However, if you do send via an SMTP client which is not configured for IMAP then you can write a global rule to do it.
See online docs and do a search on "global rule".
I searched documentation but I've not found a way to write a rule for SMTP to move mail to a specific IMAP folder of a specific user.
If you have some hints on this you're welcome.

regards

Bill48105
Developer
Developer
Posts: 6192
Joined: 2010-04-24 23:16
Location: Michigan, USA

Re: SMTP server should copy sent e-mails to IMAP sent folder

Post by Bill48105 » 2013-12-27 20:49

As was said this is for the IMAP client.
hmail rules can be used. The message must go to same user's folder or a public folder with right path. I use global & user rules to move messages scored a certain amount by ASSP & SA to a folder named Spam for each user so it definitely works. In your case you might need to do script though to have enough control.
Bill
hMailServer build LIVE on my servers: 5.4-B2014050402
#hmailserver on FreeNode IRC https://webchat.freenode.net/?channels=#hmailserver
*** ABSENT FROM hMail! Those in IRC know how to find me if urgent. ***

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: SMTP server should copy sent e-mails to IMAP sent folder

Post by percepts » 2013-12-28 01:45

In hmailadmin/rules

then hit the help button on that panel which gives you examples.

Your criteria would be something like From contains user@domain.com or domain.com

and your action would be

Move to Imap folder

but as Bill says you may want to run a function (script) from your action for greater control. There are lots of script examples in forum if you take the trouble to search. But if you can't even do a search on "global rule" as I suggested then you are probably out of your depth.

And be warned: Imap clients use SMTP to send email os in your rules you have no idea whether mail is being sent from IMAP client or pure SMTP client. And that means if IMAP client is configured to put copy in sent folder and you do the same in rules then you may end up with duplicate mails in sent folder. You'll have to resolve that potential problem yourself.

golantrevize
New user
New user
Posts: 4
Joined: 2013-12-27 10:46

Re: SMTP server should copy sent e-mails to IMAP sent folder

Post by golantrevize » 2013-12-28 02:07

Bill48105 wrote: The message must go to same user's folder or a public folder with right path. I use global & user rules to move messages scored a certain amount by ASSP & SA to a folder named Spam for each user so it definitely works. Bill
Thanks for hint. But if I understood, you're moving incoming messages to Spam folder. You're not moving outgoing SMTP messages.
How can I write a rule that works for SMTP?

User avatar
mattg
Moderator
Moderator
Posts: 20447
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: SMTP server should copy sent e-mails to IMAP sent folder

Post by mattg » 2013-12-28 03:57

Here's what I do to copy messages sent by my kids to a public IMAP folder that I can see. (this works based on SMTP connection)

I have an account sent@doamin.com
I have an account rule in this account that moves all mail to the #public.sent IMAP folder (This account has 'insert' permissions to this public folder)

I have a global rule

Use AND
if from contains kid@domain.com
recipient list not contain sent@domain.com
Then
forward to sent@domain.com

As reported above, to get better granular control, or for multiple accounts, you should write a script. I'd use 'on delivery start' or 'on deliver message'. Both of these only trigger for SMTP connections (irrespective of whether inbound or outbound - all SMTP mail is at one point in time inbound to the server) and by this time the oMessage will contain some detail of the sender and the recipients, and also the message content.
golantrevize wrote:
mattg wrote:
golantrevize wrote:- A flag "Copy to IMAP sent folder" is enabled
What flag is this?
Where is it defined, and by whom?
This flag should be in SMTP configuration. It's a part of the feature request.
It is extremely unlikely that anything will be implemented into hMailserver that has potential to break anything, OR that is not defined in RFCs.
Perhaps a header could be used rather than flags. Headers are created by the mail client, and can be fairly innocuous.

'Flags' typically only relate to IMAP connections.
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

joaoalbuquerque
New user
New user
Posts: 26
Joined: 2014-11-04 23:20

Re: SMTP server should copy sent e-mails to IMAP sent folders

Post by joaoalbuquerque » 2015-02-09 17:43

This would be a great feature on hMailServer!

govard
New user
New user
Posts: 2
Joined: 2015-02-28 14:14

Re: SMTP server should copy sent e-mails to IMAP sent folders

Post by govard » 2015-02-28 14:15

This would be a great feature on hMailServer!

cpservicespb
New user
New user
Posts: 1
Joined: 2019-03-01 15:07

Re: SMTP server should copy sent e-mails to IMAP sent folders

Post by cpservicespb » 2019-03-01 15:09

Please add such feature to the latest version.

estradis
Normal user
Normal user
Posts: 154
Joined: 2014-09-09 10:47

Re: SMTP server should copy sent e-mails to IMAP sent folders

Post by estradis » 2019-04-24 14:39

Hey guys,

This would be a very bad idea due to a lot of reaons:
  1. SMTP is a delivery protocoll. It has nothing to do with postboxes.
  2. Sorting mails in postboxes is always the muas job.
  3. Sorting mails is always an users choice.
  4. It might be conflicting with user defined configuration in the mua. (In best case the mail becomes undefined, in worst case it will be lost.)
It is like you write a real letter (mail) and give it to the postoffice (mailserver). After it was taken there, the mailman (SMTP) delivers it to another postoffice (mailserver) where it will be stored internally to your personal Inbox. You have to ask your postoffice for new mails and pull it out from there (MUA, using POP or IMAP). Then you have to say, that you want to mark it as read or to move it into another box (folder) or to delete it. It is always your turn (mua), because the postoffice (mailserver) won't ever do this without your permission!

Post Reply