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


PHP phpmailer::IsSMTP方法代码示例

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


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

示例1: email_to_user

/**
 * Send an email to a specified user
 *
 * @uses $CFG
 * @param user $user  A {@link $USER} object
 * @param user $from A {@link $USER} object
 * @param string $subject plain text subject line of the email
 * @param string $messagetext plain text version of the message
 * @param string $messagehtml complete html version of the message (optional)
 * @param string $attachment a file on the filesystem
 * @param string $attachname the name of the file (extension indicates MIME)
 * @param bool $usetrueaddress determines whether $from email address should
 *          be sent out. Will be overruled by user profile setting for maildisplay
 * @return bool|string Returns "true" if mail was sent OK, "emailstop" if email
 *          was blocked by user and "false" if there was another sort of error.
 */
function email_to_user($user, $from, $subject, $messagetext, $messagehtml = '', $attachment = '', $attachname = '', $usetrueaddress = true, $replyto = '', $replytoname = '')
{
    global $CFG;
    $textlib = textlib_get_instance();
    include_once $CFG->libdir . '/phpmailer/class.phpmailer.php';
    if (empty($user) || empty($user->email)) {
        return false;
    }
    /*
    if (over_bounce_threshold($user)) {
        error_log("User $user->id (".fullname($user).") is over bounce threshold! Not sending.");
        return false;
    }
    */
    // this doesn't exist right now, we may bring it in later though.
    $mail = new phpmailer();
    $mail->Version = 'Elgg ';
    // mailer version (should have $CFG->version on here but we don't have it yet)
    $mail->PluginDir = $CFG->libdir . '/phpmailer/';
    // plugin directory (eg smtp plugin)
    $mail->CharSet = 'UTF-8';
    // everything is now uft8
    if (empty($CFG->smtphosts)) {
        $mail->IsMail();
        // use PHP mail() = sendmail
    } else {
        if ($CFG->smtphosts == 'qmail') {
            $mail->IsQmail();
            // use Qmail system
        } else {
            $mail->IsSMTP();
            // use SMTP directly
            if ($CFG->debug > 7) {
                echo '<pre>' . "\n";
                $mail->SMTPDebug = true;
            }
            $mail->Host = $CFG->smtphosts;
            // specify main and backup servers
            if ($CFG->smtpuser) {
                // Use SMTP authentication
                $mail->SMTPAuth = true;
                $mail->Username = $CFG->smtpuser;
                $mail->Password = $CFG->smtppass;
            }
        }
    }
    /* not here yet, leave it in just in case.
       // make up an email address for handling bounces
       if (!empty($CFG->handlebounces)) {
           $modargs = 'B'.base64_encode(pack('V',$user->ident)).substr(md5($user->email),0,16);
           $mail->Sender = generate_email_processing_address(0,$modargs);
       }
       else {
           $mail->Sender   =  $CFG->sysadminemail;
       }
       */
    $mail->Sender = $CFG->sysadminemail;
    // for elgg. delete if we change the above.
    // TODO add a preference for maildisplay
    if (is_string($from)) {
        // So we can pass whatever we want if there is need
        $mail->From = $CFG->noreplyaddress;
        $mail->FromName = $from;
    } else {
        if (empty($from)) {
            // make stuff up
            $mail->From = $CFG->sysadminemail;
            $mail->FromName = $CFG->sitename . ' ' . __gettext('Administrator');
        } else {
            if ($usetrueaddress and !empty($from->maildisplay)) {
                $mail->From = $from->email;
                $mail->FromName = $from->name;
            } else {
                $mail->From = $CFG->noreplyaddress;
                $mail->FromName = $from->name;
                if (empty($replyto)) {
                    $mail->AddReplyTo($CFG->noreplyaddress, __gettext('Do not reply'));
                }
            }
        }
    }
    if (!empty($replyto)) {
        $mail->AddReplyTo($replyto, $replytoname);
    }
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:tulipan-svn,代码行数:101,代码来源:elgglib.php

示例2: sendQRmail

function sendQRmail($from, $to, $subject, $msg, $qrcodeImage, $cid, $name)
{
    include_once 'inc/class.phpmailer.php';
    $mail = new phpmailer();
    $mail->SMTPDebug = 0;
    // debugging: 1 = errors and messages, 2 = messages only, 0 = off
    $mail->IsSMTP();
    // Set mailer to use SMTP
    $mail->Host = 'mailhub.eait.uq.edu.au';
    // Specify server
    $mail->Port = 25;
    // Server port: 465 ssl OR  587 tls
    //$mail->SMTPSecure = 'tls';                       // Enable encryption, 'ssl' also accepted
    $mail->SMTPAuth = false;
    // Enable SMTP authentication
    $mail->Username = 's4329663@student.uq.edu.au';
    // SMTP username
    $mail->Password = 'hongzhe123999';
    // SMTP password
    $mail->SetFrom($from, 'QRappi');
    // Sender
    $mail->AddReplyTo($from, 'Support');
    // Set an alternative reply-to address
    $mail->AddAddress($to, 'User');
    // Set who the message is to be sent to
    $mail->Subject = $subject;
    // Set the subject line
    // Prepares message for html (see doc for details http://phpmailer.worxware.com/?pg=tutorial)
    $mail->MsgHTML($msg);
    // Add the image to the email as an inline element (i.e. not as an attachment)
    $mail->AddStringEmbeddedImage($qrcodeImage, $cid, $name);
    // Send the message, check for errors
    $ok = $mail->Send();
    return $ok;
}
开发者ID:Hongzhe,项目名称:DECO3801-PeerTech,代码行数:35,代码来源:mail.php

示例3: phpmailer

 function __construct()
 {
     $mail = new phpmailer();
     $mail->IsSMTP();
     //$mail->IsMail();
     $mail->SMTPAuth = true;
     // enable SMTP authentication
     $mail->SMTPSecure = "ssl";
     // sets the prefix to the servier
     $mail->Host = SMTP_HOST;
     // sets GMAIL as the SMTP server
     $mail->Port = SMTP_PORT;
     // set the SMTP port for the GMAIL server
     $mail->Username = SMTP_USERNAME;
     // GMAIL username
     $mail->Password = SMTP_PASSWORD;
     // GMAIL password
     $mail->AddReplyTo(EMAIL_FROM, "");
     $mail->From = EMAIL_FROM;
     $mail->FromName = EMAIL_FROM_NAME;
     $mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
     // optional, comment out and test
     $mail->WordWrap = 50;
     // set word wrap
     $this->_mail = $mail;
 }
开发者ID:business-expert,项目名称:prnsc,代码行数:26,代码来源:email.php

示例4: sendmail

function sendmail($subject, $mailcontent, $receiver, $receivername, $attachment = "")
{
    if (strpos($_SERVER['HTTP_HOST'], "localhost")) {
        return false;
    }
    $mail = new phpmailer();
    $mail->IsSMTP();
    $mail->Host = "mail.pepool.com";
    $mail->Port = 2525;
    $mail->SMTPAuth = true;
    $mail->Username = "info+pepool.com";
    // Write SMTP username in ""
    $mail->Password = "*VTWqNzPNKlut";
    $mail->Mailer = "smtp";
    $mail->IsHTML(true);
    $mail->ClearAddresses();
    $mail->From = "info@pepool.com";
    $mail->FromName = "pepool";
    $mail->Subject = $subject;
    $mail->Body = $mailcontent;
    $mail->AddAddress($receiver, $receivername);
    if ($attachment != '') {
        $mail->AddAttachment($attachment);
    }
    $suc = $mail->Send();
    return $suc > 0;
}
开发者ID:gauravstomar,项目名称:Pepool,代码行数:27,代码来源:Mail.php

示例5: envmail

function envmail($email, $subject, $msg, $from, $fromname = "Opala Clube Franca")
{
    require_once "class.phpmailer.php";
    $mail = new phpmailer();
    $mail->ClearAddresses();
    $mail->ClearAllRecipients();
    $mail->ClearAddresses();
    $mail->ClearCustomHeaders();
    $mail->IsSMTP();
    //    $mail->IsSendmail();
    $mail->From = $from;
    $mail->FromName = $fromname;
    // 	$mail->Hostname = "smtp.gmail.com";
    //	$mail->Host     = "smtp.gmail.com";
    $mail->SMTPSecure = "ssl";
    $mail->Hostname = "smtp.opalaclubefranca.com.br";
    $mail->Host = "smtp.opalaclubefranca.com.br";
    //    $mail->SMTPDebug = 2;
    $mail->Username = "admin@opalaclubefranca.com.br";
    $mail->Password = "racnela";
    $mail->SMTPAuth = true;
    $mail->Port = 465;
    $mail->Timeout = 120;
    $body = $msg;
    $text_body = $msg;
    $mail->isHTML(true);
    $mail->Subject = $subject;
    $mail->Body = $body;
    $mail->AltBody = $text_body;
    if (is_array($email)) {
        foreach ($email as $em) {
            $mail->AddAddress($em, "");
        }
    } else {
        $mail->AddAddress($email, "");
    }
    /*  echo '<tr><td>To '.$email.'</td></tr>'."\n";
        echo '<tr><td>Assunto '.$subject.'</td></tr>'."\n";
        echo '<tr><td>Mensagem '.$msg.'</td></tr>'."\n";
        echo '<tr><td>From '.$from.'</td></tr>'."\n";
    */
    $exito = $mail->Send();
    $v = 0;
    //    echo "<tr><td>ErrorInfo " . $mail->ErrorInfo . "<br></td></tr>";
    while (!$exito && $v < 5 && $mail->ErrorInfo != "SMTP Error: Data not accepted.") {
        sleep(2);
        $exito = $mail->Send();
        echo "<tr><td>ErrorInfo " . $mail->ErrorInfo . "<br></td></tr>";
        $v = $v + 1;
    }
    if (!$exito) {
        echo "<tr><td>There has been a mail error sending to " . $mail->ErrorInfo . "<br></td></tr>";
    }
    $mail->ClearAddresses();
    $mail->ClearAttachments();
    return $mail->ErrorInfo;
}
开发者ID:alencarmo,项目名称:OCF,代码行数:57,代码来源:envmail.php

示例6: SendMail

function SendMail($email, $name, $subject, $message)
{
    global $sockethost, $smtpauth, $smtpauthuser, $smtpauthpass, $socketfrom, $socketfromname, $socketreply, $socketreplyname;
    include 'class.phpmailer.php';
    $mail = new phpmailer();
    $mail->IsSMTP();
    $mail->Host = $sockethost;
    if ($smtpauth == 'TRUE') {
        $mail->SMTPAuth = true;
        $mail->Username = $smtpauthuser;
        $mail->Password = $smtpauthpass;
    }
    if (isset($_GET['caseid']) && ($_GET['caseid'] == 'NewTicket' || $_GET['caseid'] == 'view')) {
        $mail->From = $email;
        $mail->FromName = $name;
        $mail->AddReplyTo($email, $name);
    } else {
        $mail->From = $socketfrom;
        $mail->FromName = $socketfromname;
        $mail->AddReplyTo($socketreply, $socketreplyname);
    }
    $mail->IsHTML(False);
    $mail->Body = $message;
    $mail->Subject = $subject;
    if (isset($_GET['caseid']) && ($_GET['caseid'] == 'NewTicket' || $_GET['caseid'] == 'view')) {
        $mail->AddAddress($socketfrom, $socketfromname);
    } else {
        $mail->AddAddress($email, $name);
    }
    if (!$mail->Send()) {
        return 'Error: ' . $mail->ErrorInfo;
    } else {
        return 'Email Sent.';
    }
    $mail->ClearAddresses();
}
开发者ID:paintballrefjosh,项目名称:php-nuke-support-ticket,代码行数:36,代码来源:functions.php

示例7: enviar

 function enviar($arguntos)
 {
     # code...
     $mail = new phpmailer(true);
     // the true param means it will throw exceptions on errors, which we need to catch
     $mail->IsSMTP();
     // telling the class to use SMTP
     $mail->Host = Host;
     // SMTP server
     $mail->SMTPDebug = 0;
     // enables SMTP debug information (for testing)
     $mail->IsHTML(true);
     $mail->SMTPAuth = SMTPAuth;
     // enable SMTP authentication
     $mail->SMTPSecure = SMTPSecure;
     // sets the prefix to the servier
     $mail->Port = Port;
     // set the SMTP port for the GMAIL server
     $mail->Username = Username;
     // GMAIL username
     $mail->Password = Password;
     // GMAIL password
     $mail->AddAddress($arguntos['email'], $arguntos['nomebusca']);
     if (AddReplyTo != '') {
         $mail->AddReplyTo(AddReplyTo);
     }
     $mail->Subject = $arguntos['Subject'];
     $mail->From = SetFromEmail;
     $mail->FromName = SetFromNome;
     $mail->Body = $arguntos['conteudo'];
     // optional - MsgHTML will create an alternate automatically
     // $mail->MsgHTML($arguntos['conteudo']);
     if ($mail->Send()) {
         echo "<p>Mensagem enviada com Sucesso!!!!</p>\n";
     }
 }
开发者ID:tvieira,项目名称:homebank,代码行数:36,代码来源:old_enviaemail.php

示例8: SendEmail

 /**
  * Send the email
  * @param      int $UserID
  * @param      int $NewsletterID
  * @param      string $TargetEmail
  * @param      string $type
  */
 function SendEmail($UserID, $NewsletterID, $TargetEmail, $TmpEntry, $type = self::USER_TYPE_NEWSLETTER)
 {
     global $objDatabase, $_ARRAYLANG, $_DBCONFIG;
     require_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php';
     $newsletterValues = $this->getNewsletterValues($NewsletterID);
     if ($newsletterValues !== false) {
         $subject = $newsletterValues['subject'];
         $template = $newsletterValues['template'];
         $content = $newsletterValues['content'];
         $priority = $newsletterValues['priority'];
         $sender_email = $newsletterValues['sender_email'];
         $sender_name = $newsletterValues['sender_name'];
         $return_path = $newsletterValues['return_path'];
         $count = $newsletterValues['count'];
         $smtpAccount = $newsletterValues['smtp_server'];
     }
     $break = $this->getSetting('txt_break_after');
     $break = intval($break) == 0 ? 80 : $break;
     $HTML_TemplateSource = $this->GetTemplateSource($template, 'html');
     // TODO: Unused
     //        $TEXT_TemplateSource = $this->GetTemplateSource($template, 'text');
     $newsletterUserData = $this->getNewsletterUserData($UserID, $type);
     $testDelivery = !$TmpEntry;
     $NewsletterBody_HTML = $this->ParseNewsletter($subject, $content, $HTML_TemplateSource, '', $TargetEmail, $newsletterUserData, $NewsletterID, $testDelivery);
     \LinkGenerator::parseTemplate($NewsletterBody_HTML, true);
     $NewsletterBody_TEXT = $this->ParseNewsletter('', '', '', 'text', '', $newsletterUserData, $NewsletterID, $testDelivery);
     \LinkGenerator::parseTemplate($NewsletterBody_TEXT, true);
     $mail = new \phpmailer();
     if ($smtpAccount > 0) {
         if (($arrSmtp = \SmtpSettings::getSmtpAccount($smtpAccount)) !== false) {
             $mail->IsSMTP();
             $mail->Host = $arrSmtp['hostname'];
             $mail->Port = $arrSmtp['port'];
             $mail->SMTPAuth = $arrSmtp['username'] == '-' ? false : true;
             $mail->Username = $arrSmtp['username'];
             $mail->Password = $arrSmtp['password'];
         }
     }
     $mail->CharSet = CONTREXX_CHARSET;
     $mail->AddReplyTo($return_path);
     $mail->SetFrom($sender_email, $sender_name);
     $mail->Subject = $subject;
     $mail->Priority = $priority;
     $mail->Body = $NewsletterBody_HTML;
     $mail->AltBody = $NewsletterBody_TEXT;
     $queryATT = "SELECT newsletter, file_name FROM " . DBPREFIX . "module_newsletter_attachment where newsletter=" . $NewsletterID . "";
     $objResultATT = $objDatabase->Execute($queryATT);
     if ($objResultATT !== false) {
         while (!$objResultATT->EOF) {
             $mail->AddAttachment(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesAttachPath() . "/" . $objResultATT->fields['file_name'], $objResultATT->fields['file_name']);
             $objResultATT->MoveNext();
         }
     }
     $mail->AddAddress($TargetEmail);
     if ($UserID) {
         // mark recipient as in-action to prevent multiple tries of sending the newsletter to the same recipient
         $query = "UPDATE " . DBPREFIX . "module_newsletter_tmp_sending SET sendt=2 where email='" . $TargetEmail . "' AND newsletter=" . $NewsletterID . " AND sendt=0";
         if ($objDatabase->Execute($query) === false || $objDatabase->Affected_Rows() == 0) {
             return $count;
         }
     }
     if ($mail->Send()) {
         // && $UserID == 0) {
         $ReturnVar = $count++;
         if ($TmpEntry == 1) {
             // Insert TMP-ENTRY Sended Email & Count++
             $query = "UPDATE " . DBPREFIX . "module_newsletter_tmp_sending SET sendt=1 where email='" . $TargetEmail . "' AND newsletter=" . $NewsletterID . "";
             if ($objDatabase->Execute($query) === false) {
                 if ($_DBCONFIG['dbType'] == 'mysql' && $objDatabase->ErrorNo() == 2006) {
                     @$objDatabase->Connect($_DBCONFIG['host'], $_DBCONFIG['user'], $_DBCONFIG['password'], $_DBCONFIG['database'], true);
                     if ($objDatabase->Execute($query) === false) {
                         return false;
                     }
                 }
             }
             $objDatabase->Execute("\n                    UPDATE " . DBPREFIX . "module_newsletter\n                       SET count=count+1\n                     WHERE id={$NewsletterID}");
             $queryCheck = "SELECT 1 FROM " . DBPREFIX . "module_newsletter_tmp_sending where newsletter=" . $NewsletterID . " and sendt=0";
             $objResultCheck = $objDatabase->SelectLimit($queryCheck, 1);
             if ($objResultCheck->RecordCount() == 0) {
                 $objDatabase->Execute("\n                        UPDATE " . DBPREFIX . "module_newsletter\n                           SET status=1\n                         WHERE id={$NewsletterID}");
             }
         }
         /*elseif ($mail->error_count) {
               if (strstr($mail->ErrorInfo, 'authenticate')) {
                   self::$strErrMessage .= sprintf($_ARRAYLANG['TXT_NEWSLETTER_MAIL_AUTH_FAILED'], htmlentities($arrSmtp['name'], ENT_QUOTES, CONTREXX_CHARSET)).'<br />';
                   $ReturnVar = false;
               }
           } */
     } else {
         $performRejectedMailOperation = false;
         if (strstr($mail->ErrorInfo, 'authenticate')) {
             // -> smtp error
             self::$strErrMessage .= sprintf($_ARRAYLANG['TXT_NEWSLETTER_MAIL_AUTH_FAILED'], htmlentities($arrSmtp['name'], ENT_QUOTES, CONTREXX_CHARSET)) . '<br />';
//.........这里部分代码省略.........
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:101,代码来源:NewsletterManager.class.php

示例9: storeMessageComment

 /**
  * Validates the submitted comment data and writes it to the databse if valid.
  * Additionally, a notification is send out to the administration about the comment
  * by e-mail (only if the corresponding configuration option is set to do so). 
  *
  * @param   integer News message ID for which the comment shall be stored
  * @param   string  Title of the news message for which the comment shall be stored.
  *                  The title will be used in the notification e-mail
  * @param   string  The poster's name of the comment
  * @param   string  The comment's title
  * @param   string  The comment's message text
  * @global    ADONewConnection
  * @global    array
  * @global    array
  * @global    array
  * @return  array   Returns an array of two elements. The first is either TRUE on success or FALSE on failure.
  *                  The second element contains an error message on failure.  
  */
 private function storeMessageComment($newsMessageId, $newsMessageTitle, $name, $title, $message)
 {
     global $objDatabase, $_ARRAYLANG, $_CORELANG, $_CONFIG;
     if (!isset($_SESSION['news'])) {
         $_SESSION['news'] = array();
         $_SESSION['news']['comments'] = array();
     }
     // just comment
     if ($this->checkForCommentFlooding($newsMessageId)) {
         return array(false, sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_INTERVAL_MSG'], $this->arrSettings['news_comments_timeout']));
     }
     if (empty($title)) {
         return array(false, $_ARRAYLANG['TXT_NEWS_MISSING_COMMENT_TITLE']);
     }
     if (empty($message)) {
         return array(false, $_ARRAYLANG['TXT_NEWS_MISSING_COMMENT_MESSAGE']);
     }
     $date = time();
     $userId = 0;
     if (\FWUser::getFWUserObject()->objUser->login()) {
         $userId = \FWUser::getFWUserObject()->objUser->getId();
         $name = \FWUser::getParsedUserTitle($userId);
     } elseif ($this->arrSettings['news_comments_anonymous'] == '1') {
         // deny comment if the poster did not specify his name
         if (empty($name)) {
             return array(false, $_ARRAYLANG['TXT_NEWS_POSTER_NAME_MISSING']);
         }
         // check CAPTCHA for anonymous posters
         if (!\Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check()) {
             return array(false, null);
         }
     } else {
         // Anonymous comments are not allowed
         return array(false, null);
     }
     $isActive = $this->arrSettings['news_comments_autoactivate'];
     $ipAddress = contrexx_input2raw($_SERVER['REMOTE_ADDR']);
     $objResult = $objDatabase->Execute("\n            INSERT INTO `" . DBPREFIX . "module_news_comments` \n                    SET `title` = '" . contrexx_raw2db($title) . "',\n                        `text` = '" . contrexx_raw2db($message) . "',\n                        `newsid` = '" . contrexx_raw2db($newsMessageId) . "',\n                        `date` = '" . contrexx_raw2db($date) . "',\n                        `poster_name` = '" . contrexx_raw2db($name) . "',\n                        `userid` = '" . contrexx_raw2db($userId) . "',\n                        `ip_address` = '" . contrexx_raw2db($ipAddress) . "',\n                        `is_active` = '" . contrexx_raw2db($isActive) . "'");
     if (!$objResult) {
         return array(false, $_ARRAYLANG['TXT_NEWS_COMMENT_SAVE_ERROR']);
     }
     /* Prevent comment flooding from same user:
        Either user is authenticated or had to validate a CAPTCHA.
        In either way, a Contrexx session had been initialized,
        therefore we are able to use the $_SESSION to log this comment */
     $_SESSION['news']['comments'][$newsMessageId] = $date;
     // Don't send a notification e-mail to the administrator
     if (!$this->arrSettings['news_comments_notification']) {
         return array(true, null);
     }
     // Send a notification e-mail to administrator
     if (!@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
         \DBG::msg('Unable to send e-mail notification to admin');
         //DBG::stack();
         return array(true, null);
     }
     $objMail = new \phpmailer();
     if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
         if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
             $objMail->IsSMTP();
             $objMail->Host = $arrSmtp['hostname'];
             $objMail->Port = $arrSmtp['port'];
             $objMail->SMTPAuth = true;
             $objMail->Username = $arrSmtp['username'];
             $objMail->Password = $arrSmtp['password'];
         }
     }
     $objMail->CharSet = CONTREXX_CHARSET;
     $objMail->From = $_CONFIG['coreAdminEmail'];
     $objMail->FromName = $_CONFIG['coreGlobalPageTitle'];
     $objMail->IsHTML(false);
     $objMail->Subject = sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_NOTIFICATION_MAIL_SUBJECT'], $newsMessageTitle);
     $manageCommentsUrl = ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ($_SERVER['SERVER_PORT'] == 80 ? NULL : ':' . intval($_SERVER['SERVER_PORT'])) . ASCMS_ADMIN_WEB_PATH . '/index.php?cmd=News&act=comments&newsId=' . $newsMessageId;
     $activateCommentTxt = $this->arrSettings['news_comments_autoactivate'] ? '' : sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_NOTIFICATION_MAIL_LINK'], $manageCommentsUrl);
     $objMail->Body = sprintf($_ARRAYLANG['TXT_NEWS_COMMENT_NOTIFICATION_MAIL_BODY'], $_CONFIG['domainUrl'], $newsMessageTitle, \FWUser::getParsedUserTitle($userId, $name), $title, nl2br($message), $activateCommentTxt);
     $objMail->AddAddress($_CONFIG['coreAdminEmail']);
     if (!$objMail->Send()) {
         \DBG::msg('Sending of notification e-mail failed');
         //DBG::stack();
     }
     return array(true, null);
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:100,代码来源:News.class.php

示例10: send

 function send()
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     $this->_objTpl->setTemplate($this->pageContent);
     // Initialize variables
     $code = substr(md5(rand()), 1, 10);
     $url = \Cx\Core\Routing\Url::fromModuleAndCmd('Ecard', 'show', '', array('code' => $code))->toString();
     // Initialize POST variables
     $id = intval($_POST['selectedEcard']);
     $message = contrexx_addslashes($_POST['ecardMessage']);
     $recipientSalutation = contrexx_stripslashes($_POST['ecardRecipientSalutation']);
     $senderName = contrexx_stripslashes($_POST['ecardSenderName']);
     $senderEmail = \FWValidator::isEmail($_POST['ecardSenderEmail']) ? $_POST['ecardSenderEmail'] : '';
     $recipientName = contrexx_stripslashes($_POST['ecardRecipientName']);
     $recipientEmail = \FWValidator::isEmail($_POST['ecardRecipientEmail']) ? $_POST['ecardRecipientEmail'] : '';
     if (empty($senderEmail) || empty($recipientEmail)) {
         $this->_objTpl->setVariable(array('STATUS_MESSAGE' => $_ARRAYLANG['TXT_ECARD_SENDING_ERROR']));
         return false;
     }
     $query = "\n            SELECT `setting_name`, `setting_value`\n              FROM " . DBPREFIX . "module_ecard_settings";
     $objResult = $objDatabase->Execute($query);
     while (!$objResult->EOF) {
         switch ($objResult->fields['setting_name']) {
             case 'validdays':
                 $validdays = $objResult->fields['setting_value'];
                 break;
                 // Never used
                 //                case 'greetings':
                 //                    $greetings = $objResult->fields['setting_value'];
                 //                    break;
             // Never used
             //                case 'greetings':
             //                    $greetings = $objResult->fields['setting_value'];
             //                    break;
             case 'subject':
                 $subject = $objResult->fields['setting_value'];
                 break;
             case 'emailText':
                 $emailText = strip_tags($objResult->fields['setting_value']);
                 break;
         }
         $objResult->MoveNext();
     }
     $timeToLife = $validdays * 86400;
     // Replace placeholders with used in notification mail with user data
     $emailText = str_replace('[[ECARD_RECIPIENT_SALUTATION]]', $recipientSalutation, $emailText);
     $emailText = str_replace('[[ECARD_RECIPIENT_NAME]]', $recipientName, $emailText);
     $emailText = str_replace('[[ECARD_RECIPIENT_EMAIL]]', $recipientEmail, $emailText);
     $emailText = str_replace('[[ECARD_SENDER_NAME]]', $senderName, $emailText);
     $emailText = str_replace('[[ECARD_SENDER_EMAIL]]', $senderEmail, $emailText);
     $emailText = str_replace('[[ECARD_VALID_DAYS]]', $validdays, $emailText);
     $emailText = str_replace('[[ECARD_URL]]', $url, $emailText);
     $body = $emailText;
     // Insert ecard to DB
     $query = "\n            INSERT INTO `" . DBPREFIX . "module_ecard_ecards` (\n                code, date, TTL, salutation,\n                senderName, senderEmail,\n                recipientName, recipientEmail,\n                message\n            ) VALUES (\n                '" . $code . "',\n                '" . time() . "',\n                '" . $timeToLife . "',\n                '" . addslashes($recipientSalutation) . "',\n                '" . addslashes($senderName) . "',\n                '" . $senderEmail . "',\n                '" . addslashes($recipientName) . "',\n                '" . $recipientEmail . "',\n                '" . $message . "');";
     if ($objDatabase->Execute($query)) {
         $query = "\n                SELECT setting_value\n                  FROM " . DBPREFIX . "module_ecard_settings\n                 WHERE setting_name='motive_{$id}'";
         $objResult = $objDatabase->SelectLimit($query, 1);
         // Copy motive to new file with $code as filename
         $fileExtension = preg_replace('/^.+(\\.[^\\.]+)$/', '$1', $objResult->fields['setting_value']);
         $fileName = $objResult->fields['setting_value'];
         $objFile = new \File();
         if ($objFile->copyFile(ASCMS_ECARD_OPTIMIZED_PATH . '/', $fileName, ASCMS_ECARD_SEND_ECARDS_PATH . '/', $code . $fileExtension)) {
             $objMail = new \phpmailer();
             // Check e-mail settings
             if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once ASCMS_CORE_PATH . '/SmtpSettings.class.php')) {
                 $objSmtpSettings = new \SmtpSettings();
                 if (($arrSmtp = $objSmtpSettings->getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                     $objMail->IsSMTP();
                     $objMail->Host = $arrSmtp['hostname'];
                     $objMail->Port = $arrSmtp['port'];
                     $objMail->SMTPAuth = true;
                     $objMail->Username = $arrSmtp['username'];
                     $objMail->Password = $arrSmtp['password'];
                 }
             }
             // Send notification mail to ecard-recipient
             $objMail->CharSet = CONTREXX_CHARSET;
             $objMail->SetFrom($senderEmail, $senderName);
             $objMail->Subject = $subject;
             $objMail->IsHTML(false);
             $objMail->Body = $body;
             $objMail->AddAddress($recipientEmail);
             if ($objMail->Send()) {
                 $this->_objTpl->setVariable(array('STATUS_MESSAGE' => $_ARRAYLANG['TXT_ECARD_HAS_BEEN_SENT']));
             } else {
                 $this->_objTpl->setVariable(array('STATUS_MESSAGE' => $_ARRAYLANG['TXT_ECARD_MAIL_SENDING_ERROR']));
             }
         }
     } else {
         $this->_objTpl->setVariable(array('STATUS_MESSAGE' => $_ARRAYLANG['TXT_ECARD_SENDING_ERROR']));
     }
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:93,代码来源:Ecard.class.php

示例11: send_email

function send_email($to, $subject, $body, $from = '', $fromname = '', $stmp = true, $sender = '', $host = '', $port = '', $ssl = '', $username = '', $password = '')
{
    global $charset;
    $mail = new phpmailer();
    if (!$stmp) {
        $mail->IsMail();
    } else {
        $mail->IsSMTP();
        $mail->SMTPAuth = true;
        $mail->Host = $host;
        if ($ssl) {
            $mail->SMTPSecure = "ssl";
        }
        if ($port != '') {
            $mail->Port = $port;
        }
        $mail->Username = $username;
        $mail->Password = $password;
    }
    $mail->IsHTML(true);
    $mail->Sender = $sender;
    $mail->FromEmail = $from;
    $mail->FromName = $fromname;
    $mail->Subject = $subject;
    $mail->Body = $body;
    $mail->CharSet = $charset;
    $mail->WordWrap = 50;
    if (is_array($to)) {
        foreach ($to as $email) {
            $mail->AddAddress($email, "");
        }
    } else {
        $mail->AddAddress($to, "");
    }
    if ($fromname != '') {
        $mail->AddReplyTo($from, $fromname);
    }
    $mail->IsHTML(true);
    if (!$mail->Send()) {
        return "Mailer Error: " . $mail->ErrorInfo;
    } else {
        return true;
    }
}
开发者ID:saintho,项目名称:phpdisk,代码行数:44,代码来源:global.func.php

示例12: sendMail

 /**
  * send a mail to the email with the message
  *
  * @static
  * @param integer $uploadId the upload id
  * @param string $subject the subject of the mail for the recipient
  * @param string $email the recipient's mail address
  * @param null|string $message the message for the recipient
  */
 public static function sendMail($uploadId, $subject, $emails, $message = null)
 {
     global $objDatabase, $_CONFIG;
     /**
      * get all file ids from the last upload
      */
     $objResult = $objDatabase->Execute("SELECT `id` FROM " . DBPREFIX . "module_filesharing WHERE `upload_id` = '" . intval($uploadId) . "'");
     if ($objResult !== false && $objResult->RecordCount() > 0) {
         while (!$objResult->EOF) {
             $files[] = $objResult->fields["id"];
             $objResult->MoveNext();
         }
     }
     if (!is_int($uploadId) && empty($files)) {
         $files[] = $uploadId;
     }
     /**
      * init mail data. Mail template, Mailsubject and PhpMailer
      */
     $objMail = $objDatabase->SelectLimit("SELECT `subject`, `content` FROM " . DBPREFIX . "module_filesharing_mail_template WHERE `lang_id` = " . FRONTEND_LANG_ID, 1, -1);
     $content = str_replace(array(']]', '[['), array('}', '{'), $objMail->fields["content"]);
     if (empty($subject)) {
         $subject = $objMail->fields["subject"];
     }
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     if (\Env::get('ClassLoader')->loadFile($cx->getCodeBaseLibraryPath() . '/phpmailer/class.phpmailer.php')) {
         $objMail = new \phpmailer();
         /**
          * Load mail template and parse it
          */
         $objTemplate = new \Cx\Core\Html\Sigma('.');
         $objTemplate->setErrorHandling(PEAR_ERROR_DIE);
         $objTemplate->setTemplate($content);
         $objTemplate->setVariable(array("DOMAIN" => $_CONFIG["domainUrl"], 'MESSAGE' => $message));
         if ($objTemplate->blockExists('filesharing_file')) {
             foreach ($files as $file) {
                 $objTemplate->setVariable(array('FILE_DOWNLOAD' => self::getDownloadLink($file)));
                 $objTemplate->parse('filesharing_file');
             }
         }
         if ($_CONFIG['coreSmtpServer'] > 0 && \Env::get('ClassLoader')->loadFile($cx->getCodeBaseCorePath() . '/SmtpSettings.class.php')) {
             if (($arrSmtp = SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->SetFrom($_CONFIG['coreAdminEmail'], $_CONFIG['coreGlobalPageTitle']);
         $objMail->Subject = $subject;
         $objMail->Body = $objTemplate->get();
         foreach ($emails as $email) {
             $objMail->AddAddress($email);
             $objMail->Send();
             $objMail->ClearAddresses();
         }
     }
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:70,代码来源:FileSharingLib.class.php

示例13: sendMail


//.........这里部分代码省略.........
                     $objTemplate->parse('field_' . $fieldId);
                 } elseif ($objTemplate->blockExists('form_field')) {
                     // parse regular field template block
                     $objTemplate->setVariable(array('FIELD_LABEL' => contrexx_raw2xhtml($fieldLabel), 'FIELD_VALUE' => $htmlValue));
                     $objTemplate->parse('form_field');
                 }
             } elseif ($objTemplate->blockExists('field_' . $fieldId)) {
                 // hide field specific template block, if present
                 $objTemplate->hideBlock('field_' . $fieldId);
             }
         }
         // parse plaintext body
         $tabCount = $maxlength - strlen($fieldLabel);
         $tabs = $tabCount == 0 ? 1 : $tabCount + 1;
         // TODO: what is this all about? - $value is undefined
         if ($arrFormData['fields'][$fieldId]['type'] == 'recipient') {
             $value = $arrRecipients[$value]['lang'][FRONTEND_LANG_ID];
         }
         if (in_array($fieldId, $textAreaKeys)) {
             // we're dealing with a textarea, don't indent value
             $plaintextBody .= $fieldLabel . ":\n" . $plaintextValue . "\n";
         } else {
             $plaintextBody .= $fieldLabel . str_repeat(" ", $tabs) . ": " . $plaintextValue . "\n";
         }
     }
     $arrSettings = $this->getSettings();
     // TODO: this is some fixed plaintext message data -> must be ported to html body
     $message = $_ARRAYLANG['TXT_CONTACT_TRANSFERED_DATA_FROM'] . " " . $_CONFIG['domainUrl'] . "\n\n";
     if ($arrSettings['fieldMetaDate']) {
         $message .= $_ARRAYLANG['TXT_CONTACT_DATE'] . " " . date(ASCMS_DATE_FORMAT, $arrFormData['meta']['time']) . "\n\n";
     }
     $message .= $plaintextBody . "\n\n";
     if ($arrSettings['fieldMetaHost']) {
         $message .= $_ARRAYLANG['TXT_CONTACT_HOSTNAME'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['host']) . "\n";
     }
     if ($arrSettings['fieldMetaIP']) {
         $message .= $_ARRAYLANG['TXT_CONTACT_IP_ADDRESS'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['ipaddress']) . "\n";
     }
     if ($arrSettings['fieldMetaLang']) {
         $message .= $_ARRAYLANG['TXT_CONTACT_BROWSER_LANGUAGE'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['lang']) . "\n";
     }
     $message .= $_ARRAYLANG['TXT_CONTACT_BROWSER_VERSION'] . " : " . contrexx_raw2xhtml($arrFormData['meta']['browser']) . "\n";
     if (@(include_once \Env::get('cx')->getCodeBaseLibraryPath() . '/phpmailer/class.phpmailer.php')) {
         $objMail = new \phpmailer();
         if ($_CONFIG['coreSmtpServer'] > 0 && @(include_once \Env::get('cx')->getCodeBaseCorePath() . '/SmtpSettings.class.php')) {
             if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->From = $_CONFIG['coreAdminEmail'];
         $objMail->FromName = $senderName;
         if (!empty($replyAddress)) {
             $objMail->AddReplyTo($replyAddress);
             if ($arrFormData['sendCopy'] == 1) {
                 $objMail->AddAddress($replyAddress);
             }
             if ($arrFormData['useEmailOfSender'] == 1) {
                 $objMail->From = $replyAddress;
             }
         }
         $objMail->Subject = $arrFormData['subject'];
         if ($isHtml) {
             $objMail->Body = $objTemplate->get();
             $objMail->AltBody = $message;
         } else {
             $objMail->IsHTML(false);
             $objMail->Body = $message;
         }
         // attach submitted files to email
         if (count($arrFormData['uploadedFiles']) > 0 && $arrFormData['sendAttachment'] == 1) {
             foreach ($arrFormData['uploadedFiles'] as $arrFilesOfField) {
                 foreach ($arrFilesOfField as $file) {
                     $objMail->AddAttachment(\Env::get('cx')->getWebsiteDocumentRootPath() . $file['path'], $file['name']);
                 }
             }
         }
         if ($chosenMailRecipient !== null) {
             if (!empty($chosenMailRecipient)) {
                 $objMail->AddAddress($chosenMailRecipient);
                 $objMail->Send();
                 $objMail->ClearAddresses();
             }
         } else {
             foreach ($arrFormData['emails'] as $sendTo) {
                 if (!empty($sendTo)) {
                     $objMail->AddAddress($sendTo);
                     $objMail->Send();
                     $objMail->ClearAddresses();
                 }
             }
         }
     }
     return true;
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:101,代码来源:Contact.class.php

示例14: sendMail

 /**
  * Initialize the mail functionality to the recipient
  *
  * @param \Cx\Modules\Calendar\Controller\CalendarEvent $event          Event instance
  * @param integer                                       $actionId       Mail action id
  * @param integer                                       $regId          Registration id
  * @param string                                        $mailTemplate   Mail template id
  */
 function sendMail(CalendarEvent $event, $actionId, $regId = null, $mailTemplate = null)
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     $this->mailList = array();
     // Loads the mail template which needs for this action
     $this->loadMailList($actionId, $mailTemplate);
     if (!empty($this->mailList)) {
         $objRegistration = null;
         if (!empty($regId)) {
             $objRegistration = new \Cx\Modules\Calendar\Controller\CalendarRegistration($event->registrationForm, $regId);
             list($registrationDataText, $registrationDataHtml) = $this->getRegistrationData($objRegistration);
             $query = 'SELECT `v`.`value`, `n`.`default`, `f`.`type`
                       FROM ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_value AS `v`
                       INNER JOIN ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_name AS `n`
                       ON `v`.`field_id` = `n`.`field_id`
                       INNER JOIN ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field AS `f`
                       ON `v`.`field_id` = `f`.`id`
                       WHERE `v`.`reg_id` = ' . $regId . '
                       AND (
                              `f`.`type` = "salutation"
                           OR `f`.`type` = "firstname"
                           OR `f`.`type` = "lastname"
                           OR `f`.`type` = "mail"
                       )';
             $objResult = $objDatabase->Execute($query);
             $arrDefaults = array();
             $arrValues = array();
             if ($objResult !== false) {
                 while (!$objResult->EOF) {
                     if (!empty($objResult->fields['default'])) {
                         $arrDefaults[$objResult->fields['type']] = explode(',', $objResult->fields['default']);
                     }
                     $arrValues[$objResult->fields['type']] = $objResult->fields['value'];
                     $objResult->MoveNext();
                 }
             }
             $regSalutation = !empty($arrValues['salutation']) ? $arrDefaults['salutation'][$arrValues['salutation'] - 1] : '';
             $regFirstname = !empty($arrValues['firstname']) ? $arrValues['firstname'] : '';
             $regLastname = !empty($arrValues['lastname']) ? $arrValues['lastname'] : '';
             $regMail = !empty($arrValues['mail']) ? $arrValues['mail'] : '';
             $regType = $objRegistration->type == 1 ? $_ARRAYLANG['TXT_CALENDAR_REG_REGISTRATION'] : $_ARRAYLANG['TXT_CALENDAR_REG_SIGNOFF'];
             $regSearch = array('[[REGISTRATION_TYPE]]', '[[REGISTRATION_SALUTATION]]', '[[REGISTRATION_FIRSTNAME]]', '[[REGISTRATION_LASTNAME]]', '[[REGISTRATION_EMAIL]]');
             $regReplace = array($regType, $regSalutation, $regFirstname, $regLastname, $regMail);
         }
         $domain = ASCMS_PROTOCOL . "://" . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . "/";
         $date = $this->format2userDateTime(new \DateTime());
         $startDate = $event->startDate;
         $endDate = $event->endDate;
         $eventTitle = $event->title;
         $eventStart = $event->all_day ? $this->format2userDate($startDate) : $this->formatDateTime2user($startDate, $this->getDateFormat() . ' (H:i:s)');
         $eventEnd = $event->all_day ? $this->format2userDate($endDate) : $this->formatDateTime2user($endDate, $this->getDateFormat() . ' (H:i:s)');
         $placeholder = array('[[TITLE]]', '[[START_DATE]]', '[[END_DATE]]', '[[LINK_EVENT]]', '[[LINK_REGISTRATION]]', '[[USERNAME]]', '[[FIRSTNAME]]', '[[LASTNAME]]', '[[URL]]', '[[DATE]]');
         $recipients = $this->getSendMailRecipients($actionId, $event, $regId, $objRegistration);
         $objMail = new \phpmailer();
         if ($_CONFIG['coreSmtpServer'] > 0) {
             $arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer']);
             if ($arrSmtp !== false) {
                 $objMail->IsSMTP();
                 $objMail->Host = $arrSmtp['hostname'];
                 $objMail->Port = $arrSmtp['port'];
                 $objMail->SMTPAuth = true;
                 $objMail->Username = $arrSmtp['username'];
                 $objMail->Password = $arrSmtp['password'];
             }
         }
         $objMail->CharSet = CONTREXX_CHARSET;
         $objMail->SetFrom($_CONFIG['coreAdminEmail'], $_CONFIG['coreGlobalPageTitle']);
         foreach ($recipients as $mailAdress => $langId) {
             if (!empty($mailAdress)) {
                 $langId = $this->getSendMailLangId($actionId, $mailAdress, $langId);
                 if ($objUser = \FWUser::getFWUserObject()->objUser->getUsers($filter = array('email' => $mailAdress, 'is_active' => true))) {
                     $userNick = $objUser->getUsername();
                     $userFirstname = $objUser->getProfileAttribute('firstname');
                     $userLastname = $objUser->getProfileAttribute('lastname');
                 } else {
                     $userNick = $mailAdress;
                     if (!empty($regId) && $mailAdress == $regMail) {
                         $userFirstname = $regFirstname;
                         $userLastname = $regLastname;
                     } else {
                         $userFirstname = '';
                         $userLastname = '';
                     }
                 }
                 $mailTitle = $this->mailList[$langId]['mail']->title;
                 $mailContentText = !empty($this->mailList[$langId]['mail']->content_text) ? $this->mailList[$langId]['mail']->content_text : strip_tags($this->mailList[$langId]['mail']->content_html);
                 $mailContentHtml = !empty($this->mailList[$langId]['mail']->content_html) ? $this->mailList[$langId]['mail']->content_html : $this->mailList[$langId]['mail']->content_text;
                 // actual language of selected e-mail template
                 $contentLanguage = $this->mailList[$langId]['lang_id'];
                 if ($actionId == self::MAIL_NOTFY_NEW_APP && $event->arrSettings['confirmFrontendEvents'] == 1) {
                     $eventLink = $domain . "/cadmin/index.php?cmd={$this->moduleName}&act=modify_event&id={$event->id}&confirm=1";
                 } else {
//.........这里部分代码省略.........
开发者ID:Niggu,项目名称:cloudrexx,代码行数:101,代码来源:CalendarMailManager.class.php

示例15: email_user

/** 
 * Always use this function for all emails to users
 * 
 * @param object $userto user object to send email to. must contain firstname,lastname,preferredname,email
 * @param object $userfrom user object to send email from. If null, email will come from mahara
 * @param string $subject email subject
 * @param string $messagetext text version of email
 * @param string $messagehtml html version of email (will send both html and text)
 * @param array  $customheaders email headers
 * @throws EmailException
 * @throws EmailDisabledException
 */
function email_user($userto, $userfrom, $subject, $messagetext, $messagehtml = '', $customheaders = null)
{
    global $IDPJUMPURL;
    static $mnetjumps = array();
    if (!get_config('sendemail')) {
        // You can entirely disable Mahara from sending any e-mail via the
        // 'sendemail' configuration variable
        return true;
    }
    if (empty($userto)) {
        throw new InvalidArgumentException("empty user given to email_user");
    }
    if (!($mailinfo = can_receive_email($userto))) {
        throw new EmailDisabledException("email for this user has been disabled");
    }
    // If the user is a remote xmlrpc user, trawl through the email text for URLs
    // to our wwwroot and modify the url to direct the user's browser to login at
    // their home site before hitting the link on this site
    if (!empty($userto->mnethostwwwroot) && !empty($userto->mnethostapp)) {
        require_once get_config('docroot') . 'auth/xmlrpc/lib.php';
        // Form the request url to hit the idp's jump.php
        if (isset($mnetjumps[$userto->mnethostwwwroot])) {
            $IDPJUMPURL = $mnetjumps[$userto->mnethostwwwroot];
        } else {
            $mnetjumps[$userto->mnethostwwwroot] = $IDPJUMPURL = PluginAuthXmlrpc::get_jump_url_prefix($userto->mnethostwwwroot, $userto->mnethostapp);
        }
        $wwwroot = get_config('wwwroot');
        $messagetext = preg_replace_callback('%(' . $wwwroot . '([\\w_:\\?=#&@/;.~-]*))%', 'localurl_to_jumpurl', $messagetext);
        $messagehtml = preg_replace_callback('%href=["\'`](' . $wwwroot . '([\\w_:\\?=#&@/;.~-]*))["\'`]%', 'localurl_to_jumpurl', $messagehtml);
    }
    require_once 'phpmailer/class.phpmailer.php';
    $mail = new phpmailer();
    // Leaving this commented out - there's no reason for people to know this
    //$mail->Version = 'Mahara ' . get_config('release');
    $mail->PluginDir = get_config('libroot') . 'phpmailer/';
    $mail->CharSet = 'UTF-8';
    $smtphosts = get_config('smtphosts');
    if ($smtphosts == 'qmail') {
        // use Qmail system
        $mail->IsQmail();
    } else {
        if (empty($smtphosts)) {
            // use PHP mail() = sendmail
            $mail->IsMail();
        } else {
            $mail->IsSMTP();
            // use SMTP directly
            $mail->Host = get_config('smtphosts');
            if (get_config('smtpuser')) {
                // Use SMTP authentication
                $mail->SMTPAuth = true;
                $mail->Username = get_config('smtpuser');
                $mail->Password = get_config('smtppass');
            }
        }
    }
    if (get_config('bounces_handle') && isset($mailinfo->owner)) {
        $mail->Sender = generate_email_processing_address($mailinfo->owner, $userto);
    }
    if (empty($userfrom) || $userfrom->email == get_config('noreplyaddress')) {
        if (empty($mail->Sender)) {
            $mail->Sender = get_config('noreplyaddress');
        }
        $mail->From = get_config('noreplyaddress');
        $mail->FromName = isset($userfrom->id) ? display_name($userfrom, $userto) : get_config('sitename');
        $customheaders[] = 'Precedence: Bulk';
        // Try to avoid pesky out of office responses
        $messagetext .= "\n\n" . get_string('pleasedonotreplytothismessage') . "\n";
        if ($messagehtml) {
            $messagehtml .= "\n\n<p>" . get_string('pleasedonotreplytothismessage') . "</p>\n";
        }
    } else {
        if (empty($mail->Sender)) {
            $mail->Sender = $userfrom->email;
        }
        $mail->From = $userfrom->email;
        $mail->FromName = display_name($userfrom, $userto);
    }
    $replytoset = false;
    if (!empty($customheaders) && is_array($customheaders)) {
        foreach ($customheaders as $customheader) {
            $mail->AddCustomHeader($customheader);
            if (0 === stripos($customheader, 'reply-to')) {
                $replytoset = true;
            }
        }
    }
    if (!$replytoset) {
//.........这里部分代码省略.........
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:101,代码来源:user.php


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