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


PHP SugarPHPMailer::msgHTML方法代码示例

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


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

示例1: create_notification_email

 /**
  * This function handles create the email notifications email.
  * @param string $notify_user the user to send the notification email to
  * @return SugarPHPMailer
  */
 public function create_notification_email($notify_user)
 {
     global $sugar_version;
     global $sugar_config;
     global $current_user;
     global $locale;
     global $beanList;
     $OBCharset = $locale->getPrecedentPreference('default_email_charset');
     require_once "include/SugarPHPMailer.php";
     $notify_address = $notify_user->emailAddress->getPrimaryAddress($notify_user);
     $notify_name = $notify_user->full_name;
     $GLOBALS['log']->debug("Notifications: user has e-mail defined");
     $notify_mail = new SugarPHPMailer();
     $notify_mail->addAddress($notify_address, $locale->translateCharsetMIME(trim($notify_name), 'UTF-8', $OBCharset));
     if (empty($_SESSION['authenticated_user_language'])) {
         $current_language = $sugar_config['default_language'];
     } else {
         $current_language = $_SESSION['authenticated_user_language'];
     }
     $xtpl = new XTemplate(get_notify_template_file($current_language));
     if ($this->module_dir == "Cases") {
         $template_name = "Case";
         //we should use Case, you can refer to the en_us.notify_template.html.
     } else {
         $template_name = $beanList[$this->module_dir];
         //bug 20637, in workflow this->object_name = strange chars.
     }
     $this->current_notify_user = $notify_user;
     if (in_array('set_notification_body', get_class_methods($this))) {
         $xtpl = $this->set_notification_body($xtpl, $this);
     } else {
         $xtpl->assign("OBJECT", translate('LBL_MODULE_NAME'));
         $template_name = "Default";
     }
     if (!empty($_SESSION["special_notification"]) && $_SESSION["special_notification"]) {
         $template_name = $beanList[$this->module_dir] . 'Special';
     }
     if ($this->special_notification) {
         $template_name = $beanList[$this->module_dir] . 'Special';
     }
     $xtpl->assign("ASSIGNED_USER", $this->new_assigned_user_name);
     $xtpl->assign("ASSIGNER", $current_user->name);
     $parsedSiteUrl = parse_url($sugar_config['site_url']);
     $host = $parsedSiteUrl['host'];
     if (!isset($parsedSiteUrl['port'])) {
         $parsedSiteUrl['port'] = 80;
     }
     $port = $parsedSiteUrl['port'] != 80 ? ":" . $parsedSiteUrl['port'] : '';
     $path = !empty($parsedSiteUrl['path']) ? $parsedSiteUrl['path'] : "";
     $cleanUrl = "{$parsedSiteUrl['scheme']}://{$host}{$port}{$path}";
     $xtpl->assign("URL", $cleanUrl . "/index.php?module={$this->module_dir}&action=DetailView&record={$this->id}");
     $xtpl->assign("SUGAR", "Sugar v{$sugar_version}");
     $xtpl->parse($template_name);
     $xtpl->parse($template_name . "_Subject");
     // NOTE: Crowdin translation system requires some HTML tags in the template, namely <p> and <br>.
     // These will go into the HTML version of the email, but not into the text version, nor the subject line.
     $tempBody = from_html(trim($xtpl->text($template_name)));
     $notify_mail->msgHTML($tempBody);
     // Improve the text version of the email with some "reverse linkification",
     // making "<a href=link>text</a>" links readable as "text [link]"
     $tempBody = preg_replace('/<a href=([\\"\']?)(.*?)\\1>(.*?)<\\/a>/', "\\3 [\\2]", $tempBody);
     // all the other HTML tags get removed from the text version:
     $notify_mail->AltBody = strip_tags($tempBody);
     // strip_tags is used because subject lines NEVER include HTML tags, according to official specification:
     $notify_mail->Subject = strip_tags(from_html($xtpl->text($template_name . "_Subject")));
     // cn: bug 8568 encode notify email in User's outbound email encoding
     $notify_mail->prepForOutbound();
     return $notify_mail;
 }
开发者ID:samus-aran,项目名称:SuiteCRM,代码行数:74,代码来源:SugarBean.php


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