(PHP 4, PHP 5, PHP 7, PHP 8)
imap_renamemailbox — Rename an old mailbox to new mailbox
This function renames on old mailbox to new mailbox (see
imap_open()
for the format of
mbox
names).
imap
An IMAP\Connection instance.
from
The old mailbox name, see imap_open() for more information
Passing untrusted data to this parameter is insecure , unless imap.enable_insecure_rsh is disabled.
to
The new mailbox name, see imap_open() for more information
Passing untrusted data to this parameter is insecure , unless imap.enable_insecure_rsh is disabled.
| Versionen | Description |
|---|---|
| 8.1.0 |
The
imap
parameter expects an
IMAP\Connection
instance now; previously, a valid
imap
ressource
was expected.
|
Don't let "...string old_mbox, string new_mbox);" fool you. You have to add the server and port to the mailbox name also. So it would be something lique:
imap_renamemailbox($mailbox, "{localhost:143}$oldfolder", "{localhost:143}$newfolder")
Just thought I would point it out, it tooc me a while to figure it out.
Don't forguet that you can't be connected to the mailbox that you are going to rename (or delete).
If you have the following mailboxes:
IMBOX
IMBOX.Foo
...and want to rename "IMBOX.Foo" to "IMBOX.Bar" you have to be connected to "IMBOX":<?php
$mbox = imap_open('{imap.example.com}IMBOX', 'username', 'password');
imap_renamemailbox($mbox, '{imap.example.com}IMBOX.Foo', '{imap.example.com}IMBOX.Bar');
imap_close($mbox);
?>