I have a no-spam smtp-server that I want to monitor outgoing emails and easly find out why a email on a certain date didn't go through. For this, I have three tables (attached) I want to fill up with data from a log-file you need to parse. You must fit the logged data into the columns I have set.
Most of all the data you need is logged in plain text in /var/log/maillog and you only need to follow the mail-indentifier that postfix creates, for the most part. You must hovewer code it in a good way so that it is fast on big files, using perfect regular expressions.
How it works:
- The idea is that you create one entry in table MAIL for every NEW mail appearing (avoid duplicates).
- If there are any delivery messages (usually is), create a new entry in table DEL (short for Delivery), with reference to the MAIL_ID from above.
- Update table MAIL if there is a message about Delivery Success or any last error_msg status.
You would need to Google and search in documentation in order to find the different status-codes (I have started something in attached table example).
You do NOT need to create the web-interface for this - But I have a set db-layout you MUST log the data into (see attached [login to view URL]). I will myself create the web-interface and the queries, so you must follow the layout so that I can easly query the database.
It is OK to fill up the status-column automatically based on recieved error msg (for instance, if you get a never seen error, just put it into status).
But keep the first ones / most common.
Sometimes, the log would not start with the mail-identifier and you must just rely on finding the last-status msg related to that IP of the mail-server.
Example log-entry (when everything works good):
Apr 9 19:42:52 m3 postfix/pickup[6276]: 7D8F32801A5: uid=0 from=<root>
Apr 9 19:42:52 m3 postfix/cleanup[6322]: 7D8F32801A5: info: header Subject: SSL works I hope 44 from local; from=<[login to view URL]> to=<[login to view URL]>
Apr 9 19:42:52 m3 postfix/cleanup[6322]: 7D8F32801A5: message-id=<[login to view URL]>
Apr 9 19:42:52 m3 postfix/qmgr[6277]: 7D8F32801A5: from=<[login to view URL]>, size=444, nrcpt=1 (queue active)
Apr 9 19:42:53 m3 postfix/smtp[6323]: 7D8F32801A5: to=<[login to view URL]>, relay=[login to view URL][[login to view URL]]:25, delay=0.53, delays=0.01/0.01/0.11/0.41, dsn=2.0.0, status=sent (250 2.0.0 OK 1460223757 l76si8970979wmb.44 - gsmtp)
Deliverables:
- PHP-script log parser.
- PHP script (or something to log the actual emails).
- Instructions on setting up Postfix from scratch on Centos x64 7 Minimal (yum install etc), with secure option (smtps).
Goal:
SQL: select * from MAIL, DEL where MAIL_ID=200 AND DEL_MAIL_ID=MAIL_ID
This should give me all info about the delivery related to thise one email only.
(I have a Posfix test-system that I have set up, but I want clear and tested instructions - you would anyhow need to do this yourself during developement - all dev should be on YOUR server and delivered ready tested).
hi.
i worked on postfix smtp software,
my last big project postfix,dovecot,mysql,centos. [login to view URL]
it has 100k users and more hundred centos 6.5 servers.
i write php code for smtp log parse
i use regex functions on php.
but i can syslog forward to mysql database.
i can make what do you want for about this.
some of my project link [login to view URL]
i can do your job.