nextcloud / mail

💌 Mail app for Nextcloud
https://apps.nextcloud.com/apps/mail
GNU Affero General Public License v3.0
832 stars 257 forks source link

"No sent mailbox configured" Error when sending a message #4153

Open alabre opened 3 years ago

alabre commented 3 years ago

Expected behavior

Tell us what should happen After filling in the complete form to create a new mail account and saving without errors and syncing the inbox from the new account succussfully, I expect the app to send E-Mails without an error, assuming the remote IMAP server is available. The sent mail should occur in the sent folder.

Actual behavior

Tell us what happens instead Sending a message results in a 400 error response with the information: {"status":"fail","data":{"message":"No sent mailbox configured","type":"OCA\Mail\Exception\SentMailboxNotSetException"}} (to be seen in the developer tools of chromium in the network section). The mail is not sent and not stored in the configured folder (INBOX.sent)

Sidenote: while writing a 400 error occurrs when the app tries to save the draft (No drafts mailbox configured...).

Mail app

Mail app version: (see apps admin page, e.g. 0.5.3) 1.7.0

Mailserver or service: (e.g. Outlook, Yahoo, Gmail, Exchange,...) Remote hosted webserver (by onyxhosting) with postfix

Server configuration

Operating system: (e.g. Debian 8) Ubuntu 20.04 LTS

Web server: (e.g. Apache, Nginx,...) Nginx 1.7

Database: (e.g. MariaDB, SQLite or PostgreSQL) PostgreSQL 12.5

PHP version: (e.g. 7.0) 7.4

Nextcloud Version: (see admin page, e.g. 13.0.2) 20.0.2

Client configuration

Browser: (e.g. Firefox 48) Chromium 87.0

Operating system: (e.g. Arch Linux) Arch Linux

ChristophWurst commented 3 years ago

I think the auto detection doesn't always work. Can you confirm that in your account settings there are no drafts/sent/trash mailboxes configured even though your account has mailboxes for that?

alabre commented 3 years ago

Thank you for you quick response. :-) I missed to give you some more information. I configured the mailbox manually. I have set the empty fields for Sent/Drafts/Trash and they are still shown in the configuration. When I send a mail I get the error. The IMAP folder "INBOX.sent" is the name shown when I click on the three dots of the corresponding folder in the lefthandside folder view of the mail account in the app. The name in the folder view is "Gesendet" as I am on a German system.

Another observation is that after some tries to get the account running (and edits in the configuration) the fields for the three special folders are empty and I have to fill them in again. The password fields for IMAP and SMTP servers have to be filled in always (although they contain dots, as if filled), otherwise I get an authentication error on port 993 when saving the data from the form.

And a last one: Running php -f occ mail:account:export leads to three entries (1, 8 4) where 8 is the current one. Before the last deletion of a not working account it was 6. 1 and 4 are misconfigured and have not been deleted correctly, when I deleted the accounts using the three dot dialog->Delete Account

So that's more information and what my experience is. I will not doubt if the cause is more than one issue and I will open more issues if you like and tell me how you want them to be sliced. :-)

alabre commented 3 years ago

Just checked same mail settings on a hosted environment with php 7.3 and mysql 10.3, Nextcloud 19.0.5 and Mail App 1.4.1

On that system I am able to sync and send E-Mails using the same settings and credentials as I use on the other server.

ChristophWurst commented 3 years ago

Yeah because Nextcloud 19 doesn't have the mailbox preference settings yet. It will always decide on the fly, which works if you are lucky but it's not very transparent for the user.

IamMrB commented 3 years ago

Hello I have the same issue. I am able to set up the account but when trying to send receive the "Error sending your message No sent mailbox configured. Please pick one in the account settings." When checking the account settings the Drafts, Sent and Deleted messages folders are set correctly.

Debian 9 PHP 7.3.21 mysql Ver 15.1 Distrib 10.1.47-MariaDB Nextcloud 20.0.3 Mail App 1.7.2

Please let me know if there is anything I can provide to help with troubleshooting the issue.

ChristophWurst commented 3 years ago

Please let me know if there is anything I can provide to help with troubleshooting the issue.

Yes please, I'd like to know if the stored sent mailbox preference is also in the database. Please get the account ID, then check the database table oc_mail_accounts for the account with that ID and see if the sent_mailbox_id is set.

alabre commented 3 years ago

Hi ChristophWurst, I have checked the database for an account created with autoconfig (the mail app has found the correct folders). The database showed IDs like 245,246,247 for the three special folders.

Sending still failed, this is the error from the log {"reqId":"M8exSjk3nJKiwyYVcgq4","level":3,"time":"2020-12-17T20:12:49+00:00","remoteAddr":"","user":"--","app":"mail","method":"","url":"--","message":{"Exception":"OCA\Mail\Exception\ServiceException","Message":"IMAP error: Error connecting to mail server.","Code":11,"Trace":[{"file":"/apps/mail/lib/BackgroundJob/SyncJob.php","line":91,"function":"sync","class":"OCA\Mail\IMAP\MailboxSync","type":"->"},{"file":"/lib/public/BackgroundJob/Job.php","line":80,"function":"run","class":"OCA\Mail\BackgroundJob\SyncJob","type":"->"},{"file":"/lib/public/BackgroundJob/TimedJob.php","line":61,"function":"execute","class":"OCP\BackgroundJob\Job","type":"->"},{"file":"/cron.php","line":127,"function":"execute","class":"OCP\BackgroundJob\TimedJob","type":"->"}],"File":"/apps/mail/lib/IMAP/MailboxSync.php","Line":106,"Previous":{"Exception":"Horde_Imap_Client_Exception","Message":"Error connecting to mail server.","Code":11,"Trace":[{"file":"/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Socket.php","line":375,"function":"_connect","class":"Horde_Imap_Client_Socket","type":"->"},{"file":"/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Base.php","line":838,"function":"_login","class":"Horde_Imap_Client_Socket","type":"->","args":[" sensitive parameters replaced "]},{"file":"/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Base.php","line":1389,"function":"login","class":"Horde_Imap_Client_Base","type":"->","args":[" sensitive parameters replaced "]},{"file":"/apps/mail/lib/IMAP/FolderMapper.php","line":60,"function":"listMailboxes","class":"Horde_Imap_Client_Base","type":"->"},{"file":"/apps/mail/lib/IMAP/MailboxSync.php","line":103,"function":"getFolders","class":"OCA\Mail\IMAP\FolderMapper","type":"->"},{"file":"/apps/mail/lib/BackgroundJob/SyncJob.php","line":91,"function":"sync","class":"OCA\Mail\IMAP\MailboxSync","type":"->"},{"file":"/lib/public/BackgroundJob/Job.php","line":80,"function":"run","class":"OCA\Mail\BackgroundJob\SyncJob","type":"->"},{"file":"/lib/public/BackgroundJob/TimedJob.php","line":61,"function":"execute","class":"OCP\BackgroundJob\Job","type":"->"},{"file":"/cron.php","line":127,"function":"execute","class":"OCP\BackgroundJob\TimedJob","type":"->"}],"File":"/apps/mail/vendor/pear-pear.horde.org/Horde_Imap_Client/Horde/Imap/Client/Socket.php","Line":605},"CustomMessage":"Cron mail sync failed: IMAP error: Error connecting to mail server."},"userAgent":"--","version":"20.0.4.0","id":"5fdbbfdb8572e"}

After that I edited the settings manually. When loading the settings, the three special folders were shown as expected. I saved the settings and reopened them. The three special fields were empty and the values in the database were gone. After setting the three special folders manually and saving the settings, values in the database were still empty.

Looks as if there were two problems:

  1. Values from the settings page were not written into the database after editing
  2. When set correctly horde has a problem to connect the mail server (maybe related to php 7.4?)

Cheers, alabre

minikN commented 3 years ago

I experience the same issue.

ChristophWurst commented 3 years ago

@minikN just add your :+1: to the report

panfanky commented 3 years ago

For me the issue occured like this: -I visit mail tab an am prompted to set up account -I choose manual and put in servers got from my host -I get an error "Request failed with status code 404" -I visit mail tab and see the account got created anyway (-I set the IMAP and SMTP in Account settings without errors) -I try to send e-mail, I get this error, as no Drafts nor Sent folders got created

Workaround: -I create the folders called Drafts and Sent manually -I set them in the Defaults section of Account settings -The mail gets sent now

water-man commented 3 years ago

Same issue here. I have 2 observations that might/might not be relevant:

  1. My system uses Dutch language and all (mail) settings and menu are in Dutch EXCEPT the Default Mail Store settings. Replacing Drafts(En) with Concepten(Nl) does also not work.
  2. All (4) users synchronize with the same external mail server, 2 of them have no problem The other 2 share the same account with this external provider. When there was still one he also had no problem. The problem started to occur when I added the second Nextcloud user to the same external mail account, coincidence??
When I removed the last added user, this did not improve the situation for the original (3rd) user, error remained. As a last resort I manually added a folder(with the 3rd user) and selected that in the dropdown menu as sent box. Also no difference. This comes from the log file: `Error mail Exception:  Argument 1 passed to OCA\Mail\Address::fromRaw() must be of the type string, null given, called in /var/snap/nextcloud/25652/nextcloud/extra-apps/mail/lib/Service/MailTransmission.php on line 202/snap/nextcloud/25652/htdocs/lib/private/AppFramework/App.php - line 152:OC\AppFramework\Http\Dispatcher->dispatch(OCA\Mail\Con ... {}, "draft")/snap/nextcloud/25652/htdocs/lib/private/Route/Router.php - line 308:OC\AppFramework\App::main("OCA\Mail\ ... r", "draft", OC\AppFramew ... {}, { action: nu ... "})/snap/nextcloud/25652/htdocs/lib/base.php - line 1008:OC\Route\Router->match("/apps/mail/ ... t")/snap/nextcloud/25652/htdocs/index.php - line 37:OC::handleRequest()Veroorzaakt doorTypeError: Argument 1 passed to OCA\Mail\Address::fromRaw() must be of the type string, null given, called in /var/snap/nextcloud/25652/nextcloud/extra-apps/mail/lib/Service/MailTransmission.php on line 202/var/snap/nextcloud/25652/nextcloud/extra-apps/mail/lib/Service/MailTransmission.php - line 202:OCA\Mail\Address::fromRaw(null, "archivaris@**.nl")/var/snap/nextcloud/25652/nextcloud/extra-apps/mail/lib/Controller/AccountsController.php - line 456:OCA\Mail\Service\MailTransmission->saveDraft(OCA\Mail\Mod ... {}, null)/snap/nextcloud/25652/htdocs/lib/private/AppFramework/Http/Dispatcher.php - line 169:OCA\Mail\Controller\AccountsController->draft(3, "", "", "", "", "", false, null)/snap/nextcloud/25652/htdocs/lib/private/AppFramework/Http/Dispatcher.php - line 100:OC\AppFramework\Http\Dispatcher->executeController(OCA\Mail\Con ... {}, "draft")/snap/nextcloud/25652/htdocs/lib/private/AppFramework/App.php - line 152:OC\AppFramework\Http\Dispatcher->dispatch(OCA\Mail\Con ... {}, "draft")/snap/nextcloud/25652/htdocs/lib/private/Route/Router.php - line 308:OC\AppFramework\App::main("OCA\Mail\ ... r", "draft", OC\AppFramew ... {}, { action: nu ... "})/snap/nextcloud/25652/htdocs/lib/base.php - line 1008:OC\Route\Router->match("/apps/mail/ ... t")/snap/nextcloud/25652/htdocs/index.php - line 37:OC::handleRequest()

`

Hope this helps.

alabre commented 3 years ago

Hi there, after some ubuntu 20.04 updates and some nextcloud updates to 20.0.7 and mail app 1.8.1 I registered my mail account by automatic detection and now I am able to send mails as expected. I have seen there was a commit regarding this issue, but I am not sure if it made it's way into the release. Thanks for all the work you do.

I have no clue which rules exist to close this issue, so I leave it to you or I would like to get a short note if I shall close it.

Cheers, Achim

ChristophWurst commented 3 years ago

I have seen there was a commit regarding this issue, but I am not sure if it made it's way into the release.

which one? FYI on github you'll see all the git tags that have the commit. that's my usual trick to tell if or what release the commit was included with.

alabre commented 3 years ago

I have seen this one https://github.com/nextcloud/mail/commit/e5186f7689177552ec516238e6652aed39754bbe but may be it's not related to my problem... I quit programming in java almost 10 years ago and never used php or so...

But it's working now on my server. Do you want me to close it or want to leave it open?

grubshka commented 3 years ago

This comes from the log file: Error | mail | Exception: Argument 1 passed to OCA\Mail\Address::fromRaw() must be of the type string, null given, called in /var/snap/nextcloud/25652/nextcloud/extra-apps/mail/lib/Service/MailTransmission.php on line 202/snap/nextcloud/25652/htdocs/lib/private/AppFramework/App.php - line 152:OC\AppFramework\Http\Dispatcher->dispatch(OCA\Mail\Con ... {}, "draft")/snap/nextcloud/25652/htdocs/lib/private/Route/Router.php - line 308:OC\AppFramework\App::main("OCA\\Mail\\ ... r", "draft", OC\AppFramew ... {}, { action: nu ... "})/snap/nextcloud/25652/htdocs/lib/base.php - line 1008:OC\Route\Router->match("/apps/mail/ ... t")/snap/nextcloud/25652/htdocs/index.php - line 37:OC::handleRequest()Veroorzaakt doorTypeError: Argument 1 passed to OCA\Mail\Address::fromRaw() must be of the type string, null given, called in /var/snap/nextcloud/25652/nextcloud/extra-apps/mail/lib/Service/MailTransmission.php on line 202/var/snap/nextcloud/25652/nextcloud/extra-apps/mail/lib/Service/MailTransmission.php - line 202:OCA\Mail\Address::fromRaw(null, "archivaris@**********.nl")/var/snap/nextcloud/25652/nextcloud/extra-apps/mail/lib/Controller/AccountsController.php - line 456:OCA\Mail\Service\MailTransmission->saveDraft(OCA\Mail\Mod ... {}, null)/snap/nextcloud/25652/htdocs/lib/private/AppFramework/Http/Dispatcher.php - line 169:OCA\Mail\Controller\AccountsController->draft(3, "", "", "", "", "", false, null)/snap/nextcloud/25652/htdocs/lib/private/AppFramework/Http/Dispatcher.php - line 100:OC\AppFramework\Http\Dispatcher->executeController(OCA\Mail\Con ... {}, "draft")/snap/nextcloud/25652/htdocs/lib/private/AppFramework/App.php - line 152:OC\AppFramework\Http\Dispatcher->dispatch(OCA\Mail\Con ... {}, "draft")/snap/nextcloud/25652/htdocs/lib/private/Route/Router.php - line 308:OC\AppFramework\App::main("OCA\\Mail\\ ... r", "draft", OC\AppFramew ... {}, { action: nu ... "})/snap/nextcloud/25652/htdocs/lib/base.php - line 1008:OC\Route\Router->match("/apps/mail/ ... t")/snap/nextcloud/25652/htdocs/index.php - line 37:OC::handleRequest() -- | -- | --

@water-man If that could help, I had this error and solved it : https://github.com/nextcloud/mail/issues/4386

meatgreet commented 3 years ago

I had this error and solved it by manually entering the information into the database.

IanChok commented 2 years ago

@meatgreet Do you recall the exact commands you used to get this done? I'm encountering the same issue :confused:

meatgreet commented 2 years ago

@meatgreet Do you recall the exact commands you used to get this done? I'm encountering the same issue confused

I didn't use the command line. I used the phpmyadmin tool in my site's control's panel. It's a tool to edit mysql databases using an graphical interface. So log into your webhost and click on phpmyadmin.

  1. Looking at the left column follow the instructions I originally posted. i.e. find and click on oc_mail_accounts found in the left column, find your mailbox's ID# in the data that loads in the center column. Write that number down.
  2. Then in the left column find oc_mail_mailboxes and find the ID# for the sent folder assigned to your mail account ID#. For example, mail account number 3763 has a sent folder which has been assigned an ID# of 2282.
  3. Then go back to oc_mail_accounts find the row in the database info for your sent folder and enter the sent folder ID# (from my example mailbox 3763 has a sent folder with a missing ID#, so you enter number 2282 in the blank field). While there see if any other folders are missing their ID#'s and repeat the process for them.
pierreozoux commented 2 years ago

It just happened to one of our user just now.

The folders do have traditional folders:

I think for me the main trouble is that the error message sent to the user was not explicit, just showing a 400 that the message can't be sent.

But then, yeah, once looking at the server log and seeing: Saving draft failed: No drafts mailbox configured we managed to fix the issue. We had to make a visio together to be able to debug that.

And now the issue is fixed on our side.

As a first iteration, making it more obvious to the user what the problem is, would already really help. Maybe even add the selection of this folders in the mailbox creation wizard, or in the param, marking them as required fields in the form.

My 2 cents :)

rholighaus commented 2 years ago

Couldn't mail app just automatically create the Sent, Draft, Trash folders if no folders are configured and they do not exist in the IMAP account? This is how any other IMAP client would react.

EDIT: Found that in our case, configuring Dovecot accordingly will create the folders and they will be used by NextCloud mail. We configured the file /etc/dovecot/conf.d/15-mailboxes.conf like this:

namespace inbox {

mailbox "Drafts" { special_use = \Drafts auto = create }

mailbox "Ham" { auto = subscribe }

mailbox "Junk" { special_use = \Junk }

mailbox "Sent" { special_use = \Sent auto = subscribe }

mailbox "Sent Messages" { special_use = \Sent }

mailbox "Spam" { special_use = \Junk auto = subscribe }

mailbox "Trash" { special_use = \Trash auto = subscribe }

mailbox "Draft" { special_use = \Drafts auto = subscribe }

}

Which does the trick.

nickvergessen commented 2 years ago

We have the following error 257 times in the last 2 weeks in our company log:

{"reqId":"…","level":3,"time":"2022-03-22T07:56:35+00:00","remoteAddr":"…","user":"…","app":"mail","method":"POST","url":"/apps/mail/api/accounts/299/draft","message":"Saving draft failed: No drafts mailbox configured","userAgent":"…","version":"23.0.3.2"}
kiwiz commented 2 years ago

I'm encountering this issue when logging into an account on Gandi - mailboxes exist in the (Gandi) WebUI, but are not detected by Nextcloud.

ChristophWurst commented 1 year ago

Label dropped because it was a duplicate of the attribute at https://github.com/orgs/nextcloud/projects/61. The priority does not change.

sk757a commented 1 year ago

The level of logging is completely insufficient. Even with maximum detail turned on, I didn't see anything to help me understand that the problem with unsent emails is due to missing or unconfigured mail folders. Only when I saw the response to the POST /apps/mail/api/outbox/21 HTTP/2.0" 400 did I find useful information.

ChristophWurst commented 1 year ago

What we can do (just brainstorming)

1) Disable sending if we know there is no sent mailbox configured -> send user to account settings or create/assign a mailbox for them 2) Create special mailboxes at account setup, if the account doesn't have them.

ChristophWurst commented 1 year ago

Let's do the following

Before a message is sent, you check if the selected account has a sent mailbox configured. If not, see if there is a mailbox with the name account.personalNamespace + t('mail', 'Sent') or account.personalNamespace + 'Sent'. If so, update the account to set that as sent mailbox. If no existing mailbox looks like a sent mailbox we create one with the name account.personalNamespace + t('mail', 'Sent') and assign it as sent mailbox. Then we continue sending.

geonom commented 8 months ago

Hey there, I am having the same issue sadly on NC 28.01 with Mail 3.5.1 sometimes

ClientException No drafts mailbox configured Could not move draft to IMAP

The errors of course are accumulating in the log.