GoAdmio

incoming

List today's messages received by the server's SMTP service, with time, sender, recipient, IP, and subject

On this page: Overview · Quick start · Syntax · Output · Examples · Troubleshooting · Details · See also


Overview

/go/incoming reads today's entries in the Postfix mail log, /var/log/maillog, and builds a table of the messages the server's SMTP service accepted. For each message it shows:

The table is printed on screen and saved to /var/log/go/mail/incoming/incoming-YYYY-MM-DD.log.

It is a summary built by searching the log, not an exact record of every message. Some messages are left out, and some fields can be wrong. See Known limitations.


Quick start

# List today's received messages
/go/incoming

Syntax

/go/incoming

The command takes no options. Any arguments are written to the log but otherwise ignored.


Output

Time      From              To                 IP           Subject
----      ----              --                 --           -------
12:01:07  news@example.org  info@mydomain.com  203.0.113.5  Weekly newsletter
12:03:42  jo@example.net    sales@mydomain.com 198.51.100.9 Quote request
Outcome What you get
Messages found One row per message, in the order they were first logged.
Nothing matched Only the two header lines.

The command always exits with status 0. Check the table to see whether it found anything.


Examples

# Run the report
/go/incoming
# Show today's saved report again without rebuilding it
column -t -s "|" /var/log/go/mail/incoming/incoming-$(date +%F).log
# Count today's messages
tail -n +3 /var/log/go/mail/incoming/incoming-$(date +%F).log | wc -l
# Rank today's sender IP addresses
tail -n +3 /var/log/go/mail/incoming/incoming-$(date +%F).log | cut -d'|' -f4 | sort | uniq -c | sort -nr | head
# Find mail for one recipient
grep -i 'sales@mydomain.com' /var/log/go/mail/incoming/incoming-$(date +%F).log
# Check which mail log your server uses
ls -l /var/log/maillog /var/log/mail.log
# Delete reports older than 30 days (the command never deletes them)
find /var/log/go/mail/incoming -name 'incoming-*.log' -mtime +30 -delete

Troubleshooting

Symptom Likely cause Fix
Only the two header lines are shown There was no matching mail today, or one of the causes below. Check /var/log/maillog for smtpd lines from today.
cat: /var/log/maillog: No such file or directory The server logs mail somewhere else. Debian and Ubuntu normally use /var/log/mail.log. Make the mail log available at /var/log/maillog, or change the script.
Rows are missing for mail you know arrived Only messages whose Subject line was logged are listed, and the sender must pass the filters (see Known limitations). Search the mail log by hand with the message's queue ID.
The same message appears twice Its queue ID appears on more than one SMTP log line, and the IDs aren't de-duplicated. Ignore the duplicate row.
Mail from your own users is listed The command lists everything the SMTP service accepted, including mail users send through it. Filter by sender.
Mail sent by a website with PHP mail() isn't listed Locally submitted mail doesn't go through the SMTP service. Use outgoing.
Only one recipient is shown for a message sent to several Only the first recipient is kept. Search the mail log by queue ID.
A subject is cut short or looks like =?UTF-8?B?...?= Subjects are cut at the first from and shown as logged, so encoded subjects aren't decoded. Decode it by hand.
The IP column is empty, shows 127.0.0.1, or is unrelated to the sender Only IPv4 addresses are recognized. For IPv6 senders the command can pick another IPv4 address from the same message's log lines, such as a local relay. Check the client= line in the mail log.
Columns look shifted column merges empty fields, so a blank IP shifts the following columns left. Read the saved file with `cut -d'
The command takes a long time It searches the whole mail log several times for every message. Run it when the server is quiet, or on a rotated log.
Yesterday's mail isn't shown The report covers today's log entries only. Search older logs by hand.

Details

Requirements

How it works

flowchart TD
    A["incoming"] --> B["Write log line"]
    B --> C["Start a new report file with a header"]
    C --> D["Collect today's queue IDs from smtpd lines"]
    D --> E["For each ID, look up time, recipient, sender, IP, subject"]
    E --> F{"Sender has @ and doesn't contain goadmio or root?"}
    F -- "Yes" --> G["Add a row"]
    F -- "No" --> H["Skip"]
    G --> I["Print the report with column"]
    H --> I

How the fields are found

  1. Queue IDs. Every log line from today that contains smtpd[ gives the sixth word, which must be a queue ID (capital hexadecimal letters and digits).
  2. Time. The time of the first smtpd line for that ID.
  3. From and To. Both come from one log line that contains from= and to= together. In Postfix's usual log format, the line that carries both is the one written when a header check logs the subject (info: header Subject: ...; from=<...> to=<...>). The queue and delivery lines each hold only one of them. If your Postfix doesn't log subjects, From stays empty and no rows are written.
  4. IP. The first IPv4 address found on any log line for that ID, normally the connecting client.
  5. Subject. The text after Subject: up to the last semicolon on its line, with everything from the first from onward removed, cut to 75 characters.

Each field is found by searching the whole log again, so the command does about five full passes over the mail log for every message.

Known limitations

The report file

The report is written to /var/log/go/mail/incoming/incoming-YYYY-MM-DD.log as text separated by |, with a header and a line of dashes. It is replaced on every run, so it holds the latest snapshot for the day. Files for earlier days are never deleted.

The files list senders, recipients, and subjects. Check who can read /var/log/go/mail/incoming on your server.

Exit status

The exit status is the status of the final column command, normally 0.

Log file

Each call appends a line with all its arguments to /var/log/go/incoming.log:

[Nov 19 12:00:00]# incoming

See also

Command Description
outgoing Report today's outbound mail sessions
subjecttop Report the most common email subjects in the Postfix maillog
mailtop Check the most active email accounts in GoAdmio
spam Track spam email accounts in GoAdmio
sasltop Report SASL LOGIN authentication failures and block persistent sources
troubleshoot Troubleshoot email problems in GoAdmio