Skip to content

delete method not working on Gmail #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
EthraZa opened this issue Feb 12, 2021 · 6 comments
Closed

delete method not working on Gmail #106

EthraZa opened this issue Feb 12, 2021 · 6 comments
Labels
enhancement New feature or request Gmail Related to Google mail / GMAIL

Comments

@EthraZa
Copy link

EthraZa commented Feb 12, 2021

At least on Gmail, I can't get delete to work. It returns true, but does nothing.
Manually set 'Deleted' flag on a message does nothing as well.

Am I noobing here?

@EthraZa
Copy link
Author

EthraZa commented Feb 17, 2021

Here is a very good explanation on the why the "\Deleted" flag does nothing on Gmail:
http://yz.mit.edu/wp/gmail-and-imap/

Resume: On Gmail, add "\Deleted" flag is not enough, you need to move the message to "[Gmail]/Trash" as well.

The main problem to me now is that if I move the message to Trash, I get hit by #105 problem.

@EthraZa EthraZa changed the title delete method not working delete method not working on Gmail Feb 17, 2021
@Webklex
Copy link
Owner

Webklex commented Feb 17, 2021

Hi @EthraZa ,
thanks for the followup. I'll add it to the documentation. Any idea on where it could fit?

Ref.:

Best regards,

@EthraZa
Copy link
Author

EthraZa commented Feb 17, 2021

Do you have a reliable way to detect when you are connected to Gmail?
Use the host is not reliable because people can use a cname DNS entry.

Edit:
Humm, I guess the delete method can check if the "[Gmail]/Trash" or "[Gmail]/Bin" exists, if so, move the message there.

@Webklex
Copy link
Owner

Webklex commented Feb 17, 2021

Yeah I was wondering about this as well..
Perhaps $client->getConnection()->getCapabilities() has some interesting information?

Best regards,

@EthraZa
Copy link
Author

EthraZa commented Feb 17, 2021

Also taking a look at Gmail IMAP Extensions

Maybe the delete method can look something like this:

public function delete($expunge = true, $trash_path = "[Gmail]/Trash", $force_move = false) {
        $status = $this->setFlag("Deleted");

        if($force_move || in_array("X-GM-EXT-1", $this->client->getConnection()->getCapabilities())) {
                $status = $this->move($trash_path);
        }

        if($expunge) $this->client->expunge();

        $event = $this->getEvent("message", "deleted");
        $event::dispatch($this);

        return $status;
}

What do you think?

@Webklex Webklex added the enhancement New feature or request label Feb 24, 2021
@Webklex Webklex added the Gmail Related to Google mail / GMAIL label Nov 3, 2021
@Webklex
Copy link
Owner

Webklex commented Nov 4, 2021

Hi @EthraZa ,
many thanks for your suggestion. As of v3.0.0-alpha you can now use the Message::delete() method as suggested by you.
There is however one difference. If you don't provide a $trash_path, the default common folder path from options.common_folders.trash gets used instead.

Best regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Gmail Related to Google mail / GMAIL
Projects
None yet
Development

No branches or pull requests

2 participants