Author Topic: can't save sent mail  (Read 6758 times)

Offline heinohund

  • Jr. Member
  • **
  • Posts: 17
can't save sent mail
« on: February 22, 2015, 06:06:47 AM »
Hello,

I have not changed any settings. But suddenly Roundcube can not save sent mail.

Anyone have an idea what's wrong?

What do you need to help?

Br
Henrik

Offline bratze

  • Newbie
  • *
  • Posts: 7
Re: can't save sent mail
« Reply #1 on: February 26, 2015, 04:57:32 AM »
Same for me!  :-\

Sent mails are not saved into the Sent-folder of any IMAP account I have. It must be related to Roundcube as ...
  • issue is observed with a series of IMAP accounts, each by another provider/from another server
  • Sent  folder is always clearly assigned at "Special Folders"
  • alternative Sent folder locations (same level as INBOX as well as subordinate to INBOX) also fail
  • autosaving sent mails with same IMAP accounts by a local Thunderbird installation works fine

I am on 1.1.0 connected to Postfix/Dovecot on Ubuntu 14.04.01 LTS.

Best
Bratze
« Last Edit: February 26, 2015, 07:47:08 AM by bratze »

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,268
Re: can't save sent mail
« Reply #2 on: February 26, 2015, 11:01:46 AM »
Please could you have a look in your config at what the `no_save_sent_messages`option is set to. And also on the compose screen in the composition options (where the options are to switch between html/plain text ect) there is one called "Save sent message in".
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline heinohund

  • Jr. Member
  • **
  • Posts: 17
Re: can't save sent mail
« Reply #3 on: February 26, 2015, 01:03:00 PM »
Where do I find "no_save_sent_messages"

Br
Henrik

Offline heinohund

  • Jr. Member
  • **
  • Posts: 17
Re: can't save sent mail
« Reply #4 on: February 26, 2015, 01:13:18 PM »
Code: [Select]
// Determine which folder to save message
if ($savedraft) {
    $store_target = $drafts_mbox;
}
else if (!$RCMAIL->config->get('no_save_sent_messages')) {
    if (isset($_POST['_store_target'])) {
        $store_target = rcube_utils::get_input_value('_store_target', rcube_utils::INPUT_POST);
    }
    else {
        $store_target = $RCMAIL->config->get('sent_mbox');
    }
}

if ($store_target) {
    // check if folder is subscribed
    if ($RCMAIL->storage->folder_exists($store_target, true)) {
        $store_folder = true;
    }
    // folder may be existing but not subscribed (#1485241)
    else if (!$RCMAIL->storage->folder_exists($store_target)) {
        $store_folder = $RCMAIL->storage->create_folder($store_target, true);
    }
    else if ($RCMAIL->storage->subscribe($store_target)) {
        $store_folder = true;
    }

    // append message to sent box
    if ($store_folder) {
        // message body in file
        if ($mailbody_file || $MAIL_MIME->getParam('delay_file_io')) {
            $headers = $MAIL_MIME->txtHeaders();

            // file already created
            if ($mailbody_file) {
                $msg = $mailbody_file;
            }
            else {
                $temp_dir      = $RCMAIL->config->get('temp_dir');
                $mailbody_file = tempnam($temp_dir, 'rcmMsg');

                if (!PEAR::isError($msg = $MAIL_MIME->saveMessageBody($mailbody_file))) {
                    $msg = $mailbody_file;
                }
            }
        }
        else {
            $msg     = $MAIL_MIME->getMessage();
            $headers = '';
        }

        if (PEAR::isError($msg)) {
            rcube::raise_error(array('code' => 650, 'type' => 'php',
                'file' => __FILE__, 'line' => __LINE__,
                'message' => "Could not create message: ".$msg->getMessage()),
                true, false);
        }
        else {
            $saved = $RCMAIL->storage->save_message($store_target, $msg, $headers,
                $mailbody_file ? true : false, array('SEEN'));
        }

        if ($mailbody_file) {
            unlink($mailbody_file);
            $mailbody_file = null;
        }
    }

    // raise error if saving failed
    if (!$saved) {
        rcube::raise_error(array('code' => 800, 'type' => 'imap',
            'file' => __FILE__, 'line' => __LINE__,
            'message' => "Could not save message in $store_target"), true, false);

        if ($savedraft) {
            $OUTPUT->show_message('errorsaving', 'error');
            // start the auto-save timer again
            $OUTPUT->command('auto_save_start');
            $OUTPUT->send('iframe');
        }
    }

    // delete previous saved draft
    if ($saved && ($old_id = rcube_utils::get_input_value('_draft_saveid', rcube_utils::INPUT_POST))) {
        $deleted = $RCMAIL->storage->delete_message($old_id, $drafts_mbox);

        // raise error if deletion of old draft failed
        if (!$deleted) {
            rcube::raise_error(array('code' => 800, 'type' => 'imap',
                'file' => __FILE__, 'line' => __LINE__,
                'message' => "Could not delete message from $drafts_mbox"), true, false);
        }
    }
}

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,268
Re: can't save sent mail
« Reply #5 on: February 27, 2015, 02:24:38 AM »
Config options are defined in the Roundcube config files. Normally [rc root]/config/defaults.inc.php in here you should find no_save_sent_messages set to false - this is the default. Then you should have another file [rc root]/config/config.inc.php check for no_save_sent_messages in there and see if the default is overridden.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline heinohund

  • Jr. Member
  • **
  • Posts: 17
Re: can't save sent mail
« Reply #6 on: March 01, 2015, 10:03:01 AM »
It is set to "false"


Offline bratze

  • Newbie
  • *
  • Posts: 7
Re: can't save sent mail
« Reply #7 on: March 09, 2015, 04:18:26 AM »
Dear JohnDoh,


First of all, thanks for caring!

Please could you have a look in your config at what the `no_save_sent_messages`option is set to. And also on the compose screen in the composition options (where the options are to switch between html/plain text ect) there is one called "Save sent message in".
In my case ...
  • 'no_save_sent_messages' is set to "false" in defaults.inc.php
  • there is no overriding 'no_save_sent_messages' in config.inc.php
  • folder "Sent" is clearly assigned at "Special Folders"
  • folder "Sent" is assigned at "Save sent message in" of the compose screen
  • switching off all plugins did not change issue
  • saving drafts (also autosaving of drafts) work fine, so user access rights to IMAP folders should basically be fine
  • issue is observed with a series of IMAP accounts, each by another provider/from another server
  • alternative Sent folder locations (same level as INBOX as well as subordinate to INBOX) also fail
  • autosaving sent mails with same IMAP accounts by a local Thunderbird installation works fine

Any further ideas, what I could look for?


Best regards
Bratze

« Last Edit: March 09, 2015, 04:22:11 AM by bratze »

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,268
Re: can't save sent mail
« Reply #8 on: March 10, 2015, 03:47:40 AM »
i'm not sure. may be add some logging into the section of code you posted before from program/steps/mail/sendmail.inc to make sure $store_target and $store_folder are being set. and also try enabling imap_debug to see if a save attempt is actually made and the response from the server.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline bratze

  • Newbie
  • *
  • Posts: 7
Re: can't save sent mail
« Reply #9 on: March 12, 2015, 08:56:32 AM »
Quote
program/steps/mail/sendmail.inc to make sure $store_target and $store_folder are being set

It is set ...
Code: [Select]
// pass headers to message object
$MAIL_MIME->headers($headers);

// Begin SMTP Delivery Block
if (!$savedraft) {
    // check 'From' address (identity may be incomplete)
    if (empty($from)) {
        $OUTPUT->show_message('nofromaddress', 'error');
        $OUTPUT->send('iframe');
    }

    // Handle Delivery Status Notification request
    $smtp_opts['dsn'] = $dsn_enabled;

    $sent = $RCMAIL->deliver_message($MAIL_MIME, $from, $mailto,
        $smtp_error, $mailbody_file, $smtp_opts);

    // return to compose page if sending failed
    if (!$sent) {
        // remove temp file
        if ($mailbody_file) {
            unlink($mailbody_file);
        }

        if ($smtp_error)
            $OUTPUT->show_message($smtp_error['label'], 'error', $smtp_error['vars']);
        else
            $OUTPUT->show_message('sendingfailed', 'error');
        $OUTPUT->send('iframe');
    }

    // save message sent time
    if ($sendmail_delay) {
        $RCMAIL->user->save_prefs(array('last_message_time' => time()));
    }

    // set replied/forwarded flag
    if ($COMPOSE['reply_uid']) {
        foreach (rcmail::get_uids($COMPOSE['reply_uid'], $COMPOSE['mailbox']) as $mbox => $uids) {
            $RCMAIL->storage->set_flag($uids, 'ANSWERED', $mbox);
        }
    }
    else if ($COMPOSE['forward_uid']) {
        foreach (rcmail::get_uids($COMPOSE['forward_uid'], $COMPOSE['mailbox']) as $mbox => $uids) {
            $RCMAIL->storage->set_flag($uids, 'FORWARDED', $mbox);
        }
    }
}

// Determine which folder to save message
if ($savedraft) {
    $store_target = $drafts_mbox;
}
else if (!$RCMAIL->config->get('no_save_sent_messages')) {
    if (isset($_POST['_store_target'])) {
        $store_target = rcube_utils::get_input_value('_store_target', rcube_utils::INPUT_POST);
    }
    else {
        $store_target = $RCMAIL->config->get('sent_mbox');
    }
}

if ($store_target) {
    // check if folder is subscribed
    if ($RCMAIL->storage->folder_exists($store_target, true)) {
        $store_folder = true;
    }
    // folder may be existing but not subscribed (#1485241)
    else if (!$RCMAIL->storage->folder_exists($store_target)) {
        $store_folder = $RCMAIL->storage->create_folder($store_target, true);
    }
    else if ($RCMAIL->storage->subscribe($store_target)) {
        $store_folder = true;
    }

    // append message to sent box
    if ($store_folder) {
        // message body in file
        if ($mailbody_file || $MAIL_MIME->getParam('delay_file_io')) {
            $headers = $MAIL_MIME->txtHeaders();

            // file already created
            if ($mailbody_file) {
                $msg = $mailbody_file;
            }
            else {
                $temp_dir      = $RCMAIL->config->get('temp_dir');
                $mailbody_file = tempnam($temp_dir, 'rcmMsg');

                if (!PEAR::isError($msg = $MAIL_MIME->saveMessageBody($mailbody_file))) {
                    $msg = $mailbody_file;
                }
            }
        }
        else {
            $msg     = $MAIL_MIME->getMessage();
            $headers = '';
        }

        if (PEAR::isError($msg)) {
            rcube::raise_error(array('code' => 650, 'type' => 'php',
                'file' => __FILE__, 'line' => __LINE__,
                'message' => "Could not create message: ".$msg->getMessage()),
                true, false);
        }
        else {
            $saved = $RCMAIL->storage->save_message($store_target, $msg, $headers,
                $mailbody_file ? true : false, array('SEEN'));
        }

        if ($mailbody_file) {
            unlink($mailbody_file);
            $mailbody_file = null;
        }
    }

    // raise error if saving failed
    if (!$saved) {
        rcube::raise_error(array('code' => 800, 'type' => 'imap',
            'file' => __FILE__, 'line' => __LINE__,
            'message' => "Could not save message in $store_target"), true, false);

        if ($savedraft) {
            $OUTPUT->show_message('errorsaving', 'error');
            // start the auto-save timer again
            $OUTPUT->command('auto_save_start');
            $OUTPUT->send('iframe');
        }
    }

    // delete previous saved draft
    if ($saved && ($old_id = rcube_utils::get_input_value('_draft_saveid', rcube_utils::INPUT_POST))) {
        $deleted = $RCMAIL->storage->delete_message($old_id, $drafts_mbox);

        // raise error if deletion of old draft failed
        if (!$deleted) {
            rcube::raise_error(array('code' => 800, 'type' => 'imap',
                'file' => __FILE__, 'line' => __LINE__,
                'message' => "Could not delete message from $drafts_mbox"), true, false);
        }
    }
}
// remove temp file
else if ($mailbody_file) {
    unlink($mailbody_file);
}

I have activated debug-logs for IMAP and SMTP now, and will check at the weekend for any findings.

But  :o ... I by chance found something.
For another reason, I changed "dbhost" value from localhost to 127.0.0.1, This caused other troubles and I had to switch back to localhost, ... but with the dbhost=127.0.0.1 setup the autosaving of sent files worked.

WTF ...


Bratze

Offline heinohund

  • Jr. Member
  • **
  • Posts: 17
Re: can't save sent mail
« Reply #10 on: March 12, 2015, 05:21:54 PM »
This is my Imap log

Code: [Select]
[12-Mar-2015 21:20:22 +0000]: <c9d4db35> IMAP Error: Could not save message in INBOX.Sent in /mounted-storage/home61c/sub001/sc38369-GDQX/jegerglad.dk/rc/program/steps/mail/sendmail.inc on line 634 (POST /rc/?_task=mail&_unlock=loading1426195223394&_lang=da&_framed=1?_task=mail&_action=send)

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,268
Re: can't save sent mail
« Reply #11 on: March 14, 2015, 04:18:17 AM »
@heinohund: That is not an entry from any IMAP log file. It looks like an entry from the pho or httpd error log. If you turn on IMAP debug in Roundcube then you might get more detail from that or in you IMAP server log file.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline heinohund

  • Jr. Member
  • **
  • Posts: 17
Re: can't save sent mail
« Reply #12 on: March 14, 2015, 11:01:22 AM »
IMAP-log:

Code: [Select]
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] S: * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE NAMESPACE +CHILDREN STARTTLS AUTH=PLAIN] Dovecot ready.
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] C: A0001 ID ("name" "Roundcube" "version" "1.1.0" "php" "5.4.42-servage17" "os" "Linux" "command" "/?_task=mail&_unlock=loading1426345049000&_lang=da&_framed=1")
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] S: * ID NIL
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] S: A0001 OK ID completed.
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] C: A0002 AUTHENTICATE PLAIN ****** [41]
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] S: A0002 OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE QUOTA IDLE ACL ACL2=UNION STARTTLS] LOGIN Ok.
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] C: A0003 LSUB "" INBOX.Sent
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] S: * LSUB (\HasNoChildren) "." "INBOX.Sent"
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] S: A0003 OK LSUB completed
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] C: A0004 LIST "" INBOX.Sent
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] S: * LIST (\HasNoChildren) "." "INBOX.Sent"
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] S: A0004 OK LIST completed
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] C: A0005 APPEND INBOX.Sent (\Seen) {1014+}
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] C: MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="=_9179db76f17f54ee4740256bd8ac92c2"
Date: Sat, 14 Mar 2015 15:57:26 +0100
From: Henrik Karmark <henrik@karmark.com>
To: Henrik Karmark <henrik@karmark.com>
Subject: =?UTF-8?Q?pr=C3=B8ve?=
Message-ID: <2660f670e457a92bcb96559403725f29@karmark.com>
X-Sender: henrik@karmark.com
User-Agent: Roundcube Webmail/1.1.0

--=_9179db76f17f54ee4740256bd8ac92c2
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII

 

--

Venlig hilsen
Henrik Karmark

 
--=_9179db76f17f54ee4740256bd8ac92c2
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=
=3DUTF-8" /></head><body style=3D'font-size: 10pt; font-family: Verdana,Gen=
eva,sans-serif'>
<p>&nbsp;</p>
<div>-- <br />
<pre><br />Venlig hilsen
Henrik Karmark</pre>
</div>
<p>&nbsp;</p>
</body></html>

--=_9179db76f17f54ee4740256bd8ac92c2--
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] C:
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] S: A0005 NO Error in IMAP command received by server.
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] C: A0006 LOGOUT
[14-Mar-2015 14:57:27 +0000]: <59961be4> [9C62] S: MIME-Version: NO Error in IMAP command received by server.

Offline bratze

  • Newbie
  • *
  • Posts: 7
Re: can't save sent mail
« Reply #13 on: April 08, 2015, 06:04:49 AM »
I got it!

After switching off the plugin for multiple SMTP identities, the saving to sent folder instantly worked again for all accounts. Hoah!

Interestingly, the multiple SMTP outgoing identities are still there, even with having the multiple SMTP identities plugin removed.


Best regards
Bratze

Offline heinohund

  • Jr. Member
  • **
  • Posts: 17
Re: can't save sent mail
« Reply #14 on: April 09, 2015, 10:24:59 AM »
Nice!

Where do i switch it off?

Br
Henrik