Moving sent mail to sent folder...

I dunno how to explain this correctly, but I’ll try: I have a few people that send messages with large attachments regularly, and each time a message gets sent, it needs to be kind of resent to get it into the sent items folder.
Isn’t there a way to do this server-side or something? So when a message gets sent through Postfix, it will be automatically copied in the sent mail folder of the sender?
Or any other way of solving that double-upload problem?

What email client is being used, is it the same one for each of the folks having problems?

In theory, the “Sent” folder is just any other folder, and it’s up to the email client to place a copy of an email within it. If that’s not happening, it might be a problem with the client.
-Eric

mmm i knew i would fail to explain it well :frowning:

it’s not that the folks are having problems, it’s that when you send a, say, 5 MB big message, it firstly gets sent via SMTP, then it needs to be sent over the internet again to be put in the sent mail folder. so the client uploads 10 MB of data for a 5 MB message, which as slower as a connection is, the more painful it gets.

afaik gmail users for example have the option that every mail sent through their smtp automatically gets into their sent mail folder, without the client needing to upload it there.

so my question is if something similar could be set up for postfix/dovecot/virtualmin…

so my question is if something similar could be set up for postfix/dovecot/virtualmin...

Unfortunately not.

The problem is that Postfix knows nothing about mailboxes, and Dovecot knows nothing about mail being sent. They are completely separate protocols running on different ports. There’s not interaction at all between Dovecot and Postfix, and so there’s no way for one to communicate to the other that there’s a message for them.

Actually, though, now that I think of it…Postfix is pretty powerful, and procmail is already in the equation. So, maybe it is possible using some sort of "smart alias". Hmmm…Gonna have to do a little digging on this one.

BTW-If you send via Usermin, the upload only has to happen once. So maybe for really big attachments, in the meantime, you might suggest your users send via the webmail client.

Yeah, Webmail of course is fine.
I digged a bit and slept over it, and I think I got an idea.

There is this “Automatic BCC” feature in Postfix. It is implemented in Virtualmin as well, but only domain-wide.
Nevertheless, I could edit the bcc file in Postfix manually to add something like “mymail@mydomain.tld mymail@mydomain.tld”, then place a procmail filter to automatically place messages in the Sent folder which come from mymail@mydomain.tld, and mark them as read.
I’m curious to see if this will work, I’ll let you know :stuck_out_tongue:

But if you come up with a better solution, let me know :slight_smile:

oops, a little mistake in the procmail code… the path in the mv should look like this: … "Maildir/.$folder/cur/" … <- add a dot after Maildir/

Ok, I got this working. The workaround is probably a bit dirty, but it works.

In my scenario, I got a domain, several aliases but only one mailbox, so I could activate the Bcc option for the domain in Virtualmin.
However, I manually had to run postmap /etc/postfix/bcc and reload postfix for the changes to take effect. I guess this is a Virtualmin bug. Anyway.

The /etc/postfix/bcc file looks like this

[code:1]
@mydomain.tld mailbox@mydomain.tld
[/code:1]

which bcc’s mail sent from all domain’s addresses to that mailbox. this is generated by virtualmin. however, i suppose you can manually edit the bcc file to bind bcc rules to separate addresses, like this:

[code:1]
mailbox@mydomain.tld mailbox@mydomain.tld
[/code:1]

I manually edited the .procmailrc file of my mailbox to look like this:

[code:1]
:0

  • ^(From).*mydomain.tld
    {
    folder=Sent

    :0 c
    Maildir/.$folder/

    :0 hi

    • LASTFOLDER ?? //[^/]+$
      | mv $LASTFOLDER Maildir/$folder/cur/$MATCH:2,S
      }
      [/code:1]

So now I can disable the "save message in sent folder" in both client and webmail, as the server will do so automatically (otherwise you would get duplicates).

Let me know what you think!
hal

Ok, I got this working. The workaround is probably a bit dirty, but it works.

In my scenario, I got a domain, several aliases but only one mailbox, so I could activate the Bcc option for the domain in Virtualmin.
However, I manually had to run postmap /etc/postfix/bcc and reload postfix for the changes to take effect. I guess this is a Virtualmin bug. Anyway.

The /etc/postfix/bcc file looks like this

[code:1]
@mydomain.tld mailbox@mydomain.tld
[/code:1]

which bcc’s mail sent from all domain’s addresses to that mailbox. this is generated by virtualmin. however, i suppose you can manually edit the bcc file to bind bcc rules to separate addresses, like this:

[code:1]
mailbox@mydomain.tld mailbox@mydomain.tld
[/code:1]

I manually edited the .procmailrc file of my mailbox to look like this:

[code:1]
:0

  • ^(From).*mydomain.tld
    {
    folder=Sent

    :0 c
    Maildir/.$folder/

    :0 hi

    • LASTFOLDER ?? //[^/]+$
      | mv $LASTFOLDER Maildir/$folder/cur/$MATCH:2,S
      }
      [/code:1]

So now I can disable the "save message in sent folder" in both client and webmail, as the server will do so automatically (otherwise you would get duplicates).

Let me know what you think!
hal

Just to preface, I like the powerful usermin mail client however, some of my customers like Outlook or Thunderbird to easily manage multiple addresses.

Yeah, same here. I’ve wondered how Google intercepts mail that goes through the SMTP server and drops it in your sent items. If you have multiple Gmail addresses in Thunderbird for instance, you’ll have multiple matching Google SMTP servers with usernames and passwords that match the Gmail addresses. This way Google knows which account sent mail folder to drop sent messages into. In fact, you have to manually disable Thunderbirds storage of sent items for IMAP because the default is to store the sent items in the Google IMAP sent folder and since Google captures and stores the sent mail, there is no need to send, and then copy the sent message into the Google IMAP sent folder.

I was hoping by now that Postfix/Dovecot could do a similar “capture” deal without complex scripts etc.

eg. you have 2 email addresses using Thunderbird.

  1. mail.example.com -- is the mail server
  2. emailone@example.com -- Username is emailone.example
  3. emailtwo@example.com -- Username is emailtwo.example

So in Thunderbird you have to create 2 SMTP server entries for the above email address with matching usernames and passwords.

This should be enough info for postfix to know which sent folder to drop mail that passes through it?

Or is my simple mind thinking it should be simple when it’s gonna take some magic to get it done?

I keep thinking among all the shiny knobs in webmin’s postfix config screen I’ll find that magic knob if I stare at it long enough.