Answer the question
In order to leave comments, you need to log in
How to parse mail server logs?
Hello.
There is a mail server.
It has logs for sending emails (I'm a cap).
The essence of the question: how to read these logs through a php script.
what would then from what the script reads build a simple table for clarity?
I know that there are bin scripts (which read them in the "terminal", but that's not it).
Answer the question
In order to leave comments, you need to log in
To successfully extract the necessary information from the log file, you just need to study it and write a regular expression to extract the necessary data. For example, this is how you can read the Exim mail server log file and select the email sender and recipient:
$logs = file('log');
foreach($logs as $num => $line)
{
/**
* Регулярное выражение нужно делать по своему примеру
*/
preg_match('/F=<(.*?)>.*?RCPT\s<(.*?)>/', $line, $recipient);
if (isset($recipient[1]) && isset($recipient[2]))
{
echo "Sender: " . $recipient[1] . " Recipient: " . $recipient[2] . "\n";
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question