Thanks for good input, i can use that to something.
Can you maybe give some examples for daemons i totally understand that and would 100% use that instead of a cronjob.
And what do you think of these SQL tables i have at the moment.
CREATE TABLE IF NOT EXISTS `abuse` (
`id` int(11) NOT NULL,
`pId` int(11) NOT NULL,
`name` varchar(255) COLLATE utf8_bin NOT NULL,
`email` varchar(255) COLLATE utf8_bin NOT NULL,
`message` longtext COLLATE utf8_bin NOT NULL,
`category` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`ip` varchar(15) COLLATE utf8_bin NOT NULL,
`status` varchar(50) COLLATE utf8_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CREATE TABLE IF NOT EXISTS `abuseCategories` (
`id` int(11) NOT NULL,
`name` varchar(255) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
INSERT INTO `abuseCategories` (`id`, `name`) VALUES
(1, 'Defekt billede'),
(2, 'Misbrug');
CREATE TABLE IF NOT EXISTS `abuseResponse` (
`id` int(11) NOT NULL,
`aId` int(11) NOT NULL,
`pId` int(11) NOT NULL,
`message` longtext COLLATE utf8_bin NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`username` varchar(50) COLLATE utf8_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
ALTER TABLE `abuse`
ADD PRIMARY KEY (`id`), ADD KEY `status` (`status`), ADD KEY `category` (`category`), ADD KEY `pId` (`pId`);
ALTER TABLE `abuseCategories`
ADD PRIMARY KEY (`id`), ADD KEY `name` (`name`);
ALTER TABLE `abuseResponse`
ADD PRIMARY KEY (`id`), ADD KEY `aId` (`aId`), ADD KEY `pId` (`pId`);
ALTER TABLE `abuse`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `abuseCategories`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=3;
ALTER TABLE `abuseResponse`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `abuse`
ADD CONSTRAINT `abuse_ibfk_1` FOREIGN KEY (`category`) REFERENCES `abuseCategories` (`name`) ON DELETE SET NULL ON UPDATE CASCADE,
ADD CONSTRAINT `abuse_ibfk_2` FOREIGN KEY (`pId`) REFERENCES `pictures` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
ADD CONSTRAINT `abuse_ibfk_3` FOREIGN KEY (`status`) REFERENCES `statuses` (`name`) ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE `abuseResponse`
ADD CONSTRAINT `abuseResponse_ibfk_1` FOREIGN KEY (`aId`) REFERENCES `abuse` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE,
ADD CONSTRAINT `abuseResponse_ibfk_2` FOREIGN KEY (`pId`) REFERENCES `pictures` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE;
Don't mind my native language as content on categories :)
I guess i need to make a script that runs every XX min in cron to check for new emails and add them to the mysql table.
I'd opt for a daemon over a cron job if you can. Aside from picking up new email quicker (eg. using IMAP IDLE), a dameon avoids the possibility of a large amount of email piling up between 'check email' jobs which would slow down the ingress of email into your database and could lead to cron jobs overlapping in severe cases.
But does this exist in phalcon or do i need to use [vanilla] php with imap?
Phalcon doesn't have any built-in IMAP/POP functionality, but a quick search turned up a few PHP libraries like Fetch that fit your requirements. PHP's IMAP/POP libraries are a bit fidly if you're not familiar with the protocol, so using a library with a nice abstraction will probably help you keep your code maintainable.
how should it be design architecture wise.
Here's one possiblity (pretty much reflects what you've said you plan to do). If the system is getting a lot of message traffic, you could push outgoing messages to a queue and have them processed by another daemon in the background, instead of sending emails directly from the front-end.