@@ -578,6 +578,124 @@ function imap_headerinfo($imap_stream, int $msg_number, int $fromlength = 0, int
578578}
579579
580580
581+ /**
582+ * Create a MIME message based on the given envelope
583+ * and body sections.
584+ *
585+ * @param array $envelope An associative array of header fields. Valid keys are: "remail",
586+ * "return_path", "date", "from", "reply_to", "in_reply_to", "subject",
587+ * "to", "cc", "bcc" and "message_id", which set the respective message headers to the given string.
588+ * To set additional headers, the key "custom_headers" is supported, which expects
589+ * an array of those headers, e.g. ["User-Agent: My Mail Client"].
590+ * @param array $body An indexed array of bodies. The first body is the main body of the message;
591+ * only if it has a type of TYPEMULTIPART, further bodies
592+ * are processed; these bodies constitute the bodies of the parts.
593+ *
594+ *
595+ * Body Array Structure
596+ *
597+ *
598+ *
599+ * Key
600+ * Type
601+ * Description
602+ *
603+ *
604+ *
605+ *
606+ * type
607+ * int
608+ *
609+ * The MIME type.
610+ * One of TYPETEXT (default), TYPEMULTIPART,
611+ * TYPEMESSAGE, TYPEAPPLICATION,
612+ * TYPEAUDIO, TYPEIMAGE,
613+ * TYPEMODEL or TYPEOTHER.
614+ *
615+ *
616+ *
617+ * encoding
618+ * int
619+ *
620+ * The Content-Transfer-Encoding.
621+ * One of ENC7BIT (default), ENC8BIT,
622+ * ENCBINARY, ENCBASE64,
623+ * ENCQUOTEDPRINTABLE or ENCOTHER.
624+ *
625+ *
626+ *
627+ * charset
628+ * string
629+ * The charset parameter of the MIME type.
630+ *
631+ *
632+ * type.parameters
633+ * array
634+ * An associative array of Content-Type parameter names and their values.
635+ *
636+ *
637+ * subtype
638+ * string
639+ * The MIME subtype, e.g. 'jpeg' for TYPEIMAGE.
640+ *
641+ *
642+ * id
643+ * string
644+ * The Content-ID.
645+ *
646+ *
647+ * description
648+ * string
649+ * The Content-Description.
650+ *
651+ *
652+ * disposition.type
653+ * string
654+ * The Content-Disposition, e.g. 'attachment'.
655+ *
656+ *
657+ * disposition
658+ * array
659+ * An associative array of Content-Disposition parameter names and values.
660+ *
661+ *
662+ * contents.data
663+ * string
664+ * The payload.
665+ *
666+ *
667+ * lines
668+ * int
669+ * The size of the payload in lines.
670+ *
671+ *
672+ * bytes
673+ * int
674+ * The size of the payload in bytes.
675+ *
676+ *
677+ * md5
678+ * string
679+ * The MD5 checksum of the payload.
680+ *
681+ *
682+ *
683+ *
684+ * @return string Returns the MIME message as string.
685+ * @throws ImapException
686+ *
687+ */
688+ function imap_mail_compose (array $ envelope , array $ body ): string
689+ {
690+ error_clear_last ();
691+ $ result = \imap_mail_compose ($ envelope , $ body );
692+ if ($ result === false ) {
693+ throw ImapException::createFromPhpError ();
694+ }
695+ return $ result ;
696+ }
697+
698+
581699/**
582700 * Copies mail messages specified by msglist
583701 * to specified mailbox.
@@ -1141,6 +1259,83 @@ function imap_setflag_full($imap_stream, string $sequence, string $flag, int $op
11411259}
11421260
11431261
1262+ /**
1263+ * Gets and sorts message numbers by the given parameters.
1264+ *
1265+ * @param resource $imap_stream An IMAP stream returned by
1266+ * imap_open.
1267+ * @param int $criteria Criteria can be one (and only one) of the following:
1268+ *
1269+ *
1270+ *
1271+ * SORTDATE - message Date
1272+ *
1273+ *
1274+ *
1275+ *
1276+ * SORTARRIVAL - arrival date
1277+ *
1278+ *
1279+ *
1280+ *
1281+ * SORTFROM - mailbox in first From address
1282+ *
1283+ *
1284+ *
1285+ *
1286+ * SORTSUBJECT - message subject
1287+ *
1288+ *
1289+ *
1290+ *
1291+ * SORTTO - mailbox in first To address
1292+ *
1293+ *
1294+ *
1295+ *
1296+ * SORTCC - mailbox in first cc address
1297+ *
1298+ *
1299+ *
1300+ *
1301+ * SORTSIZE - size of message in octets
1302+ *
1303+ *
1304+ *
1305+ * @param int $reverse Set this to 1 for reverse sorting
1306+ * @param int $options The options are a bitmask of one or more of the
1307+ * following:
1308+ *
1309+ *
1310+ *
1311+ * SE_UID - Return UIDs instead of sequence numbers
1312+ *
1313+ *
1314+ *
1315+ *
1316+ * SE_NOPREFETCH - Don't prefetch searched messages
1317+ *
1318+ *
1319+ *
1320+ * @param string $search_criteria IMAP2-format search criteria string. For details see
1321+ * imap_search.
1322+ * @param string $charset MIME character set to use when sorting strings.
1323+ * @return array Returns an array of message numbers sorted by the given
1324+ * parameters.
1325+ * @throws ImapException
1326+ *
1327+ */
1328+ function imap_sort ($ imap_stream , int $ criteria , int $ reverse , int $ options = 0 , string $ search_criteria = null , string $ charset = null ): array
1329+ {
1330+ error_clear_last ();
1331+ $ result = \imap_sort ($ imap_stream , $ criteria , $ reverse , $ options , $ search_criteria , $ charset );
1332+ if ($ result === false ) {
1333+ throw ImapException::createFromPhpError ();
1334+ }
1335+ return $ result ;
1336+ }
1337+
1338+
11441339/**
11451340 * Subscribe to a new mailbox.
11461341 *
0 commit comments