本文整理汇总了PHP中Swift_Mime_Message::toByteStream方法的典型用法代码示例。如果您正苦于以下问题:PHP Swift_Mime_Message::toByteStream方法的具体用法?PHP Swift_Mime_Message::toByteStream怎么用?PHP Swift_Mime_Message::toByteStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Swift_Mime_Message
的用法示例。
在下文中一共展示了Swift_Mime_Message::toByteStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: streamMessage
/** Stream the contents of the message over the buffer */
protected function streamMessage(Swift_Mime_Message $message)
{
$this->buffer->setWriteTranslations(array("\r\n." => "\r\n.."));
try {
$message->toByteStream($this->buffer);
$this->buffer->flushBuffers();
} catch (Swift_TransportException $e) {
$this->throwException($e);
}
$this->buffer->setWriteTranslations(array());
$this->executeCommand("\r\n.\r\n", array(250));
}
示例2: _doSend
/**
* do send through the API
*
* @param Swift_Mime_Message $message
* @param string[] &$failedRecipients to collect failures by-reference
* @return AWSResponse
*/
protected function _doSend(Swift_Mime_Message $message, &$failedRecipients = null)
{
$date = date('D, j F Y H:i:s O');
if (function_exists('hash_hmac') and in_array('sha1', hash_algos())) {
$hmac = base64_encode(hash_hmac('sha1', $date, $this->AWSSecretKey, true));
} else {
$hmac = $this->calculate_RFC2104HMAC($date, $this->AWSSecretKey);
}
$auth = "AWS3-HTTPS AWSAccessKeyId=" . $this->AWSAccessKeyId . ", Algorithm=HmacSHA1, Signature=" . $hmac;
$host = parse_url($this->endpoint, PHP_URL_HOST);
$path = parse_url($this->endpoint, PHP_URL_PATH);
$fp = fsockopen('ssl://' . $host, 443, $errno, $errstr, 30);
if (!$fp) {
throw new AWSConnectionError("{$errstr} ({$errno})");
}
$socket = new ChunkedTransferSocket($fp, $host, $path);
$socket->header("Date", $date);
$socket->header("X-Amzn-Authorization", $auth);
$socket->write("Action=SendRawEmail&RawMessage.Data=");
$ais = new Swift_AWSInputByteStream($socket);
$message->toByteStream($ais);
$ais->flushBuffers();
$result = $socket->read();
return $result;
}