Please give me a best solution to store all mails (send, receive, forward) in mysql with postfix? and Is this the correct approach?
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.
Most of the open source IMAP servers (Courier, Cyrus, Dovecot...) do support using MySQL as database to keep meta information like list of users and passwords, list of accepted domains, user aliases, etc. But none even attempt to make use of database like MySQL as actual storage backend.
Of course, if you really feel adventurous, you can try to implement SQL IMAP backend of your own. One of the most important considerations for you would be good support of unlimited length VARCHAR or BLOBs (for email attachments) by database engine. Unfortunately, MySQL is not very good server as far as BLOB support goes (you will have to tweak both client and server config for that). Also, you would probably want to have good transaction support - if you care for safety of your email data. For MySQL that means you must use InnoDB engine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With