Что такое код imap_reopen

imap_reopen

��������

Reopens the specified stream to a new mailbox on an IMAP or NNTP server.

������ ����������

����� IMAP, ���������� �� imap_open() .

The mailbox name, see imap_open() for more information

Number of maximum connect attempts

������������ ��������

Returns TRUE if the stream is reopened, FALSE otherwise.

������ ���������

������ ��������
5.2.0 n_retries added

�������

������ #1 imap_reopen() example

imap_reopen

(PHP 4, PHP 5, PHP 7)

imap_reopen � ������������� ����� IMAP � ������ �����

��������

������������� ��������� ����� � ����� mailbox �� ������� IMAP ��� NNTP .

������ ����������

����� IMAP, ���������� �� imap_open() .

��� ��������� �����. ����� �������� ������� � ������� ��� ������� imap_open()

����������� ���������� ������� ����������

������������ ��������

���������� TRUE , ���� ����� ���������� � FALSE , ���� ���.

������ ���������

������ ��������
5.2.0 �������� �������� n_retries

�������

������ #1 ������ ������������� imap_reopen()

imap_reopen

Description

Reopens the specified stream to a new mailbox on an IMAP or NNTP server.

Parameters

An IMAP stream returned by imap_open .

The mailbox name, see imap_open for more information

Number of maximum connect attempts

Return Values

Returns TRUE if the stream is reopened, FALSE otherwise.

Changelog

Version Description
5.2.0 n_retries added

Examples

Example #1 imap_reopen example

imap_reopen

Description

Reopens the specified stream to a new mailbox on an IMAP or NNTP server.

Parameters

An IMAP stream returned by imap_open().

The mailbox name, see imap_open() for more information

The options are a bit mask with one or more of the following:

Number of maximum connect attempts

Return Values

Returns TRUE if the stream is reopened, FALSE otherwise.

Changelog

Version Description
5.2.0 n_retries added

Examples

Example #1 imap_reopen() example

��� ����� ��� imap_reopen

(PHP 3, PHP 4 , PHP 5)

imap_reopen — Reopen IMAP stream to new mailbox

Description bool imap_reopen ( resource imap_stream, string mailbox [, string options] )

This function reopens the specified stream to a new mailbox on an IMAP or NNTP server.

The options are a bit mask with one or more of the following:

OP_READONLY — Open mailbox read-only

OP_ANONYMOUS — Don’t use or update a .newsrc for news (NNTP only)

OP_HALFOPEN — For IMAP and NNTP names, open a connection but don’t open a mailbox.

CL_EXPUNGE — Expunge mailbox automatically upon mailbox close (see also imap_delete() and imap_expunge() )

Возвращает TRUE в случае успешного завершения или FALSE в случае возникновения ошибки.

The mailbox parameter is the full address, not just the folder name.

PHP imap_reopen no error returned

I have a script that connects to a mailbox. I’d like to check if I can connect to a folder that does not exist, but imap_reopen does not return errors.

Do you have an idea ?

1 Answer 1

Your statement ending with or die() is actually terminating execution before the if test against the return value in $test .

So just remove the or die() expression and your if ($test == false) will be evaluated. I’ll also use === here since it should return a true boolean:

You may alternatively use

Note about the PHP E_NOTICE emitted — if imap_reopen() emits that notice even when returning false , this is one instance in which you may want to use the @ operator for error suppression since you are correctly testing for errors in your if block.

Addendum after testing:

Documentation on imap_reopen() is slim and ambiguous stating its return as:

Returns TRUE if the stream is reopened, FALSE otherwise.

Some testing seems to imply that opening a non-existent mailbox is not considered an error state for which it returns false . When opening a non-existent mailbox on an otherwise valid stream, imap_reopen() will still return true but populate an error in imap_errors() .

So you may check count(imap_errors()) > 0 for errors after opening the faulty mailbox. Couple that with a true return check, in case imap_reopen() does return a true error state.

For example my testing produces results similar to:

You may work around this using logic to:

For what it’s worth, imap_open() exhibits the same behavior. Successfully connecting and establishing the stream (your variable $mbox ) is possible with a non-existent mailbox. The stream is created and valid, but imap_errors() will contain a message Mailbox doesn’t exist: .

��� ����� ��� imap_reopen

(PHP 3, PHP 4, PHP 5)

imap_reopen — Reopen IMAP stream to new mailbox

Description bool imap_reopen ( resource imap_stream, string mailbox [, int options] )

This function reopens the specified stream to a new mailbox on an IMAP or NNTP server.

The options are a bit mask with one or more of the following:

OP_READONLY — Open mailbox read-only

OP_ANONYMOUS — Don’t use or update a .newsrc for news (NNTP only)

OP_HALFOPEN — For IMAP and NNTP names, open a connection but don’t open a mailbox.

CL_EXPUNGE — Expunge mailbox automatically upon mailbox close (see also imap_delete() and imap_expunge() )

Returns TRUE on success or FALSE on failure.

��� ����� ��� imap_reopen

(PHP 3, PHP 4 , PHP 5)

imap_reopen — Reopen IMAP stream to new mailbox

Description bool imap_reopen ( resource imap_stream, string mailbox [, string options] )

This function reopens the specified stream to a new mailbox on an IMAP or NNTP server.

The options are a bit mask with one or more of the following:

OP_READONLY — Open mailbox read-only

OP_ANONYMOUS — Don’t use or update a .newsrc for news (NNTP only)

OP_HALFOPEN — For IMAP and NNTP names, open a connection but don’t open a mailbox.

CL_EXPUNGE — Expunge mailbox automatically upon mailbox close (see also imap_delete() and imap_expunge() )

Возвращает TRUE в случае успешного завершения или FALSE в случае возникновения ошибки.

The mailbox parameter is the full address, not just the folder name.

��� ����� ��� imap_reopen

imap_reopen — �������� ��������� IMAP-����� � ����� mailbox.

��������

int imap_reopen (int imap_stream, string mailbox [, string flags])

��� ������� �������� ��������� ����������������� ����� � ����� mailbox �� IMAP ��� NNTP-�������.

����� �������� ������� ������ � ����� ��� ����� ��������:


OP_READONLY — ������� mailbox ������ ��� ������

OP_ANONYMOUS — �� ������������ ��� �� ��������� .newsrc �� ����� (������ � NNTP)

OP_HALFOPEN — ��� ��� IMAP � NNTP, ��������� ����������, �� �� ��������� mailbox.

CL_EXPUNGE — ������� mailbox ������������� ����� ��� �������� (��. ����� imap_delete() � imap_expunge() ).

���������� TRUE ��� ������, FALSE ��� ������.

��� ����� ��� imap_reopen

imap_reopen — �������� ��������� IMAP-����� � ����� mailbox.

��������

int imap_reopen (int imap_stream, string mailbox [, string flags])

��� ������� �������� ��������� ����������������� ����� � ����� mailbox �� IMAP ��� NNTP-�������.

����� �������� ������� ������ � ����� ��� ����� ��������:


OP_READONLY — ������� mailbox ������ ��� ������

OP_ANONYMOUS — �� ������������ ��� �� ��������� .newsrc �� ����� (������ � NNTP)

OP_HALFOPEN — ��� ��� IMAP � NNTP, ��������� ����������, �� �� ��������� mailbox.

CL_EXPUNGE — ������� mailbox ������������� ����� ��� �������� (��. ����� imap_delete() � imap_expunge() ).

���������� TRUE ��� ������, FALSE ��� ������.

Илон Маск рекомендует:  Что такое код sector
Понравилась статья? Поделиться с друзьями:
Кодинг, CSS и SQL