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


PHP Newsletter::initMailer方法代码示例

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


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

示例1: check_configuration

function check_configuration($port, $security)
{
    flush();
    try {
        $mail = Newsletter::initMailer($port, $security);
        $mail->Timeout = 3;
        // seconds
        $mail->SMTPDebug = 2;
        $mail->clearAddresses();
        $mail->addAddress(SENDER_ADDRESS, SENDER_NAME);
        $mail->addReplyTo(SENDER_ADDRESS, SENDER_NAME);
        $mail->setFrom(SENDER_ADDRESS, SENDER_NAME);
        $mail->Subject = "Open-Letters NewsletterSoftware => Test-Email";
        $mail->Body = "Dear Newsletter owner,\n\nThis mail was sent to You by file " . __FILE__ . " on Your Webspace. That You can read this mail means the" . " email configuration in Your config/config.inc.php is right.\n\n" . "best regards\nOpen-Letters";
        $mail->smtpConnect();
        if (!$mail->send()) {
            throw new Exception("ERROR sending an Email: " . $mail->ErrorInfo, "666");
        } else {
            echo "This configuration DID work: Port=" . $port . " and Security=" . $security . "!!!<br>" . "The inbox of " . SENDER_ADDRESS . " should " . "have a new email right now. If this email was not received, " . "please check Your spam folder and configuration.<br>" . "<span class='success'>Success, test mail was sent!</span><br>";
            return true;
        }
    } catch (Exception $e) {
        echo "Your configuration did NOT work: Port=" . $port . " and Security=" . $security . "<br>";
        echo $e->getMessage();
        echo "<span class='error'>Sorry, this try did not work.</span><br><br>";
        return false;
    }
}
开发者ID:ReichardtIT,项目名称:open-letters-newsletter,代码行数:28,代码来源:phpMailerSmtpTest.php

示例2: send_double_optin_mail

 /**
  * Diese Methode bereitet das Objekt der Klasse <i>PhpMailer</i> darauf vor, die
  * Newsletter zu versenden. Beim ersten Aufruf dieser Methode wird der Mailer
  * tatsaechlich initiiert, spaeter wird nur auf das im statischen Attribut
  * abgelegt.
  * @return PhpMailer ein Objekt der Klasse PhpMailer, dem nur der Inhalt der
  * E-Mail (HTML und Text) und der Empfaenger fehlt
  */
 protected function send_double_optin_mail($user_input)
 {
     $rueckgabe = null;
     try {
         ob_start();
         require_once ROOT_PATH . "include/newsletter.class.php";
         $mail = Newsletter::initMailer();
         // Emailadressen und Betreff
         $mail->addReplyTo(SENDER_ADDRESS, SENDER_NAME);
         $mail->setFrom(SENDER_ADDRESS, SENDER_NAME);
         $mail->addAddress($user_input['newsemail'], $user_input['firstname'] . " " . $user_input['name']);
         $mail->Subject = $this->text->get_text('newsletter_subscription_opt_in_email_subject') . $_SERVER["HTTP_HOST"];
         $text = $this->text->get_text('newsletter_subscription_opt_in_email_message');
         $text = str_replace("#####host#####", $_SERVER['HTTP_HOST'], $text);
         $url = rtrim(ROOT_DOMAIN, "/") . "/index.php?doubleoptin=" . $user_input['double_optin_token'];
         $mail->AltBody = str_replace("#####url#####", $url, $text);
         $url = "<br><a href='" . $url . "'>" . $url . "</a>";
         $text = str_replace("\n", "<br>", $text);
         $text = str_replace("#####url#####", $url, $text);
         $mail->msgHTML($text);
         if ($mail->send()) {
             $rueckgabe = true;
         }
         $error = ob_get_contents();
         ob_end_clean();
         if (strlen(trim($error)) > 0) {
             throw new Exception("Fehler beim Versand der Double-OptIn-Mail: " . $error);
         }
     } catch (Exception $e) {
         $this->logmessage($e->getMessage());
         $rueckgabe = false;
     }
     return $rueckgabe;
 }
开发者ID:ReichardtIT,项目名称:open-letters-newsletter,代码行数:42,代码来源:newsletter_form.class.php

示例3: execute_sending

 /**
  * Diese Methode fuehrt den Versand der Newsletter-E-Mails aus.
  * @param array $receivers die Empfaenger dieses Versandprozesses
  * @return int die ID des letzten Empfaengers, dem der Newsletter
  * zugestellt wurde
  */
 protected function execute_sending($receivers)
 {
     // Objekt von PhpMailer (einmalig) konfigurieren
     try {
         ob_start();
         $mail = Newsletter::initMailer();
         // Emailadressen und Betreff
         $mail->addReplyTo(SENDER_ADDRESS, SENDER_NAME);
         $mail->setFrom(SENDER_ADDRESS, SENDER_NAME);
         $subject = SUBJECT;
         if (SUBJECT_DATE) {
             $subject .= " " . date("d.m.Y", $this->timestamp);
         }
         $mail->Subject = $subject;
         $error = ob_get_contents();
         ob_end_clean();
         if (strlen(trim($error)) > 0) {
             throw new Exception($error);
         }
     } catch (Exception $e) {
         $this->logmessage($e->getMessage());
         return false;
     }
     // Schleife ueber all diese Empfaenger
     $anzahl = count($receivers);
     $last_receiver = 0;
     for ($i = 0; $i < $anzahl; $i++) {
         try {
             ob_start();
             // E-Mail-Adresse pruefen und (wenn keine E-Mail-Adresse) ueberspringen
             if (!filter_var($receivers[$i]['email'], FILTER_VALIDATE_EMAIL)) {
                 $last_receiver = $receivers[$i]['email_id'];
                 continue;
             }
             // Adresse dieses Empfaengers in den Mailer setzen
             $mail->clearAddresses();
             $mail->addAddress($receivers[$i]['email'], $receivers[$i]['name']);
             // Adresse dieses Empfaengers in den Mail-Text setzen
             $html_text = $this->getHtml($receivers[$i]['email']);
             $plain_text = $this->getTxt($receivers[$i]['email']);
             // Inhalte setzen
             $mail->AltBody = $plain_text;
             $mail->msgHTML($html_text);
             // Im Debug-Modus simulieren wir das Versenden nur
             if (DEBUG_MODUS > 0) {
                 $this->logmessage("Der Newsletter vom " . date("d.m.Y") . " wurde an " . $receivers[$i]['name'] . " (" . $receivers[$i]['email'] . ", UserID " . $receivers[$i]['email_id'] . ") simuliert.");
             } else {
                 // kein Debug-Modus: Versenden versuchen
                 if (!$mail->send()) {
                     $this->logmessage("Der Newsletter vom " . date("d.m.Y") . " konnte nicht an " . $receivers[$i]['name'] . " (" . $receivers[$i]['email'] . ") versendet werden. Fehlermeldung: " . $mail->ErrorInfo);
                 }
             }
             $error = ob_get_contents();
             ob_end_clean();
             if (strlen(trim($error)) > 0) {
                 throw new Exception($error);
             }
         } catch (Exception $e) {
             $this->logmessage("Fehler beim Versand der Newsletter-eMail: " . $e->getMessage());
         }
         $last_receiver = $receivers[$i]['email_id'];
     }
     return $last_receiver;
 }
开发者ID:ReichardtIT,项目名称:open-letters-newsletter,代码行数:70,代码来源:newsletter.class.php


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