Your software
My Mautic version is: 4.2
My PHP version is: 7.4.27
My Database type and version is: MariaDB 10.5.15
Your problem
My problem is: Error 500 on attempting to send an email.
These errors are showing in the log:
[2022-03-05 22:08:11] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException: "An exception occurred while executing ‘INSERT INTO mauticemail_stats (email_address, date_sent, is_read, is_failed, viewed_in_browser, date_read, tracking_hash, retry_count, source, source_id, tokens, open_count, last_opened, open_details, email_id, lead_id, list_id, ip_id, copy_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)’ with params [ {{email content removed}} “, 0, null, “a:0:{}”, 25, “77”, 1, null, “4bfeaf7a3350744da59befbff9c56667”]:\n\nSQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (mautic
.mauticemail_stats
, CONSTRAINT FK_8EA2B849A8752772
FOREIGN KEY (copy_id
) REFERENCES mauticemail_copies
(id
) ON DELETE SET NULL) at /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:68, Doctrine\DBAL\Driver\PDO\Exception(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (mautic
.mauticemail_stats
, CONSTRAINT FK_8EA2B849A8752772
FOREIGN KEY (copy_id
) REFERENCES mauticemail_copies
(id
) ON DELETE SET NULL) at /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18, PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (mautic
.mauticemail_stats
, CONSTRAINT FK_8EA2B849A8752772
FOREIGN KEY (copy_id
) REFERENCES mauticemail_copies
(id
) ON DELETE SET NULL) at /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:112)”}
Steps I have tried to fix the problem: reinstall files, ran php bin/console doctrine:migration:status and php bin/console doctrine:migration:migrate with no errors and nothing outstanding.
I have also gone into the MariaDB table for mauticemail_copies and deleted the most recent edition along with the corresponding row in mauticemails with no success.