/**
  * {@inheritdoc}
  */
 protected function format(MessageInterface $message)
 {
     // We should split up the ServerToken on : to get username and password
     list($username, $password) = explode(':', $this->getServerToken());
     $from = $this->normalizeIdentity($message->getFrom());
     $toEmails = array();
     $toNames = array();
     foreach ($this->normalizeIdentities($message->getTo()) as $recipient) {
         $toEmails[] = $recipient->getEmail();
         $toNames[] = $recipient->getName();
     }
     $bccEmails = array();
     foreach ($this->normalizeIdentities($message->getBcc()) as $recipient) {
         $bccEmails[] = $recipient->getEmail();
     }
     $smtpApi = array();
     if ($message instanceof TaggableInterface) {
         $smtpApi['category'] = (array) $message->getTag();
     }
     if ($message instanceof MetadataAwareInterface) {
         $smtpApi['unique_args'] = array_filter($message->getMetadata());
     }
     $inline = array();
     if ($message instanceof AttachmentsAwareInterface) {
         // Store inline attachment references
         list(, $inline) = $this->processAttachments($message->getAttachments());
     }
     $parameters = array('api_user' => $username, 'api_key' => $password, 'to' => $toEmails, 'toname' => $toNames, 'from' => $from->getEmail(), 'fromname' => $from->getName(), 'subject' => $message->getSubject(), 'text' => $message->getText(), 'html' => $message->getHtml(), 'bcc' => $bccEmails, 'replyto' => $message->getReplyTo(), 'headers' => json_encode($message->getHeaders()), 'content' => $inline);
     if ($smtpApi) {
         $parameters['x-smtpapi'] = json_encode(array_filter($smtpApi));
     }
     return http_build_query(array_filter($parameters));
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 protected function format(MessageInterface $message)
 {
     // We should split up the ServerToken on : to get username and password
     list($username, $password) = explode(':', $this->getServerToken());
     $parameters = array('api_user' => $username, 'api_key' => $password, 'to' => $message->getTo(), 'from' => $message->getFrom(), 'subject' => $message->getSubject(), 'text' => $message->getText(), 'html' => $message->getHtml(), 'bcc' => $message->getBcc(), 'replyto' => $message->getReplyTo(), 'headers' => json_encode($message->getHeaders()));
     return http_build_query(array_filter($parameters));
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 protected function format(MessageInterface $message)
 {
     // Custom headers should be prefixed with h:X-My-Header
     $headers = $message->getHeaders();
     array_walk($headers, function (&$value, &$key) {
         $key = 'h:' . $key;
     });
     $parameters = array('from' => $message->getFrom(), 'to' => $message->getTo(), 'subject' => $message->getSubject(), 'text' => $message->getText(), 'html' => $message->getHtml(), 'cc' => $message->getCc(), 'bcc' => $message->getBcc());
     return http_build_query(array_filter(array_merge($headers, $parameters)));
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 protected function format(MessageInterface $message)
 {
     $headers = array_filter(array_merge($message->getHeaders(), array('Reply-To' => $message->getReplyTo())));
     $to = array(array('email' => $message->getTo()));
     if ($message->getCc()) {
         $cc = explode(',', $message->getCc());
         foreach ($cc as $email) {
             $to[] = array('email' => $email);
         }
     }
     $parameters = array('key' => $this->getServerToken(), 'message' => array_filter(array('from_email' => $message->getFrom(), 'to' => $to, 'subject' => $message->getSubject(), 'headers' => $headers, 'bcc_address' => $message->getBcc(), 'text' => $message->getText(), 'html' => $message->getHtml())));
     return json_encode($parameters);
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 protected function format(MessageInterface $message)
 {
     $headers = array();
     foreach ($message->getHeaders() as $name => $value) {
         $headers[] = array('Name' => $name, 'Value' => $value);
     }
     $parameters = array('From' => $this->buildIdentityString($message->getFrom()), 'To' => $this->buildIdentityString($message->getTo()), 'Subject' => $message->getSubject(), 'Headers' => $headers, 'TextBody' => $message->getText(), 'HtmlBody' => $message->getHtml(), 'ReplyTo' => $message->getReplyTo());
     if ($message instanceof TaggableInterface) {
         $tag = $message->getTag();
         if (is_array($tag)) {
             $tag = reset($tag);
         }
         $parameters['Tag'] = $tag;
     }
     return json_encode(array_filter($parameters));
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 protected function format(MessageInterface $message)
 {
     $headers = array_filter(array_merge($message->getHeaders(), array('Reply-To' => $message->getReplyTo())));
     $from = $this->normalizeIdentity($message->getFrom());
     $to = array();
     foreach ($this->normalizeIdentities($message->getTo()) as $recipient) {
         $to[] = array('email' => $recipient->getEmail(), 'name' => $recipient->getName());
     }
     $tags = array();
     if ($message instanceof TaggableInterface) {
         $tags = (array) $message->getTag();
     }
     $metadata = array();
     if ($message instanceof MetadataAwareInterface) {
         $metadata = array_filter($message->getMetadata());
     }
     $parameters = array('key' => $this->getServerToken(), 'message' => array_filter(array('from_email' => $from->getEmail(), 'from_name' => $from->getName(), 'to' => $to, 'subject' => $message->getSubject(), 'headers' => $headers, 'text' => $message->getText(), 'html' => $message->getHtml(), 'tags' => $tags, 'metadata' => $metadata)));
     return json_encode($parameters);
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 protected function format(MessageInterface $message)
 {
     // Custom headers should be prefixed with h:X-My-Header
     $headers = array_merge($message->getHeaders(), array('Reply-To' => $message->getReplyTo()));
     array_walk($headers, function (&$value, &$key) {
         $key = 'h:' . $key;
     });
     $parameters = array('from' => $this->buildIdentityString($message->getFrom()), 'to' => $this->buildIdentityString($message->getTo()), 'subject' => $message->getSubject(), 'text' => $message->getText(), 'html' => $message->getHtml(), 'cc' => $this->buildIdentityString($message->getCc()), 'bcc' => $this->buildIdentityString($message->getBcc()));
     if ($message instanceof TaggableInterface) {
         $parameters['o:tag'] = (array) $message->getTag();
     }
     $metadata = array();
     if ($message instanceof MetadataAwareInterface) {
         $metadata = array_filter($message->getMetadata());
         // Custom variables should be prefixed with v:my_var
         array_walk($metadata, function (&$value, &$key) {
             $key = 'v:' . $key;
         });
     }
     return http_build_query(array_filter(array_merge($headers, $parameters, $metadata)));
 }
Example #8
0
 /**
  * {@inheritdoc}
  */
 protected function format(MessageInterface $message)
 {
     $parameters = array('email' => $message->getTo(), 'subject' => $message->getSubject(), 'from_email' => $message->getFrom(), 'tag' => $message->getTag(), 'content' => array('html' => $message->getHtml(), 'text' => $message->getText()));
     return json_encode(array('trigger_mail' => $parameters));
 }
 /**
  * {@inheritdoc}
  */
 protected function format(MessageInterface $message)
 {
     $parameters = array('apikey' => $this->getServerToken(), 'message' => array_filter(array('html' => $message->getHtml(), 'text' => $message->getText(), 'subject' => $message->getSubject(), 'to_email' => $message->getTo(), 'from_email' => $message->getFrom())));
     return http_build_query($parameters);
 }
Example #10
0
 /**
  * {@inheritdoc}
  */
 protected function format(MessageInterface $message)
 {
     $parameters = array_filter(array('From' => $message->getFrom(), 'To' => $message->getTo(), 'Subject' => $message->getSubject(), 'Headers' => $message->getHeaders(), 'TextBody' => $message->getText(), 'HtmlBody' => $message->getHtml()));
     return json_encode($parameters);
 }