PHP: Hypertext Preprocessor (original) (raw)
imap_mail_copy
(PHP 4, PHP 5, PHP 7, PHP 8)
imap_mail_copy — Copy specified messages to a mailbox
Description
Parameters
imap
An IMAP\Connection instance.
message_nums
message_nums
is a range not just message numbers (as described in » RFC2060).
mailbox
The mailbox name, see imap_open() for more information
flags
flags
is a bitmask of one or more of
[CP_UID](imap.constants.php#constant.cp-uid)
- the sequence numbers contain UIDS[CP_MOVE](imap.constants.php#constant.cp-move)
- Delete the messages from the current mailbox after copying. If this flag is set, the function behaves identically to imap_mail_move().
Return Values
Returns [true](reserved.constants.php#constant.true)
on success or [false](reserved.constants.php#constant.false)
on failure.
Changelog
Version | Description |
---|---|
8.1.0 | The imap parameter expects an IMAP\Connection instance now; previously, a valid imap resource was expected. |
Found A Problem?
marcus at names dot co dot uk ¶
22 years ago
`If you are having problems getting imap_mail_copy and imap_mail_move to work, check you have installed imap_devel (the imap development libraries) as well as imap (the imap daemon). Without it, PHP appears to configure correctly --with-imap, but some functions do not work.
It took me about 12 hours to figure this out!!
`
24 years ago
After much fooling around, imap_mail_copy did work for me. One thing you might want to check, if you are having problems, is the new mailbox name. Make sure it is just a folder name, e.g. INBOX.haha without the server part.
jigar dot dhaduk79 at gmail dot com ¶
9 years ago
`When we want to copy more than one mail, we can write '(string)' before msg_num. Like.. msgnum="1,2,3,4,5,6,7";<spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mi>o</mi><mi>p</mi><mi>y</mi><mo>=</mo><mi>i</mi><mi>m</mi><mi>a</mi><msub><mi>p</mi><mi>m</mi></msub><mi>a</mi><mi>i</mi><msub><mi>l</mi><mi>c</mi></msub><mi>o</mi><mi>p</mi><mi>y</mi><mostretchy="false">(</mo></mrow><annotationencoding="application/x−tex">copy=imapmailcopy(</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:0.625em;vertical−align:−0.1944em;"></span><spanclass="mordmathnormal">co</span><spanclass="mordmathnormal">p</span><spanclass="mordmathnormal"style="margin−right:0.03588em;">y</span><spanclass="mspace"style="margin−right:0.2778em;"></span><spanclass="mrel">=</span><spanclass="mspace"style="margin−right:0.2778em;"></span></span><spanclass="base"><spanclass="strut"style="height:1em;vertical−align:−0.25em;"></span><spanclass="mordmathnormal">ima</span><spanclass="mord"><spanclass="mordmathnormal">p</span><spanclass="msupsub"><spanclass="vlist−tvlist−t2"><spanclass="vlist−r"><spanclass="vlist"style="height:0.1514em;"><spanstyle="top:−2.55em;margin−left:0em;margin−right:0.05em;"><spanclass="pstrut"style="height:2.7em;"></span><spanclass="sizingreset−size6size3mtight"><spanclass="mordmathnormalmtight">m</span></span></span></span><spanclass="vlist−s"></span></span><spanclass="vlist−r"><spanclass="vlist"style="height:0.15em;"><span></span></span></span></span></span></span><spanclass="mordmathnormal">ai</span><spanclass="mord"><spanclass="mordmathnormal"style="margin−right:0.01968em;">l</span><spanclass="msupsub"><spanclass="vlist−tvlist−t2"><spanclass="vlist−r"><spanclass="vlist"style="height:0.1514em;"><spanstyle="top:−2.55em;margin−left:−0.0197em;margin−right:0.05em;"><spanclass="pstrut"style="height:2.7em;"></span><spanclass="sizingreset−size6size3mtight"><spanclass="mordmathnormalmtight">c</span></span></span></span><spanclass="vlist−s"></span></span><spanclass="vlist−r"><spanclass="vlist"style="height:0.15em;"><span></span></span></span></span></span></span><spanclass="mordmathnormal">o</span><spanclass="mordmathnormal">p</span><spanclass="mordmathnormal"style="margin−right:0.03588em;">y</span><spanclass="mopen">(</span></span></span></span>imapstream,(string)msg_num = "1,2,3,4,5,6,7"; <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mi>o</mi><mi>p</mi><mi>y</mi><mo>=</mo><mi>i</mi><mi>m</mi><mi>a</mi><msub><mi>p</mi><mi>m</mi></msub><mi>a</mi><mi>i</mi><msub><mi>l</mi><mi>c</mi></msub><mi>o</mi><mi>p</mi><mi>y</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">copy = imap_mail_copy(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.625em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">co</span><span class="mord mathnormal">p</span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">ima</span><span class="mord"><span class="mord mathnormal">p</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">m</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">ai</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">c</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">o</span><span class="mord mathnormal">p</span><span class="mord mathnormal" style="margin-right:0.03588em;">y</span><span class="mopen">(</span></span></span></span>imap_stream, (string) msgnum="1,2,3,4,5,6,7";<spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>c</mi><mi>o</mi><mi>p</mi><mi>y</mi><mo>=</mo><mi>i</mi><mi>m</mi><mi>a</mi><msub><mi>p</mi><mi>m</mi></msub><mi>a</mi><mi>i</mi><msub><mi>l</mi><mi>c</mi></msub><mi>o</mi><mi>p</mi><mi>y</mi><mostretchy="false">(</mo></mrow><annotationencoding="application/x−tex">copy=imapmailcopy(</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:0.625em;vertical−align:−0.1944em;"></span><spanclass="mordmathnormal">co</span><spanclass="mordmathnormal">p</span><spanclass="mordmathnormal"style="margin−right:0.03588em;">y</span><spanclass="mspace"style="margin−right:0.2778em;"></span><spanclass="mrel">=</span><spanclass="mspace"style="margin−right:0.2778em;"></span></span><spanclass="base"><spanclass="strut"style="height:1em;vertical−align:−0.25em;"></span><spanclass="mordmathnormal">ima</span><spanclass="mord"><spanclass="mordmathnormal">p</span><spanclass="msupsub"><spanclass="vlist−tvlist−t2"><spanclass="vlist−r"><spanclass="vlist"style="height:0.1514em;"><spanstyle="top:−2.55em;margin−left:0em;margin−right:0.05em;"><spanclass="pstrut"style="height:2.7em;"></span><spanclass="sizingreset−size6size3mtight"><spanclass="mordmathnormalmtight">m</span></span></span></span><spanclass="vlist−s"></span></span><spanclass="vlist−r"><spanclass="vlist"style="height:0.15em;"><span></span></span></span></span></span></span><spanclass="mordmathnormal">ai</span><spanclass="mord"><spanclass="mordmathnormal"style="margin−right:0.01968em;">l</span><spanclass="msupsub"><spanclass="vlist−tvlist−t2"><spanclass="vlist−r"><spanclass="vlist"style="height:0.1514em;"><spanstyle="top:−2.55em;margin−left:−0.0197em;margin−right:0.05em;"><spanclass="pstrut"style="height:2.7em;"></span><spanclass="sizingreset−size6size3mtight"><spanclass="mordmathnormalmtight">c</span></span></span></span><spanclass="vlist−s"></span></span><spanclass="vlist−r"><spanclass="vlist"style="height:0.15em;"><span></span></span></span></span></span></span><spanclass="mordmathnormal">o</span><spanclass="mordmathnormal">p</span><spanclass="mordmathnormal"style="margin−right:0.03588em;">y</span><spanclass="mopen">(</span></span></span></span>imapstream,(string)msg_num, '[Gmail]/Important', CP_UID);
`