/** 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)); }
/** * 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; }