Beispiel #1
0
 /**
  *
  * @param Envelope $envelope
  * @return PHPMailerOverride
  */
 protected function prepareMailer(Envelope $envelope)
 {
     $mail = new PHPMailerOverride(true);
     // the true param means it will throw exceptions on errors, which we need to catch
     $mail->Subject = FromUTF8::toIso88591Email($envelope->getSubject());
     $mail->CharSet = "utf-8";
     if ($envelope->isHtml()) {
         $mail->msgHTML($envelope->getBody());
     } else {
         $mail->Body = $envelope->getBodyText();
     }
     $mail->isSMTP();
     // telling the class to use SMTP
     if ($this->connection->getProtocol() != "smtp") {
         $mail->SMTPSecure = $this->connection->getProtocol();
         // ssl ou tls!
     }
     $replyTo = Util::decomposeEmail($envelope->getReplyTo());
     $mail->addReplyTo($replyTo["email"], $replyTo["name"]);
     // Define From email
     $from = Util::decomposeEmail($envelope->getFrom());
     $mail->setFrom($from["email"], $from["name"]);
     // Add Recipients
     foreach ((array) $envelope->getTo() as $toItem) {
         $to = Util::decomposeEmail($toItem);
         $mail->addAddress($to["email"], $to["name"]);
     }
     // Add Carbon Copy
     foreach ((array) $envelope->getCC() as $ccItem) {
         $cc = Util::decomposeEmail($ccItem);
         $mail->addCC($cc["email"], $cc["name"]);
     }
     // Add Blind Carbon Copy
     foreach ((array) $envelope->getBCC() as $bccItem) {
         $bcc = Util::decomposeEmail($bccItem);
         $mail->addBCC($bcc["email"], $bcc["name"]);
     }
     // Attachments
     foreach ((array) $envelope->getAttachments() as $name => $value) {
         $mail->addAttachment($value['content'], $name, 'base64', $value['content-type']);
     }
     return $mail;
 }
Beispiel #2
0
 public static function decomposeEmail($fullEmail)
 {
     $pat = "/[\"'](?P<name>[\\S\\s]*)[\"']\\s+<(?P<email>.*)>/";
     $pat2 = "/<(?P<email>.*)>/";
     $email = $fullEmail;
     $name = "";
     $parts = null;
     if (preg_match($pat, $fullEmail, $parts)) {
         if (array_key_exists("name", $parts)) {
             $name = FromUTF8::toIso88591Email($parts["name"]);
         }
         if (array_key_exists("email", $parts)) {
             $email = $parts["email"];
         }
     } else {
         if (preg_match($pat2, $fullEmail, $parts)) {
             if (array_key_exists("email", $parts)) {
                 $email = $parts["email"];
             }
         }
     }
     return array("email" => $email, "name" => $name);
 }
Beispiel #3
0
 /**
  *
  * @param string $name
  * @param ChartColumnType $type
  * @param string $data
  */
 public function addSerie($name, $type, $data)
 {
     $iter = $this->_Serie->getIterator();
     if ($iter->Count() == 0) {
         $this->_Serie->addField('data_0', "'{$name}'");
         foreach ($data as $item) {
             if ($type == ChartColumnType::String) {
                 $item = "'" . FromUTF8::removeAccent($item) . "'";
             } else {
                 if ($type == ChartColumnType::Number) {
                     $item = intval($item);
                 } else {
                     throw new UnexpectedValueException('Unexpected Chat Column Type - ' . $type);
                 }
             }
             $this->_Serie->appendRow();
             $this->_Serie->addField('data_0', $item);
         }
     } else {
         $serieCount = null;
         foreach ($iter as $row) {
             if ($serieCount == null) {
                 $serieCount = count($row->toArray());
                 $row->addField("data_{$serieCount}", "'{$name}'");
             } else {
                 if (count($data) > 0) {
                     if ($type == ChartColumnType::String) {
                         $item = "'" . array_shift($data) . "'";
                     } else {
                         if ($type == ChartColumnType::Number) {
                             $item = intval(array_shift($data));
                         } else {
                             throw new UnexpectedValueException('Unexpected Chat Column Type - ' . $type);
                         }
                     }
                     $row->addField("data_{$serieCount}", $item);
                 }
             }
         }
     }
 }
Beispiel #4
0
<?php

require "vendor/autoload.php";
$str = \ByJG\Convert\ToUTF8::fromHtmlEntities('Jo&atilde;o');
echo $str;
// João
$str2 = \ByJG\Convert\FromUTF8::toHtmlEntities('João');
echo $str2;
// Jo&atilde;o
$str3 = \ByJG\Convert\FromUTF8::removeAccent('João');
echo $str3;
// Joao
$str4 = \ByJG\Convert\FromUTF8::toIso88591Email('João');
echo $str4;
// =?iso-8859-1?Q?Jo=E3o?=