Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

postfix and save to sent mail dir

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

like image 670
sd1sd1 Avatar asked Nov 14 '13 06:11

sd1sd1


People also ask

Where does postfix store sent mail?

Once you have access to the disk, Postfix stores email in /var/spool/postfix , in a binary format that you really want the postcat(1) tool to extract in human readable format.

Does SMTP save sent mail?

By definition of the SMTP RFC all this server does is relay mail. SMTP does not save copies to a sent folder.

Where is the send mail stored?

By default, a copy of each message that you send is saved in the Sent Items folder. When you reply to or forward an email message that is saved in any folder other than the Inbox, you can configure Outlook to save a copy of the sent message in the same folder as the original message.

Does postfix store email?

Postfix server by itself does not store email (not for a long time at least) - it can only temporarily queue until it is forwarded to intended recipient(s). Typically only IMAP (or outdated POP3) servers actually store your email.


3 Answers

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 [email protected]. 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...)

like image 105
Brandon Bates Avatar answered Oct 19 '22 09:10

Brandon Bates


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.

like image 43
Magnus Bäck Avatar answered Oct 19 '22 11:10

Magnus Bäck


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.

like image 3
ego2dot0 Avatar answered Oct 19 '22 10:10

ego2dot0