GoAdmio

outgoing

List today's outgoing messages from the mail log, with time, sender, recipient, IP, and subject, and save the report

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


Overview

/go/outgoing reads today's entries in the Postfix mail log (/var/log/maillog) and lists the messages the server sent out. For each message it shows:

It prints the list as a table and saves it as a dated report file. It leaves out mail to the administrator address and mail from system senders, so the list shows your customers' outbound mail rather than GoAdmio's own notices. Use it to spot spam or a compromised mail account.

The command runs sudo internally, so run it as root or as a user with sudo rights. It needs the sqlite3 command.


Quick start

# Show today's outgoing mail
/go/outgoing

Syntax

/go/outgoing

The command takes no arguments. Anything you add is written to the command log but otherwise ignored.

Every run is recorded in /var/log/go/outgoing.log, with the time and the arguments you passed.


Options

None.


Output

The command prints a table with one row per message, then saves the same data to a file.

Column Meaning
Time Time of the first delivery entry for the message (HH:MM:SS).
From The sender address.
To The recipient address. Only the first recipient is shown.
IP The first IPv4 address found in the message's log lines. For mail submitted by a mail client, this is normally the client's address.
Subject The subject, cut to 75 characters. Blank if the subject wasn't recorded in the log.
Time      From              To                IP            Subject
----      ----              --                --            -------
09:15:02  info@example.com  client@gmail.com  203.0.113.10  Your invoice

Report file

The report is saved to:

/var/log/go/mail/outgoing/outgoing-<YYYY-MM-DD>.log

In the file, columns are separated by | instead of aligned with spaces, so it is easy to import elsewhere:

Time|From|To|IP|Subject
----|----|--|--|-------
09:15:02|info@example.com|client@gmail.com|203.0.113.10|Your invoice

[!NOTE] Running the command again on the same day overwrites that day's report file. Copy the file first if you need to keep an earlier version.

Log

Each run appends one line to /var/log/go/outgoing.log:

[Nov 21 12:00:00]# outgoing

Examples

# Show today's outgoing mail
/go/outgoing
# Show only messages sent by one domain
/go/outgoing | grep '@example.com'
# Count today's outgoing messages (subtract 2 for the header rows)
wc -l /var/log/go/mail/outgoing/outgoing-$(date +%F).log
# Find the senders with the most messages today
cut -d'|' -f2 /var/log/go/mail/outgoing/outgoing-$(date +%F).log | sort | uniq -c | sort -rn | head

Troubleshooting

An empty table (only the two header rows) means no message passed the filters, not that the command failed.

Symptom Likely cause Fix
Only the header rows appear No outgoing mail today, or every sender was filtered out. Check /var/log/maillog for lines containing smtp[ and to=. See Which messages are listed.
A sender you expect is missing The address contains go or root anywhere, for example info@google.com or go@example.com. See Which messages are listed.
Subject is blank The subject wasn't recorded in the mail log for that message. None. The other columns are still correct.
The same message appears more than once A message with several recipients, or one retried after a deferral, creates several log entries. Ignore the repeats. Each repeat shows only the first recipient.
Yesterday's mail is missing The command only reads entries dated today. Read the rotated mail log (such as /var/log/maillog-<date>) directly.
The command is slow A large mail log is scanned several times per message. Run it when the server is quiet, or filter the saved report instead.

Details

Which messages are listed

The command first finds today's outgoing delivery entries, then builds one row for each message found.

Step Rule
Today's entries Only log lines dated today are used.
Outgoing deliveries Only lines from the Postfix SMTP client (smtp[) that contain to= are used.
Administrator mail Lines that contain the administrator email address are skipped. If the address is empty or invalid, nothing is skipped. If several addresses are set (comma-separated), all of them are skipped.
Sender has an address From must contain an @. Empty senders, such as bounce messages, are left out.
System senders From must not contain go or root anywhere in the address.

[!WARNING] The go check matches any sender address that contains those two letters, wherever they appear. Senders at domains such as google.com or mongo.example, or with names like gordon@, are left out of the report even though they are real outgoing mail.

The administrator email address is read from GoAdmio's configuration database. To change it, use email.

Where the data comes from

All columns are read from the Postfix log entries that share the message's queue ID.

Column Source
Time The first smtp[ entry for the message.
To The first to=<...> value.
From The first from=<...> value.
IP The first IPv4 address in any entry for the message.
Subject The Subject: text of the logged message header, with the trailing host information removed.
flowchart TD
    A["outgoing"] --> B["Log the run, start today's report file with header rows"]
    B --> C["Read the administrator email from the GoAdmio database"]
    C --> D["Find today's smtp[ delivery entries, skipping the administrator address"]
    D --> E["For each queue ID: read time, from, to, IP, subject"]
    E --> F{"From has @, and no go or root?"}
    F -- "Yes" --> G["Append row to the report file"]
    F -- "No" --> H["Skip"]
    G --> I["Print the report as an aligned table"]
    H --> I

See also

Command Description
incoming List today's messages received by the server's SMTP service, with time, sender, recipient, IP, and subject
mailtop Check the most active email accounts in GoAdmio
subjecttop Report the most common email subjects in the Postfix maillog
spam Track spam email accounts in GoAdmio
email Change the administrator email address GoAdmio uses for server notifications
troubleshoot Troubleshoot email problems in GoAdmio