Upload contacts to Mautic from a CSV file using BasicAuth.
# Enter development environment
nix-shellCopy the example env file and add your credentials:
cp .env.example .envEdit .env with your settings:
Create a CSV file with at least an email column:
email,firstname,lastname,company
john.doe@example.com,John,Doe,Example Corp
jane@example.com,Jane,Smith,Acme IncPreview what would happen without making changes:
php upload.php --csv contacts.csv --dry-runOutput:
Row 1: Would create/update contact: john.doe@example.com
Row 2: Would create/update contact: jane@example.com
Done. Success: 2, Errors: 0
Run for real to create/update contacts in Mautic:
php upload.php --csv contacts.csvOutput:
Batch rows 1-2: 2 success, 0 errors
Done. Success: 2, Errors: 0
Pull members directly from the member portal API:
php upload.php --portal --dry-run
php upload.php --portalThis requires PORTAL_TOKEN in your .env file.
The following fields are imported from the portal (preferred_name replaces firstname):
- firstname (or preferred_name if available)
- lastname
- major
- graduation_year
- tshirt_size
- uin
- confirmed_at
- member_since
| Column | Required | Description |
|---|---|---|
| Yes | Contact email address | |
| firstname | No | First name |
| lastname | No | Last name |
| company | No | Company name |
| * | No | Any other Mautic contact field |
--csv <file>- Path to CSV file (required if not using --portal)--portal- Fetch members from member portal API instead of CSV--portal-url <url>- Portal API URL (default: https://portal.ieeetamu.org)--dry-run- Preview without making changes--help- Show usage information
- Creates new contacts if email doesn't exist
- Updates existing contacts if email already exists (Mautic auto-merges by email)
- Contacts are uploaded in batches of 100 for fast processing
- Each batch prints a progress line with success/error counts
- Exit code 0 on success, 1 if any errors