============================================================
MailFlow - Simple Installation Guide
For Complete Beginners
============================================================

This guide will walk you through installing MailFlow
step by step using your web hosting control panel.
No technical experience required!

------------------------------------------------------------
WHAT YOU NEED BEFORE YOU START
------------------------------------------------------------

1. A web hosting account (any shared hosting will work)
2. Access to your hosting control panel (cPanel, Plesk, etc.)
3. The MailFlow zip file (you already have this)
4. About 15 minutes

------------------------------------------------------------
STEP 1: LOG INTO YOUR HOSTING CONTROL PANEL
------------------------------------------------------------

1. Go to your web host's website
2. Log into your control panel (cPanel or Plesk)
3. Look for "File Manager" - we'll use this to upload files

------------------------------------------------------------
STEP 2: UPLOAD AND EXTRACT THE FILES
------------------------------------------------------------

1. In your control panel, open "File Manager"
2. Navigate to the folder where your website lives.
   This is usually called:
   - public_html  (most common)
   - www
   - httpdocs (Plesk)
3. You can install MailFlow either:
   A) Directly in public_html (your site will be at yourdomain.com)
   B) In a sub-folder (e.g., public_html/mailflow → yourdomain.com/mailflow)
   
   RECOMMENDATION for beginners: Create a sub-folder
   - Click "New Folder" in File Manager
   - Name it: mailflow
   - Open that folder

4. Click "Upload" in File Manager
5. Upload the MailFlow.zip file
6. Once uploaded, right-click the zip file
7. Select "Extract" or "Extract Here"
8. The files will be extracted into the folder
9. You can delete the zip file after extraction

------------------------------------------------------------
STEP 3: CREATE A DATABASE
------------------------------------------------------------

1. In your control panel, find "MySQL Databases"
   (It might also be called "Database Wizard")
2. Create a new database:
   - Click "Create New Database"
   - Type a name like: mailflow_db
   - Click Create
3. Create a database user:
   - Type a username like: mailflow_user
   - Type a strong password (save this somewhere!)
   - Click Create User
4. Add the user to the database:
   - Under "Add User to Database"
   - Select your user and database
   - Click Add
   - Grant ALL PRIVILEGES
   - Click Make Changes

WRITE DOWN THESE DETAILS - YOU WILL NEED THEM:
  Database Name: ___________________
  Database Username: ___________________
  Database Password: ___________________
  Database Host: localhost (almost always)

------------------------------------------------------------
STEP 4: IMPORT THE DATABASE TABLES
------------------------------------------------------------

1. In your control panel, find "phpMyAdmin"
2. Click your database name on the LEFT side
3. Click the "Import" tab at the top
4. Click "Choose File"
5. Find and select the file: database.sql
   (It's in the MailFlow folder you extracted)
6. Scroll down and click "Import" or "Go"
7. You should see a success message in green

------------------------------------------------------------
STEP 5: CONFIGURE THE APP
------------------------------------------------------------

1. In File Manager, go to your MailFlow folder
2. Find the file called: config.php
3. Right-click it and choose "Edit" or "Code Edit"
4. Find these lines and change them:

   define('USER_DB_HOST', 'localhost');
   Change 'localhost' only if your host says different

   define('USER_DB_NAME', 'your_app_db');
   Change 'your_app_db' to your database name from Step 3

   define('USER_DB_USER', 'db_user');
   Change 'db_user' to your database username from Step 3

   define('USER_DB_PASSWORD', 'db_password');
   Change 'db_password' to your database password from Step 3

   $sitename='';
   Change to: $sitename='MailFlow';

5. Click "Save" when done

------------------------------------------------------------
STEP 6: COPY IN THE REQUIRED SYSTEM FILES
------------------------------------------------------------

The following files are included with your package and need
to be placed in the ROOT (main) MailFlow folder:

  protect.php     - Already included in your package
  user-lib.php    - Already included in your package
  login.php       - Already included in your package
  logout.php      - Already included in your package
  register.php    - Already included in your package

These files handle user accounts and security. They should
already be in the folder if you extracted the full package.

------------------------------------------------------------
STEP 7: TEST YOUR INSTALLATION
------------------------------------------------------------

1. Open your web browser
2. Go to your MailFlow URL:
   - yourdomain.com (if installed in public_html)
   - yourdomain.com/mailflow (if installed in sub-folder)
3. You should see a login page
4. Click "Register" to create your account
5. Log in with your new account
6. You should see the Dashboard!

------------------------------------------------------------
STEP 8: SET UP YOUR SMTP EMAIL
------------------------------------------------------------

1. Once logged in, click "SMTP Settings" in the left sidebar
2. Enter your email server details
3. Click "Save Settings"
4. Use the "Send Test Email" section to verify it works

Need SMTP? Options include:
  - Your web hosting email (ask your host for SMTP details)
  - Gmail (needs App Password - see User Guide)
  - SendGrid free tier (100 emails/day free)
  - Brevo/Sendinblue (300 emails/day free)

------------------------------------------------------------
SOMETHING WENT WRONG?
------------------------------------------------------------

BLANK PAGE or ERROR MESSAGE:
  - Double-check config.php has the correct database details
  - Make sure you imported database.sql correctly
  - Check all files were extracted properly

"Could not connect to database":
  - Recheck your database name, username and password in config.php
  - Some hosts use a different DB host (not localhost) - check with your host

"Page not found" (404 error):
  - Make sure you're looking in the right folder
  - Check the files were uploaded to the right location

CONTACT YOUR HOST if you're stuck - most hosts have 24/7 support
and can help you check file permissions and database connections.

------------------------------------------------------------
FILES IN YOUR PACKAGE
------------------------------------------------------------

config.php           - Configuration (YOU EDIT THIS)
database.sql         - Import this into phpMyAdmin
index.php            - Dashboard
contacts.php         - Manage contacts
contact_edit.php     - Add/edit a contact
contact_delete.php   - Deletes contacts
contact_import.php   - Import CSV contacts
tags.php             - Manage tags
campaigns.php        - Manage campaigns
campaign_edit.php    - Create/edit campaign
campaign_send.php    - Send/schedule campaigns
queue.php            - Email queue
automations.php      - Manage automations
automation_edit.php  - Create/edit automation
settings.php         - SMTP configuration
protect.php          - Security (included in package)
user-lib.php         - User system (included in package)
login.php            - Login page (included in package)
logout.php           - Logout (included in package)
register.php         - Registration (included in package)
includes/            - Folder with shared code
api/                 - Folder with background processors
css/                 - Folder with styling
js/                  - Folder with JavaScript

============================================================