Documentation

SendMessage

Description and parameters

mixed
CPosting::SendMessage(
int ID,
int timeout = 0, int maxcount = 0,< bool check_charset = false, );

Non-static method sends a message posting in email campaign to URLs, specified in the table b_posting_email with corresponding posting ID. With the following statuses updated:

  • Y - not yet sent
  • N - sent
  • Е - with errors
Sent messages with the status "Sent successfully" are not recurring. However, if a message has the status "Sent partially", the message is sent to the remaining URLs.

First, an attempt to block the posting is performed (see. CPosting::Lock). When blocking has failed, dispatch is deemed as partial and returns "CONTINUE". Next, email body is generated for dispatch and cycle of sending to subscriber URLs is executed using the function bxmail.

Event handlers BeforePostingSendMail are called in the mode " Send a message personally" before calling [link= 6658023]bxmail[/link].

The cycle of dispatch within URL queue is performed until marked as successful or failed dispatch.

Posted message is now unlocked (see. CPosting::UnLock).

Parameters

ParameterDescription Available from version
ID Post ID.
timeout Maximum sending period in seconds. In case of timeout, the method terminates and sets the Partially sent status of the message. The parameter is meaningful only for dispatch method Send a message personally. If $timeout=0, the sending operation is not fragmented.
maxcount Maximum number of messages to be sent. If the number of messages sent exceeds this value, the method terminates and sets the issue status Partially sent. This parameter is only meaningful if used with the sending option Send personally to each recipient. If this value is 0, the sending is always performed within a single step.
check_charset Matches the current encoding (constant LANG_CHARSET) with the encoding of the post message. In case such encoding don't match, returns "CONTINUE". It used when sending messages via agents. Comparison is case-insensitive for encodings.

Return values

The method returns true on success, or false otherwise. If some of the messages could not be sent, the method returns "CONTINUE". In case of an error, the class variable LAST_ERROR contains the error description.

See also

  • bxmail

  • Examples

    <?
    if($action=="send" && $ID>0):
    if(($res = $cPosting->SendMessage($ID, COption::GetOptionString("subscribe", "posting_interval"))) !== false):
    if($res === "CONTINUE"):
    ?>
    <script language="JavaScript" type="text/javascript">
    <!--
    function DoNext(){window.location="<?echo $APPLICATION->GetCurPage()."?ID=".$ID."&action=send&lang=".LANG."&rnd=".rand();?>";}
    setTimeout('DoNext()', 2500);
    //-->
    </script>
    <?
    else:
    $strOk = "Sent successfully.";
    endif; //$res === "CONTINUE"
    endif; //$cPosting->SendMessage
    $strError .= $cPosting->LAST_ERROR;
    endif; //$action=="send"


    © «Bitrix24», 2001-2024