Question

i know this might be a dummy question or a question that comes from lake of knowledge, but i hope someone can still answer it. i did try to read a lot of postfix documentation but found no answer to this. i don't even know if it's a postfix specific or mail servers general question.

so i have a mail server, just a clean postfix install that delivers email. iv'e defined my users and connected with IMAP and SMTP using thunderbird.

when i went to thunderbird account settings and disabled "place a copy", postfix did not put a copy of the sent message in the user .Sent folder.

however, iv'e also connected my gmail,hotmail or yahoo mail and diabled the "place a copy" and still have a copy in the sent items folder.

so in this case there are 2 options:

  1. something is wrong with my postfix configuration
  2. gmail,hotmail,yahoo put a copy in thier sent folder as a different process on the server side

thanks in advance

Was it helpful?

Solution 2

Postfix itself does not place copies of sent messages anywhere; it receives messages and delivers them to the recipient. Saving sent messages to your own mailbox is the responsibility of your user agent (Thunderbird, in your case).

It's important to understand that Postfix (and other traditional Unix SMTP servers) don't have a "user" concept. Yes, if so configured it's possible to authenticate by supplying a username and a password, but Postfix doesn't use this identity information.

That said, it's not impossible to configure Postfix to do what you expected – sender_bcc_maps can be used to add a recipient to messages sent by you, and by adding yourself and using a filter in your mail client (or mail delivery agent like procmail) you can make sure that messages sent by you end up in the Sent folder.

OTHER TIPS

Just for the record, having searched around for a how to, and not finding one, I am posting it here:

The only (easy) way I've found to save sent emails is the sender_bcc solution (with it's attendant faults):

I am using postfix / dovecot / sieve / mysql virtual boxes

In /etc/postfix/main.cf add:

sender_bcc_maps = mysql:/etc/postfix/mysql-virtual-bcc-maps.cf

Create file /etc/postfix/mysql-virtual-bcc-maps.cf:

user = (database user)
password = (database password)
hosts = 127.0.0.1
dbname = (database databasename)
query = SELECT CONCAT_WS('',LEFT('%s', LOCATE('@', '%s')-1),'+sent@',SUBSTRING('%s', LOCATE('@', '%s')+1)) AS destination FROM virtual_users WHERE email='%s' AND autosent=1

You'll note in my query, I've added a (tinyint default 0) column to my virtual_users table so I can turn on/off this automatic sent items feature per user. This query takes the sender email address that postfix gives it, splits it in half at the @ sign, and adds +sent to the address so it looks like sender+sent@domain.tld. This allows sieve in the next step to pick it up and drop it straight to sent items.

In /etc/dovecot/sieve/default.sieve add:

require ["fileinto", "mailbox", "envelope", "subaddress","imap4flags"];
if envelope :detail "to" "sent" {
    addflag "\\Seen";
    fileinto :create "Sent";
    stop;
}

Also helpful to modify /etc/dovecot/conf.d/15-mailboxes.conf and add the auto subscribe to sent (and junk and trash and others for that matter):

  mailbox Sent {
    special_use = \Sent
    auto = subscribe
  }

I think that is all (I'm posting this the next day after doing it, so I think I got it all...)

I am running a Installation with automatic copies created by sender_bcc_maps. It's working fine. You have to check the sender, otherwise everyone can create sent mails in foreign sent folders.

I have solved it with two virtual domains. One for the user and one for the copy.

But there is a big problem with sender_bcc_maps. All bcc senders will be deleted in the sent copy. You cannot see anymore, who got a blind copy of this mail.

As 'ego2dot0' said above, you don't need any MDA filters (sieve etc.) to do this. It can be done using Postfix alone, although it took me a while to figure out how to do it.

You have to use sender_bcc_maps AND virtual_mailbox_maps features together.

You have to use a virtual domain dedicated specially for copies to self. If your actual domain is "your.domain.tld", you can use eg. subdomain "copyself.your.domain.tld". This subdomain does not have to actually exist, ie. be defined in the DNS (moreover, it's better that it isn't defined, so nobody accidentally sends mail to it from outside). It is a purely virtual domain that is recognized only by Postfix.

1) Configure sender_bcc_maps to BCC mail coming from user@your.domain.tld to user@copyself.your.domain.tld. You can do it for only a few selected users using a regular "hash" type map, or you can do it for all users at once using PCRE type map and regular expressions.

2) You have to define your virtual domain in virtual_mailbox_domains, like this:

virtual_mailbox_domains=copyself.your.domain.tld

3) Configure virtual_mailbox_maps so that the destination mailbox for address "user@copyself.your.domain.tld" is the actual "Sent" mailbox of the user "user". For example (assumed that you are using regular system users and Maildir format - like in my case) the path to "Sent" mailbox for user "user" will be "/home/user/Maildir/.Sent". So, you can define common part of the path as virtual_mailbox_base, eg.

virtual_mailbox_base=/home

and then in the virtual mailbox map enter the rest of the path like this:

user@copyself.your.domain.tld    user/Maildir/.Sent/

(the trailing / is important to indicate the Maildir format). Again, you can use PCRE type map to do this for all users.

4) To properly save mail to the mailbox, Postfix need to also know the proper UID and GID for the particular user, so you have to use virtual_uid_maps and virtual_gid_maps parameters as well. If you are using virtual users, it's probably enough to define "static" type maps specifying a single UID and GID of the system user that owns all the virtual mailboxes. However, if you are using system users like me, you need the proper actual UID and GID for any user. If you have only a few users, you can use a regular "hash" type map, with entries like these:

user@copyself.your.domain.tld    2001

or you can try to setup a pipeline with "pipemap" map type, that uses some PCRE maps and "unix:passwd.byname" map to obtain the UIDs and GIDs for all users (I haven't done this part, as my Postfix installation is compiled without "pipemap" type support).

So to sum everything up, use something like this:

In /etc/postfix/main.cf file, add the following lines:

sender_bcc_maps=hash:/etc/postfix/sender_bcc
virtual_mailbox_domains=copyself.your.domain.tld
virtual_mailbox_base=/home
virtual_mailbox_maps=hash:/etc/postfix/copyself
virtual_uid_maps=hash:/etc/postfix/copyself_uids
virtual_gid_maps=hash:/etc/postfix/copyself_gids

/etc/postfix/sender_bcc contains a bunch of lines like:

user@your.domain.tld    user@copyself.your.domain.tld

/etc/postfix/copyself contains - respectively - lines like:

user@copyself.your.domain.tld    user/Maildir/.Sent/

/etc/postfix/copyself_uids and /etc/postfix/copyself_gids contain - respectively - lines like:

user@copyself.your.domain.tld    2001

I have done this on my server and it works great for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top