/go/collectmail searches every table in every MySQL/MariaDB database on the server for a column named email, gathers the addresses it finds, and writes them to a single file. The result is lowercased, sorted, free of duplicates, and limited to well-formed addresses. It is useful for migrations and for building a consolidated list of the addresses your sites already hold. Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.
Quick start
# Collect all email addresses into /root/emails.csv
/go/collectmail /root/emails.csv
[!WARNING]
The result contains personal data from all of your customers’ sites. Store it securely and use it only where you have the legal right, for example for a migration or for consent-based mailing. The command also leaves per-table copies of the addresses in/usr/local/goadmio/tmp/mail. See Cleanup.
Arguments
| Argument | Required | Notes |
|---|---|---|
<output file> |
Yes | The file to write. The name must end in .csv or .txt. A relative path is relative to the current directory. An existing file is overwritten. |
If the argument is missing, or the name doesn’t end in .csv or .txt, the command prints the same two lines and exits with status 1:
Error: No output file provided.
Usage: collectmail <Output CSV File>
Examples
# Collect addresses and keep only the final count on screen
/go/collectmail /root/emails.csv 2>/dev/null | tail -n 1
# Preview the first few addresses
head /root/emails.csv
# Count the addresses in the file
wc -l /root/emails.csv
# Remove the temporary per-table copies when finished
rm -rf /usr/local/goadmio/tmp/mail
Output
On screen
| What you see | Meaning |
|---|---|
Collecting Emails from <database>.<table>... |
The table currently being read. |
| Email addresses | The addresses found in each table are also printed as they are collected. |
ERROR 1054 ... Unknown column 'email' |
The table has no email column. This is expected and harmless. |
Emails: <number> |
The number of addresses written to the output file. |
If no table contains an address, no summary is printed and the output file isn’t created.
Output file
The file has one address per line, with no header row. Despite the .csv extension, there is only one column.
Every run is logged with a timestamp, for example [Nov 20 09:15:02]# collectmail /root/emails.csv, to /var/log/go/collectmail.log.
See the full reference at /go/collectmail and the GoAdmio command index.
GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.
