Hanging mails in outbox and ServiceException in log

Hello,

I run mail 3.7.8 on Nexccloud Ver. 29.0.7.1.

Now for only one user in my NC instance some emails are no longer delivered to the mail server. There are currently some emails in the outbox. The log contains the following message for each send attempt:

[mail] Warning: Could not send outbox message 2757: Could not send message because a previous send operation produced an unclear sent state.
from ? from – at 09/24/2024, 7:20:03 p.m

It appears to be a forwarded email. At least that’s what the user said. All other users can work normally.

I have already tried occ mail:clean-up without success. Is it possible to identify this one “previous email” and safely remove it from the “top” of the outbox? Or is there an occ command to reset the output queue for the user? Unfortunately I didn’t find that.

thx in advance.

I have the same issue. Mail is in status 13 in table oc_mail_local_messages. It occurred now the second time on a different user. How to convince mail app to try again even with an “unclear state”?

Same problem. Mail is in status 13 in table oc_mail_local_messages. Any ideas?

Are there any further details available via the Mail app’s SMTP debugging?

See Mail: Troubleshooting.

Not really a solution. I removed the hanging emails from the oc_mail_local_messages table step by step. After that, the rest of the stuck emails were sent successfully.

1 Like

Same Problem here, It startet after an update from 30.0.3 to 30.0.5.
I guess it happens when the server is turned off while a mail send operation is happening?

could you explain that a bit more in Detail?
When I read oc_mail_local_messages table I get a long text output of mails. What to do?

Hello.

I wanted to share a solution I found for dealing with stuck messages in Nextcloud Mail logs. When I encountered log entries like this:

Copy
Warning mail ServiceException
Could not send message because a previous send operation produced an unclear sent state.
Could not send outbox message 1711: Could not send message because a previous send operation produced an unclear sent state.
I extracted the message ID (e.g., 1711) from the log. Then, I collected all the IDs of the stuck messages and used the following SQL query to clean up the oc_mail_local_messages table:

USE nextcloud;  
DELETE FROM oc_mail_local_messages  
WHERE id IN (  
    1717, 1716, 1715, 1714, 1713, 1712, 1711, 1710, 1709, 1708,  
    1707, 1699, 1697, 1695, 1688, 1682, 1669, 1654, 1652, 1651,  
    1649, 1648, 1647, 1645, 1644, 1642, 1641, 1637, 1613, 1612  
);

After running this query, the issue with stuck messages was resolved, and the logs became clean again.

I hope this helps anyone facing a similar problem!

2 Likes

Sorry for the very late reply.

My solution was almost the same. The only difference was that I deleted the messages step by step from oldest to newest and then always waited a while.
After a few deletes, the rest of the queue was sent (I suspect via nc cron job).