[SOLVED] How to save postfix email in db?

Issues related to applications and software problems and general support
Post Reply
formiche
Posts: 7
Joined: 2020/09/24 14:51:12

[SOLVED] How to save postfix email in db?

Post by formiche » 2020/10/02 11:31:05

Hi to all!
I'm new in this forum. I started short time ago to use centos, I normally use ubuntu. I installed and configurated a mail server with postfix, postfixadmin, dovecot and roundcube on centos 8, it's work but now I've the problem in object, that is, I want to save both incoming and outgoing emails into database instead in file, or both. I'm looking on the network but I didn't find anything. Can someone help me, please?
Thank you very much!

Michela
Last edited by formiche on 2020/10/06 14:23:38, edited 1 time in total.

User avatar
KernelOops
Posts: 395
Joined: 2013/12/18 15:04:03
Location: xfs file system

Re: How to save postfix email in db?

Post by KernelOops » 2020/10/02 12:55:55

postfix does not store emails, at least not permanently. They are stored temporarily until they are sent to another server or to a destination like dovecot. Maybe you want dovecot to store emails in a database? that would make more sense.
--
I love my computer - all my friends live there.
--

iwishitwouldwork
Posts: 77
Joined: 2014/02/08 14:56:39

Re: How to save postfix email in db?

Post by iwishitwouldwork » 2020/10/03 04:05:10

Heh. You can, but it won't be trivial.

You can write your own mail filter and as part of that filter ship the emails
off to some process to shove them into a database. I've done something
akin to that, but not that exactly. I did not care about attachments to
the emails and how to get access to the attachments was not obvious
to me when I was doing my project. So you're on your own there.

AFAIK, your project is certainly not a matter of configuration.

formiche
Posts: 7
Joined: 2020/09/24 14:51:12

Re: How to save postfix email in db?

Post by formiche » 2020/10/05 08:34:52

Thank you very much for your replies, they are very userful for me! So, when have I exactly to catch emails, for example, in outgoing? What is the order of sending? From roundcube to dovecot and so to postfix? Or roundcube to postfix and so to dovecot?

User avatar
KernelOops
Posts: 395
Joined: 2013/12/18 15:04:03
Location: xfs file system

Re: How to save postfix email in db?

Post by KernelOops » 2020/10/05 09:20:39

roundcube acts as a normal SMTP/IMAP client, it READS emails with dovecot via imap and SENDS emails with postfix via SMTP.

postfix can create copies of all emails to a specific internal email address back in dovecot, so you can have a complete archive of all sent/received emails.
--
I love my computer - all my friends live there.
--

formiche
Posts: 7
Joined: 2020/09/24 14:51:12

Re: How to save postfix email in db?

Post by formiche » 2020/10/05 17:03:58

Ok, and how can I create a copy of all emails to a specific internal email address? Have I set a configuration in main.cf?

formiche
Posts: 7
Joined: 2020/09/24 14:51:12

Re: How to save postfix email in db?

Post by formiche » 2020/10/05 17:36:52

Found it: https://stackoverflow.com/questions/755 ... il-address.
With this configuration all emails, both incoming and outgoing, are saved in "new" directory of the forwarding account then I will try to create a cron that, for example, each minute reads files into directory and writes in db the new entries.
Thank you all!

Michela

User avatar
KernelOops
Posts: 395
Joined: 2013/12/18 15:04:03
Location: xfs file system

Re: How to save postfix email in db?

Post by KernelOops » 2020/10/06 06:04:35

That is correct, the setting always_bcc= allows you to store all emails (incoming and outgoing) to a particular internal email address and store them into a database or other place. You could even create your own imap client or as you mention a simple cron job.
--
I love my computer - all my friends live there.
--

Post Reply

Return to “CentOS 8 - General Support”