当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPMailer::setLanguage方法代码示例

本文整理汇总了PHP中PHPMailer::setLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPMailer::setLanguage方法的具体用法?PHP PHPMailer::setLanguage怎么用?PHP PHPMailer::setLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPMailer的用法示例。


在下文中一共展示了PHPMailer::setLanguage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initMailFromSet

 /**
  * Inner mailer initialization from set variables
  *
  * @return void
  */
 protected function initMailFromSet()
 {
     $this->mail->setLanguage($this->get('langLocale'), $this->get('langPath'));
     $this->mail->CharSet = $this->get('charset');
     $this->mail->From = $this->get('from');
     $this->mail->FromName = $this->get('fromName') ?: $this->get('from');
     $this->mail->Sender = $this->get('from');
     $this->mail->clearAllRecipients();
     $this->mail->clearAttachments();
     $this->mail->clearCustomHeaders();
     $emails = explode(static::MAIL_SEPARATOR, $this->get('to'));
     foreach ($emails as $email) {
         $this->mail->addAddress($email);
     }
     $this->mail->Subject = $this->get('subject');
     $this->mail->AltBody = $this->createAltBody($this->get('body'));
     $this->mail->Body = $this->get('body');
     // add custom headers
     foreach ($this->get('customHeaders') as $header) {
         $this->mail->addCustomHeader($header);
     }
     if (is_array($this->get('images'))) {
         foreach ($this->get('images') as $image) {
             // Append to $attachment array
             $this->mail->addEmbeddedImage($image['path'], $image['name'] . '@mail.lc', $image['name'], 'base64', $image['mime']);
         }
     }
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:33,代码来源:Mailer.php

示例2: testTranslations

 /**
  * Test language files for missing and excess translations
  * All languages are compared with English
  * @group languages
  */
 public function testTranslations()
 {
     $this->Mail->setLanguage('en');
     $definedStrings = $this->Mail->getTranslations();
     $err = '';
     foreach (new DirectoryIterator('../language') as $fileInfo) {
         if ($fileInfo->isDot()) {
             continue;
         }
         $matches = array();
         //Only look at language files, ignore anything else in there
         if (preg_match('/^phpmailer\\.lang-([a-z_]{2,})\\.php$/', $fileInfo->getFilename(), $matches)) {
             $lang = $matches[1];
             //Extract language code
             $PHPMAILER_LANG = array();
             //Language strings get put in here
             include $fileInfo->getPathname();
             //Get language strings
             $missing = array_diff(array_keys($definedStrings), array_keys($PHPMAILER_LANG));
             $extra = array_diff(array_keys($PHPMAILER_LANG), array_keys($definedStrings));
             if (!empty($missing)) {
                 $err .= "\nMissing translations in {$lang}: " . implode(', ', $missing);
             }
             if (!empty($extra)) {
                 $err .= "\nExtra translations in {$lang}: " . implode(', ', $extra);
             }
         }
     }
     $this->assertEmpty($err, $err);
 }
开发者ID:jimobama,项目名称:app,代码行数:35,代码来源:phpmailerLangTest.php

示例3: __construct

 /**
  * Class constructor
  *
  * @param   boolean  $exceptions  PHPMailer should throw external exceptions? [Optional]
  */
 public function __construct($exceptions = TRUE)
 {
     require_once Kohana::find_file('vendor/PHPMailer', 'PHPMailerAutoload');
     // Create phpmailer object
     $this->_mail = new PHPMailer($exceptions);
     // Set some defaults
     $this->_mail->setFrom(Config::get('site.site_email', 'webmaster@example.com'), Template::getSiteName());
     $this->_mail->WordWrap = 70;
     $this->_mail->CharSet = Kohana::$charset;
     $this->_mail->XMailer = Gleez::getVersion(FALSE, TRUE);
     $this->_mail->setLanguage(I18n::$lang);
     $this->_mail->Debugoutput = 'error_log';
 }
开发者ID:ultimateprogramer,项目名称:cms,代码行数:18,代码来源:email.php

示例4: email

 static function email($assunto, $msg, $remetente, $nomeRemetente, $destino, $nomeDestino)
 {
     $path = VENDOR . "phpmailer" . DS . "phpmailer" . DS;
     require_once $path . 'PHPMailerAutoload.php';
     $mail = new \PHPMailer();
     $mail->IsSMTP();
     $mail->setLanguage('br');
     $mail->SMTPAuth = true;
     $mail->Host = HOST_EMAIL;
     $mail->Username = USER_EMAIL;
     $mail->Password = PASS_EMAIL;
     $mail->From = $remetente;
     //remetente
     $mail->FromName = utf8_decode($nomeRemetente);
     //remetente nome
     $mail->AddReplyTo($remetente, utf8_decode($nomeRemetente));
     $mail->IsHTML(true);
     $mail->Subject = utf8_decode($assunto);
     //assunto
     $mail->Body = utf8_decode($msg);
     //mensagem
     $mail->AddAddress($destino, utf8_decode($nomeDestino));
     //email e nome destino
     return $mail->Send();
 }
开发者ID:alcatraz-mvc,项目名称:emailhelper,代码行数:25,代码来源:EmailHelper.php

示例5: smtpMailer

function smtpMailer($to, $from, $from_name, $subject, $body)
{
    $mail = new \PHPMailer();
    // Cree un nouvel objet PHPMailer
    $mail->IsSMTP();
    // active SMTP
    $mail->IsHTML(true);
    $mail->CharSet = "utf-8";
    $mail->SMTPDebug = 0;
    // debogage: 1 = Erreurs et messages, 2 = messages seulement
    $mail->SMTPAuth = true;
    // Authentification SMTP active
    $mail->SMTPSecure = 'ssl';
    // Gmail REQUIERT Le transfert securise
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = 465;
    $mail->Username = GMailUSER;
    $mail->Password = GMailPWD;
    $mail->SetFrom($from, $from_name);
    $mail->Subject = $subject;
    $mail->Body = $body;
    $mail->AddAddress($to);
    $mail->setLanguage('fr', '/optional/path/to/language/directory/');
    //debug($mail);
    if (!$mail->Send()) {
        $errorMail = 'Mail error: ' . $mail->ErrorInfo;
    }
}
开发者ID:2philgit,项目名称:mudeo,代码行数:28,代码来源:mailer.php

示例6: __construct

 public function __construct(\Config_Lite $config, \HttpClientAbstract $client, \App\Storage\User $userStorage)
 {
     $this->_config = $config;
     if (function_exists("pcntl_signal")) {
         pcntl_signal(SIGTERM, array($this, "sigHandler"));
         pcntl_signal(SIGINT, array($this, "sigHandler"));
     }
     $this->_httpClient = $client;
     $this->_userStorage = $userStorage;
     $this->_logger = Logger::getLogger("main");
     $this->_lockFile = DOCUMENT_ROOT . "/var/.lock";
     $this->_lock();
     $this->_running = true;
     $this->_logger->info("Vérification des alertes.");
     $this->_mailer = new PHPMailer($exceptions = true);
     $this->_mailer->setLanguage("fr", DOCUMENT_ROOT . "/lib/PHPMailer/language/");
     $this->_mailer->CharSet = "utf-8";
     if ($config->hasSection("mailer")) {
         if ($smtp = $config->get("mailer", "smtp", array())) {
             $this->_mailer->SMTPKeepAlive = true;
             if (!empty($smtp["host"])) {
                 $this->_mailer->Host = $smtp["host"];
                 if (!empty($smtp["port"])) {
                     $this->_mailer->Port = $smtp["port"];
                 }
                 $this->_mailer->isSMTP();
             }
             if (!empty($smtp["username"])) {
                 $this->_mailer->SMTPAuth = true;
                 $this->_mailer->Username = $smtp["username"];
             }
             if (!empty($smtp["password"])) {
                 $this->_mailer->SMTPAuth = true;
                 $this->_mailer->Password = $smtp["password"];
             }
             if (!empty($smtp["secure"])) {
                 $this->_mailer->SMTPSecure = $smtp["secure"];
             }
         }
         if ($from = $config->get("mailer", "from", null)) {
             $this->_mailer->Sender = $from;
             $this->_mailer->From = $from;
             $this->_mailer->FromName = $from;
         }
     }
     $this->_mailer->isHTML(true);
 }
开发者ID:norips,项目名称:LBCAlerte,代码行数:47,代码来源:check.php

示例7: getMailBoner

 /**
  * 
  * @return \PHPMailer
  */
 private static function getMailBoner()
 {
     $mail = new \PHPMailer();
     $mail->setLanguage('cz');
     $mail->CharSet = 'UTF-8';
     $mail->setFrom(self::FROM_ADDRESS, self::FROM_NAME);
     return $mail;
 }
开发者ID:Thoronir42,项目名称:logickehry,代码行数:12,代码来源:MailSender.php

示例8: contact

 public function contact()
 {
     $am = new AuthentificationManager();
     $error = "";
     $result = "";
     $user_name_regex = "/^[\\p{L}._-]{2,100}\$/u";
     if (!empty($_POST)) {
         $name = $_POST['name'];
         $email = $_POST['email'];
         // $subject = $_POST['subject'];
         //Nom valide
         if (!preg_match($user_name_regex, $name)) {
             $error = "Votre nom ne doit pas contenir de caractères spéciaux !";
         }
         //email valide
         if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
             $error = "Email non valide";
         }
         if (!$error) {
             $mail = new \PHPMailer();
             //configuration de l'envoi
             $mail->isSMTP();
             $mail->setLanguage('fr');
             $mail->CharSet = 'UTF-8';
             //debug
             $mail->SMTPDebug = 0;
             $mail->Debugoutput = 'html';
             //config du serveur smtp
             $mail->Host = 'smtp.gmail.com';
             $mail->Port = 587;
             $mail->SMTPSecure = 'tls';
             $mail->SMTPAuth = true;
             //Identifiant
             global $w_config;
             $smtp_user = $w_config['smtp_user'];
             $smtp_pass = $w_config['smtp_pass'];
             $mail->Username = $smtp_user;
             $mail->Password = $smtp_pass;
             //envoie
             $mail->From = $_POST['email'];
             $mail->FromName = $_POST['name'];
             $mail->Subject = $_POST['subject'];
             $mail->Body = $_POST['message'];
             //To us
             $mail->addAddress('bdlocbdloc@gmail.com', 'Admin');
             //mail au format HTML
             $mail->isHTML(true);
             //envoie du mail ou error
             if (!$mail->send()) {
                 $result = "Mailer Error: " . $mail->ErrorInfo;
             } else {
                 $result = "Votre message a bien été envoyé";
             }
         }
     }
     //affiche la page contact
     $this->show('default/contact', ['result' => $result, 'error' => $error]);
 }
开发者ID:Wouane,项目名称:BDLOC,代码行数:58,代码来源:DefaultController.php

示例9: forgotPassword

    public function forgotPassword()
    {
        $userManager = new UserManager();
        $succes = "";
        $error = "";
        if (!empty($_POST)) {
            $factory = new \RandomLib\Factory();
            $generator = $factory->getGenerator(new \SecurityLib\Strength(\SecurityLib\Strength::MEDIUM));
            $token = $generator->generateString(32, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
            $email = $_POST['email'];
            // Verif si email existe dans la BDD
            if ($userManager->emailExists($email)) {
                $user = $userManager->getUserByUsernameOrEmail($email);
                $userManager->update(array("token" => $token), $user['id']);
                // Envois du mail
                $mail = new \PHPMailer();
                $mail->isSMTP();
                $mail->setLanguage('fr');
                $mail->CharSet = 'UTF-8';
                $mail->SMTPDebug = 2;
                //0 pour désactiver les infos de débug
                $mail->Debugoutput = 'html';
                $mail->Host = 'smtp.gmail.com';
                $mail->Port = 587;
                $mail->SMTPSecure = 'tls';
                $mail->SMTPAuth = true;
                $mail->Username = "thejma666@gmail.com";
                $mail->Password = "poiuytreza321654987";
                $mail->setFrom('ServiceMessagerie@BDloc', 'Service de Messagerie BDloc');
                $mail->addAddress($email, $user['username']);
                $mail->isHTML(true);
                $mail->Subject = 'Envoyé par PHP !';
                $app = getApp();
                $router = $app->getRouter();
                $url = $router->generate("resetMotdepasse", array("token" => $token));
                $mail->Body = 'Nous avons bien reçu votre demande de renouvellement de mot de passe <br>
						pour changer votre mot de passe <a href="http://www.bdloc.dev' . $url . '">Cliquer ici</a>';
                // SI email est bien envoyer
                if (!$mail->send()) {
                    echo "Mailer Error: " . $mail->ErrorInfo;
                } else {
                    echo "Message envoyé";
                }
                $_SESSION['mail_succes'] = "Le mail a bien été envoyé !";
                $this->redirectToRoute('oublieMotdepasse');
            } else {
                $error = "Adresse Email non trouvé !";
            }
        }
        $data = [];
        $data['succes'] = $succes;
        $data['error'] = $error;
        $this->show('user/forgotPassword', $data);
    }
开发者ID:Wouane,项目名称:BDLOC,代码行数:54,代码来源:UserController.php

示例10: testMiscellaneous

 /**
  * Miscellaneous calls to improve test coverage and some small tests.
  */
 public function testMiscellaneous()
 {
     $this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed');
     $this->Mail->addCustomHeader('SomeHeader: Some Value');
     $this->Mail->clearCustomHeaders();
     $this->Mail->clearAttachments();
     $this->Mail->isHTML(false);
     $this->Mail->isSMTP();
     $this->Mail->isMail();
     $this->Mail->isSendmail();
     $this->Mail->isQmail();
     $this->Mail->setLanguage('fr');
     $this->Mail->Sender = '';
     $this->Mail->createHeader();
     $this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded');
     $this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed');
     $this->assertTrue($this->Mail->set('AllowEmpty', null), 'Null property set failed');
     $this->assertTrue($this->Mail->set('AllowEmpty', false), 'Valid property set of null property failed');
     //Test pathinfo
     $a = '/mnt/files/飛兒樂 團光茫.mp3';
     $q = PHPMailer::mb_pathinfo($a);
     $this->assertEquals($q['dirname'], '/mnt/files', 'UNIX dirname not matched');
     $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'UNIX basename not matched');
     $this->assertEquals($q['extension'], 'mp3', 'UNIX extension not matched');
     $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'UNIX filename not matched');
     $this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_DIRNAME), '/mnt/files', 'Dirname path element not matched');
     $this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_BASENAME), '飛兒樂 團光茫.mp3', 'Basename path element not matched');
     $this->assertEquals(PHPMailer::mb_pathinfo($a, 'filename'), '飛兒樂 團光茫', 'Filename path element not matched');
     $a = 'c:\\mnt\\files\\飛兒樂 團光茫.mp3';
     $q = PHPMailer::mb_pathinfo($a);
     $this->assertEquals($q['dirname'], 'c:\\mnt\\files', 'Windows dirname not matched');
     $this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'Windows basename not matched');
     $this->assertEquals($q['extension'], 'mp3', 'Windows extension not matched');
     $this->assertEquals($q['filename'], '飛兒樂 團光茫', 'Windows filename not matched');
     $this->assertEquals(PHPMailer::filenameToType('abc.jpg?xyz=1'), 'image/jpeg', 'Query string not ignored in filename');
     $this->assertEquals(PHPMailer::filenameToType('abc.xyzpdq'), 'application/octet-stream', 'Default MIME type not applied to unknown extension');
     //Line break normalization
     $eol = $this->Mail->LE;
     $b1 = "1\r2\r3\r";
     $b2 = "1\n2\n3\n";
     $b3 = "1\r\n2\r3\n";
     $this->Mail->LE = "\n";
     $t1 = "1{$this->Mail->LE}2{$this->Mail->LE}3{$this->Mail->LE}";
     $this->assertEquals($this->Mail->fixEOL($b1), $t1, 'Failed to normalize line breaks (1)');
     $this->assertEquals($this->Mail->fixEOL($b2), $t1, 'Failed to normalize line breaks (2)');
     $this->assertEquals($this->Mail->fixEOL($b3), $t1, 'Failed to normalize line breaks (3)');
     $this->Mail->LE = "\r\n";
     $t1 = "1{$this->Mail->LE}2{$this->Mail->LE}3{$this->Mail->LE}";
     $this->assertEquals($this->Mail->fixEOL($b1), $t1, 'Failed to normalize line breaks (4)');
     $this->assertEquals($this->Mail->fixEOL($b2), $t1, 'Failed to normalize line breaks (5)');
     $this->assertEquals($this->Mail->fixEOL($b3), $t1, 'Failed to normalize line breaks (6)');
     $this->Mail->LE = $eol;
 }
开发者ID:jbs321,项目名称:portfolio,代码行数:56,代码来源:phpmailerTest.php

示例11: settings

 protected function settings()
 {
     // SMTP
     if (config('mail.smtp')) {
         $this->PHPMailer->isSMTP();
         $this->PHPMailer->Host = config('mail.smtp_host');
         if (config('mail.smtp_login') != '') {
             $this->PHPMailer->SMTPAuth = TRUE;
             $this->PHPMailer->Username = config('mail.smtp_login');
             $this->PHPMailer->Password = config('mail.smtp_password');
             $this->PHPMailer->Port = config('mail.smtp_port');
         }
     }
     // Other
     $this->PHPMailer->From = config('mail.admin_email');
     $this->PHPMailer->FromName = config('mail.admin_name');
     $this->PHPMailer->CharSet = 'utf-8';
     $this->PHPMailer->isHTML(TRUE);
     // Language (перевод системных сообщений)
     $this->PHPMailer->setLanguage('ru', Yii::getPathOfAlias('ext.PHPMailer.language') . '/');
 }
开发者ID:mmorpg2015,项目名称:ghtweb5,代码行数:21,代码来源:Notify.php

示例12: sendContactToAdmin

 public static function sendContactToAdmin($contact, $response = null)
 {
     $response->status = CgdContact::saveContact($contact);
     if ($response->status) {
         $response->message = "Mensagem de contato enviada com sucesso.";
         $mail = new PHPMailer();
         //$mail->SMTPDebug = 3;                               // Enable verbose debug output
         $mail->isSMTP();
         // Set mailer to use SMTP
         $mail->Host = '';
         // Specify main and backup SMTP servers
         $mail->SMTPAuth = true;
         // Enable SMTP authentication
         $mail->Username = '';
         // SMTP username
         $mail->Password = '';
         // SMTP password
         $mail->SMTPSecure = 'tls';
         // Enable TLS encryption, `ssl` also accepted
         $mail->Port = 587;
         // TCP port to connect to
         $mail->setLanguage('br');
         $mail->From = '';
         $mail->FromName = '';
         $mail->addAddress('', '');
         // Add a recipient
         $mail->addReplyTo($contact->email);
         //$mail->addCC('cc@example.com');
         //$mail->addBCC('bcc@example.com');
         //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
         //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
         $mail->isHTML(true);
         // Set email format to HTML
         $mail->Subject = $contact->subject;
         $mail->Body = $contact->email . '<br><br>' . $contact->message;
         $mail->AltBody = $contact->email . ' | ' . $contact->message;
         if (!$mail->send()) {
             //echo 'Message could not be sent.';
             //echo 'Mailer Error: ' . $mail->ErrorInfo;
         } else {
             //echo 'Message has been sent';
         }
     } else {
         $response->message = "Falhou, tente novamente.";
     }
 }
开发者ID:cleitonferreira,项目名称:WorkAndroid,代码行数:46,代码来源:AplContact.php

示例13: getConfiguredMailer

function getConfiguredMailer()
{
    $mail = new PHPMailer();
    //config de l'envoi
    $mail->isSMTP();
    $mail->setLanguage('fr');
    $mail->CharSet = 'UTF-8';
    //debug
    $mail->SMTPDebug = 0;
    //0 pour désactiver les infos de débug
    $mail->Debugoutput = 'html';
    //config du serveur smtp
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = 587;
    $mail->SMTPSecure = 'tls';
    $mail->SMTPAuth = true;
    $mail->Username = SMTPUSER;
    $mail->Password = SMTPPASS;
    //mail au format HTML
    $mail->isHTML(true);
    return $mail;
}
开发者ID:Wouane,项目名称:Flojo,代码行数:22,代码来源:functions.php

示例14: sendEmail

function sendEmail($name, $email, $subject, $body)
{
    //непосредственно почта
    $mail = new PHPMailer();
    $mail->setLanguage('ru', '../lib/phpmailer/phpmailer/language/phpmailer.lang-ru.php');
    $mail->CharSet = "utf-8";
    //$mail->SMTPDebug = 3;                               // Enable verbose debug output
    //$mail->isSMTP();                                      // Set mailer to use SMTP
    //$mail->Host = 'smtp1.example.com;smtp2.example.com';  // Specify main and backup SMTP servers
    //$mail->SMTPAuth = true;                               // Enable SMTP authentication
    //$mail->Username = 'user@example.com';                 // SMTP username
    //$mail->Password = 'secret';                           // SMTP password
    //$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
    //$mail->Port = 587;                                    // TCP port to connect to
    $mail->setFrom($email, $name);
    $mail->addAddress(const_admin_email);
    // Add a recipient
    //$mail->addAddress('ellen@example.com');               // Name is optional
    //$mail->addReplyTo('info@example.com', 'Information');
    //$mail->addCC('cc@example.com');
    //$mail->addBCC('bcc@example.com');
    //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
    //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
    $mail->isHTML(true);
    // Set email format to HTML
    $mail->Subject = $subject;
    //'Message from visermort.ru';
    $mail->Body = $body;
    //'This is the HTML message body <b>in bold!</b>';
    $mail->AltBody = $body;
    //'This is the body in plain text for non-HTML mail clients';
    if (!$mail->send()) {
        return 'Сообщение не отправлено ' . $mail->ErrorInfo;
    } else {
        return 0;
    }
}
开发者ID:visermort,项目名称:visermort,代码行数:37,代码来源:function.php

示例15: sendEmail

function sendEmail($data = array('recipient' => '', 'toName' => '', 'subject' => '', 'isHTML' => 0, 'html' => '', 'text' => '', 'attach' => array(), 'from' => '', 'fromName' => '', 'sender' => '', 'stringAttach' => array()))
{
    // used to send a standardized email message
    global $phpwcms;
    $mailInfo = array(0 => false, 1 => '');
    $sendTo = array();
    $from = empty($data['from']) || !is_valid_email($data['from']) ? $phpwcms['SMTP_FROM_EMAIL'] : $data['from'];
    $sender = empty($data['sender']) || !is_valid_email($data['sender']) ? $from : $data['sender'];
    $fromName = empty($data['fromName']) ? '' : cleanUpForEmailHeader($data['fromName']);
    $toName = empty($data['toName']) ? '' : cleanUpForEmailHeader($data['toName']);
    $subject = empty($data['subject']) ? 'Email sent by phpwcms' : cleanUpForEmailHeader($data['subject']);
    if (empty($data['html'])) {
        $data['html'] = '';
        $data['isHTML'] = 0;
    } elseif (empty($data['isHTML'])) {
        $data['isHTML'] = 0;
    } else {
        $data['isHTML'] = 1;
    }
    if (empty($data['text'])) {
        $data['text'] = '';
    }
    if (!is_array($data['recipient'])) {
        $recipient = str_replace(' ', '', trim($data['recipient']));
        $recipient = str_replace(',', ';', $recipient);
        $recipient = str_replace(' ', '', $recipient);
        $recipient = explode(';', $recipient);
    } else {
        $recipient = $data['recipient'];
    }
    if (is_array($recipient) && count($recipient)) {
        foreach ($recipient as $value) {
            if (is_valid_email($value)) {
                $sendTo[] = $value;
            }
        }
    }
    if (count($sendTo)) {
        require_once PHPWCMS_ROOT . '/include/inc_ext/phpmailer/PHPMailerAutoload.php';
        $mail = new PHPMailer();
        $mail->Mailer = $phpwcms['SMTP_MAILER'];
        $mail->Host = $phpwcms['SMTP_HOST'];
        $mail->Port = $phpwcms['SMTP_PORT'];
        if ($phpwcms['SMTP_AUTH']) {
            $mail->SMTPAuth = 1;
            $mail->Username = $phpwcms['SMTP_USER'];
            $mail->Password = $phpwcms['SMTP_PASS'];
        }
        if (!empty($phpwcms['SMTP_SECURE'])) {
            $mail->SMTPSecure = $phpwcms['SMTP_SECURE'];
        }
        if (!empty($phpwcms['SMTP_AUTH_TYPE'])) {
            $mail->AuthType = $phpwcms['SMTP_AUTH_TYPE'];
            if ($phpwcms['SMTP_AUTH_TYPE'] === 'NTLM') {
                if (!empty($phpwcms['SMTP_REALM'])) {
                    $mail->Realm = $phpwcms['SMTP_REALM'];
                }
                if (!empty($phpwcms['SMTP_WORKSTATION'])) {
                    $mail->Workstation = $phpwcms['SMTP_WORKSTATION'];
                }
            }
        }
        $mail->CharSet = $phpwcms["charset"];
        $mail->isHTML($data['isHTML']);
        $mail->Subject = $data['subject'];
        if ($data['isHTML']) {
            if ($data['text'] != '') {
                $mail->AltBody = $data['text'];
            }
            $mail->Body = $data['html'];
        } else {
            $mail->Body = $data['text'];
        }
        if (!$mail->setLanguage($phpwcms['default_lang'], PHPWCMS_ROOT . '/include/inc_ext/phpmailer/language/')) {
            $mail->setLanguage('en', PHPWCMS_ROOT . '/include/inc_ext/phpmailer/language/');
        }
        $mail->From = $from;
        $mail->FromName = $fromName;
        $mail->Sender = $sender;
        $mail->addAddress($sendTo[0], $toName);
        unset($sendTo[0]);
        if (is_array($sendTo) && count($sendTo)) {
            foreach ($sendTo as $value) {
                $mail->addBCC($value);
            }
        }
        if (isset($data['attach']) && is_array($data['attach']) && count($data['attach'])) {
            foreach ($data['attach'] as $attach_file) {
                $mail->addAttachment($attach_file);
            }
        }
        if (isset($data['stringAttach']) && is_array($data['stringAttach']) && count($data['stringAttach'])) {
            $attach_counter = 1;
            foreach ($data['stringAttach'] as $attach_string) {
                if (is_array($attach_string) && !empty($attach_string['data'])) {
                    $attach_string['filename'] = empty($attach_string['filename']) ? 'attachment_' . $attach_counter : $attach_string['filename'];
                    $attach_string['mime'] = empty($attach_string['mime']) ? 'application/octet-stream' : $attach_string['mime'];
                    $attach_string['encoding'] = empty($attach_string['encoding']) ? 'base64' : $attach_string['encoding'];
                    $mail->addStringAttachment($attach_string['data'], $attach_string['filename'], $attach_string['encoding'], $attach_string['mime']);
                    $attach_counter++;
//.........这里部分代码省略.........
开发者ID:EDVLanger,项目名称:phpwcms,代码行数:101,代码来源:general.inc.php


注:本文中的PHPMailer::setLanguage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。