- Connected to the provided MySQL
emailsdatabase on the server - Built a Laravel app with:
- Artisan command to parse
email→raw_text(plain text only) - RESTful API (Store, Get, Update, Delete, List)
- Token-based auth middleware
- Artisan command to parse
- Parsing uses
php-mime-mail-parser/php-mime-mail-parser(no external services) - Skips already processed rows
- API and parsing logic tested and working
- Project path:
/var/www/html/email-parser - DB used:
emails(loaded viasuccessful_emails.sql)
- I've prepared a Docker setup for local development. You can run the following command to start the containers:
docker-compose up -d
- Run the following command to install the dependencies:
docker-compose exec app composer install - Copy the
.env.examplefile to.envand set your database credentials:cp .env.example .env
- Generate the application key:
docker-compose exec app php artisan key:generate - Run the migrations:
docker-compose exec app php artisan migrate- Create a user using
php artisan tinkerfor API authentication:
docker-compose exec app php artisan tinker$user = \App\Models\User::create([ 'name' => 'Your Name', 'email' => 'your_email@example.com', 'password' => bcrypt('your_password'), ]); echo $user->createToken('API Token')->plainTextToken;
- Create a user using
- Run parser manually:
php artisan emails:parse - API: use
Authorization: Bearer {TOKEN}header - Create token by running
php artisan tinkerand executing the following:$user = \App\Models\User::find(1); // Replace 1 with the user ID echo $user->createToken('API Token')->plainTextToken;
- Use the token in your API requests. Select Bearer Token in Postman and paste the token in the field.
- Log into the server and verify database access
- Clone project to
/var/www/email-parser - Set up
.envwith correct DB credentials - Run
composer installandphp artisan key:generate
- Create
emails:parseArtisan command - Use
php-mime-mail-parser/php-mime-mail-parserto extract plain text - Strip HTML and headers
- Keep only printable characters and
\n - Skip already processed records
- Limit batch size for safety
- Test parsing on real data
- Register the command
- Run Laravel scheduler via
schedule:workor cron
- Create POST
/api/emailsto store and auto-parse - Create GET
/api/emails/{id}to fetch by ID - Create PUT
/api/emails/{id}to update - Create GET
/api/emailsto list - Create DELETE
/api/emails/{id} - Add token-based authentication middleware
- Parse all existing unprocessed records
- Write README with setup and API instructions
- [ x Email submission with:
- GitHub repo link
- Server path:
/var/www/html/email-parser - Confirmation that everything is working
- Import existing email data into the newly migrated Laravel database on the server
- Ensure the imported data matches the structure expected by Laravel
- Create a user using
php artisan tinkerfor API authentication - Generate and assign an API token or notification key for the user
- Set up and confirm that cron is running the parsing job on the server
- Test the entire setup directly on the server to make sure everything works as expected