Esempio n. 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;
 }
Esempio n. 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);
 }
Esempio n. 3
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?=