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


PHP EmailTemplate::retrieve方法代码示例

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


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

示例1: save

 function save($check_notify = false)
 {
     global $current_user, $sugar_config;
     parent::save($check_notify);
     $email_template = new EmailTemplate();
     if ($_REQUEST['module'] == 'Import') {
         //Don't send email on import
         return;
     }
     $signature = array();
     $addDelimiter = true;
     $aop_config = $sugar_config['aop'];
     if (!empty($this->contact_id)) {
         $emails = $this->getEmailForUser();
         if ($aop_config['user_email_template_id']) {
             $email_template->retrieve($aop_config['user_email_template_id']);
         }
         $addDelimiter = false;
     } elseif ($this->assigned_user_id && !$this->internal) {
         $emails = $this->getEmailForContact();
         if ($aop_config['contact_email_template_id']) {
             $email_template->retrieve($aop_config['contact_email_template_id']);
             $signature = $current_user->getDefaultSignature();
         }
     }
     if ($emails && $email_template) {
         $GLOBALS['log']->info("AOPCaseUpdates: Calling send email");
         $res = $this->sendEmail($emails, $email_template, $signature, $this->case_id, $addDelimiter);
     }
 }
开发者ID:isrealconsulting,项目名称:ic-suite,代码行数:30,代码来源:AOP_Case_Updates.php

示例2: canSendPassword

function canSendPassword()
{
    require_once 'include/SugarPHPMailer.php';
    global $mod_strings;
    global $current_user;
    global $app_strings;
    $mail = new SugarPHPMailer();
    $emailTemp = new EmailTemplate();
    $mail->setMailerForSystem();
    $emailTemp->disable_row_level_security = true;
    if ($current_user->is_admin) {
        if ($emailTemp->retrieve($GLOBALS['sugar_config']['passwordsetting']['generatepasswordtmpl']) == '') {
            return $mod_strings['LBL_EMAIL_TEMPLATE_MISSING'];
        }
        if (empty($emailTemp->body) && empty($emailTemp->body_html)) {
            return $app_strings['LBL_EMAIL_TEMPLATE_EDIT_PLAIN_TEXT'];
        }
        if ($mail->Mailer == 'smtp' && $mail->Host == '') {
            return $mod_strings['ERR_SERVER_SMTP_EMPTY'];
        }
        $email_errors = $mod_strings['ERR_EMAIL_NOT_SENT_ADMIN'];
        if ($mail->Mailer == 'smtp') {
            $email_errors .= "<br>-" . $mod_strings['ERR_SMTP_URL_SMTP_PORT'];
        }
        if ($mail->SMTPAuth) {
            $email_errors .= "<br>-" . $mod_strings['ERR_SMTP_USERNAME_SMTP_PASSWORD'];
        }
        $email_errors .= "<br>-" . $mod_strings['ERR_RECIPIENT_EMAIL'];
        $email_errors .= "<br>-" . $mod_strings['ERR_SERVER_STATUS'];
        return $email_errors;
    } else {
        return $mod_strings['LBL_EMAIL_NOT_SENT'];
    }
}
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:34,代码来源:password_utils.php

示例3: canSendPassword

function canSendPassword()
{
    global $mod_strings, $current_user, $app_strings;
    require_once "modules/OutboundEmailConfiguration/OutboundEmailConfigurationPeer.php";
    if ($current_user->is_admin) {
        $emailTemplate = new EmailTemplate();
        $emailTemplate->disable_row_level_security = true;
        if ($emailTemplate->retrieve($GLOBALS['sugar_config']['passwordsetting']['generatepasswordtmpl']) == '') {
            return $mod_strings['LBL_EMAIL_TEMPLATE_MISSING'];
        }
        if (empty($emailTemplate->body) && empty($emailTemplate->body_html)) {
            return $app_strings['LBL_EMAIL_TEMPLATE_EDIT_PLAIN_TEXT'];
        }
        if (!OutboundEmailConfigurationPeer::validSystemMailConfigurationExists($current_user)) {
            return $mod_strings['ERR_SERVER_SMTP_EMPTY'];
        }
        $emailErrors = $mod_strings['ERR_EMAIL_NOT_SENT_ADMIN'];
        try {
            $config = OutboundEmailConfigurationPeer::getSystemDefaultMailConfiguration();
            if ($config instanceof OutboundSmtpEmailConfiguration) {
                $emailErrors .= "<br>-{$mod_strings['ERR_SMTP_URL_SMTP_PORT']}";
                if ($config->isAuthenticationRequired()) {
                    $emailErrors .= "<br>-{$mod_strings['ERR_SMTP_USERNAME_SMTP_PASSWORD']}";
                }
            }
        } catch (MailerException $me) {
            // might want to report the error
        }
        $emailErrors .= "<br>-{$mod_strings['ERR_RECIPIENT_EMAIL']}";
        $emailErrors .= "<br>-{$mod_strings['ERR_SERVER_STATUS']}";
        return $emailErrors;
    }
    return $mod_strings['LBL_EMAIL_NOT_SENT'];
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:34,代码来源:password_utils.php

示例4: testAssignedUserName

 public function testAssignedUserName()
 {
     global $locale;
     require_once 'include/Localization/Localization.php';
     $locale = new Localization();
     $testName = $locale->getLocaleFormattedName($this->user->first_name, $this->user->last_name);
     $testTemplate = new EmailTemplate();
     $testTemplate->retrieve($this->emailTemplate->id);
     $this->assertEquals($testName, $testTemplate->assigned_user_name, 'Assert that the assigned_user_name is the locale formatted name value');
 }
开发者ID:thsonvt,项目名称:sugarcrm_dev,代码行数:10,代码来源:Bug48800Test.php

示例5: updateUser

 function updateUser($bean, $event, $arguments)
 {
     if (isset($bean->joomla_account_access) && $bean->joomla_account_access != '') {
         global $sugar_config;
         $aop_config = $sugar_config['aop'];
         $template = new EmailTemplate();
         $template->retrieve($aop_config['joomla_account_creation_email_template_id']);
         $object_arr['Contacts'] = $bean->id;
         $body_html = aop_parse_template($template->body_html, $object_arr);
         $body_html = str_replace("\$joomla_pass", $bean->joomla_account_access, $body_html);
         $body_html = str_replace("\$portal_address", $aop_config['joomla_url'], $body_html);
         $body_plain = aop_parse_template($template->body, $object_arr);
         $body_plain = str_replace("\$joomla_pass", $bean->joomla_account_access, $body_plain);
         $body_plain = str_replace("\$portal_address", $aop_config['joomla_url'], $body_plain);
         $this->sendEmail($bean->email1, $template->subject, $body_html, $body_plain, $bean);
     }
 }
开发者ID:BMLP,项目名称:memoryhole-ansible,代码行数:17,代码来源:updatePortal.php

示例6: getTemplateValidationMessages

function getTemplateValidationMessages($templateId)
{
    $msgs = array();
    if (!$templateId) {
        $msgs[] = 'LBL_NO_SELECTED_TEMPLATE';
    } else {
        $template = new EmailTemplate();
        $template->retrieve($templateId);
        if (!$template->subject) {
            $msgs[] = 'LBL_NO_SUBJECT';
        }
        if (!$template->body_html) {
            $msgs[] = 'LBL_NO_HTML_BODY_CONTENTS';
        }
        if (!$template->body) {
            $msgs[] = 'LBL_NO_BODY_CONTENTS';
        }
    }
    return $msgs;
}
开发者ID:sacredwebsite,项目名称:SuiteCRM,代码行数:20,代码来源:WizardCampaignSave.php

示例7: EmailMarketing

 if (!$emailman->verify_campaign($row['marketing_id'])) {
     $GLOBALS['log']->fatal('Error verifying templates for the campaign, exiting');
     continue;
 }
 //verify the email template too..
 //find the template associated with marketing message. make sure that template has a subject and
 //a non-empty body
 if (!isset($template_status[$row['marketing_id']])) {
     if (!class_exists('EmailMarketing')) {
     }
     $current_emailmarketing = new EmailMarketing();
     $current_emailmarketing->retrieve($row['marketing_id']);
     if (!class_exists('EmailTemplate')) {
     }
     $current_emailtemplate = new EmailTemplate();
     $current_emailtemplate->retrieve($current_emailmarketing->template_id);
 }
 //acquire a lock.
 //if the database does not support repeatable read isolation by default, we might get data that does not meet
 //the criteria in the original query, and we care most about the in_queue_date and process_date_time,
 //if they are null or in past(older than 24 horus) then we are okay.
 $lock_query = "UPDATE emailman SET in_queue=1, in_queue_date=" . $db->now() . " WHERE id = " . intval($row['id']);
 $lock_query .= " AND (in_queue ='0' OR in_queue IS NULL OR ( in_queue ='1' AND in_queue_date <= " . $db->convert($db->quoted($timedate->fromString("-1 day")->asDb()), "datetime") . "))";
 //if the query fails to execute.. terminate campaign email process.
 $lock_result = $db->query($lock_query, true, 'Error acquiring a lock for emailman entry.');
 $lock_count = $db->getAffectedRowCount($lock_result);
 //do not process the message if unable to acquire lock.
 if ($lock_count != 1) {
     $GLOBALS['log']->fatal("Error acquiring lock for the emailman entry, skipping email delivery. lock status={$lock_count} " . print_r($row, true));
     continue;
     //do not process this row we will examine it after 24 hrs. the email address based dupe check is in place too.
开发者ID:NALSS,项目名称:SuiteCRM,代码行数:31,代码来源:EmailManDelivery.php

示例8: EmailTemplate

 * All Rights Reserved.
 * Contributor(s): ______________________________________..
 ********************************************************************************/
require_once 'modules/Campaigns/utils.php';
//if campaign_id is passed then we assume this is being invoked from the campaign module and in a popup.
$has_campaign = true;
$inboundEmail = true;
if (!isset($_REQUEST['campaign_id']) || empty($_REQUEST['campaign_id'])) {
    $has_campaign = false;
}
if (!isset($_REQUEST['inboundEmail']) || empty($_REQUEST['inboundEmail'])) {
    $inboundEmail = false;
}
$focus = new EmailTemplate();
if (isset($_REQUEST['record'])) {
    $focus->retrieve($_REQUEST['record']);
}
$old_id = '';
if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
    $old_id = $focus->id;
    // for attachments down below
    $focus->id = "";
}
//setting default flag value so due date and time not required
if (!isset($focus->id)) {
    $focus->date_due_flag = 1;
}
//needed when creating a new case with default values passed in
if (isset($_REQUEST['contact_name']) && is_null($focus->contact_name)) {
    $focus->contact_name = $_REQUEST['contact_name'];
}
开发者ID:sysraj86,项目名称:carnivalcrm,代码行数:31,代码来源:EditView.php

示例9: isset

    } else {
        $leaveMessagesOnMailServer = $app_strings['LBL_EMAIL_NO'];
    }
    // else
    if (!isset($storedOptions['leaveMessagesOnMailServer']) || $storedOptions['leaveMessagesOnMailServer'] == 1) {
        $leaveMessagesOnMailServer = $app_strings['LBL_EMAIL_YES'];
    } else {
        $leaveMessagesOnMailServer = $app_strings['LBL_EMAIL_NO'];
    }
    // else
    $distrib_method = isset($storedOptions['distrib_method']) ? $storedOptions['distrib_method'] : "";
    $create_case_email_template = isset($storedOptions['create_case_email_template']) ? $storedOptions['create_case_email_template'] : "";
}
if (!empty($create_case_email_template)) {
    $et = new EmailTemplate();
    $et->retrieve($create_case_email_template);
    $create_case_email_template_name = $et->name;
}
if (!empty($distrib_method)) {
    $distributionMethod = $app_list_strings['dom_email_distribution_for_auto_create'][$distrib_method];
}
// if
$xtpl = new XTemplate('modules/InboundEmail/DetailView.html');
////	ERRORS from Save
if (isset($_REQUEST['error'])) {
    $xtpl->assign('ERROR', "<div class='error'>" . $mod_strings['ERR_NO_OPTS_SAVED'] . "</div>");
}
//cma, June 24,2008 - Fix bug 21670. User status and group/personal statements are not localized.
$userStatus = $mod_strings['LBL_STATUS_ACTIVE'];
if ('Inactive' == $focus->status) {
    $userStatus = $mod_strings['LBL_STATUS_INACTIVE'];
开发者ID:nerdystudmuffin,项目名称:dashlet-subpanels,代码行数:31,代码来源:DetailView.php

示例10: EmailMarketing

 function verify_campaign($marketing_id)
 {
     if (!isset($this->verified_email_marketing_ids[$marketing_id])) {
         if (!class_exists('EmailMarketing')) {
         }
         $email_marketing = new EmailMarketing();
         $ret = $email_marketing->retrieve($marketing_id);
         if (empty($ret)) {
             $GLOBALS['log']->fatal('Error retrieving marketing message for the email campaign. marketing_id = ' . $marketing_id);
             return false;
         }
         //verify the email template.
         if (empty($email_marketing->template_id)) {
             $GLOBALS['log']->fatal('Error retrieving template for the email campaign. marketing_id = ' . $marketing_id);
             return false;
         }
         if (!class_exists('EmailTemplate')) {
         }
         $emailtemplate = new EmailTemplate();
         $ret = $emailtemplate->retrieve($email_marketing->template_id);
         if (empty($ret)) {
             $GLOBALS['log']->fatal('Error retrieving template for the email campaign. template_id = ' . $email_marketing->template_id);
             return false;
         }
         if (empty($emailtemplate->subject) and empty($emailtemplate->body) and empty($emailtemplate->body_html)) {
             $GLOBALS['log']->fatal('Email template is empty. email_template_id=' . $email_marketing->template_id);
             return false;
         }
     }
     $this->verified_email_marketing_ids[$marketing_id] = 1;
     return true;
 }
开发者ID:jgera,项目名称:sugarcrm_dev,代码行数:32,代码来源:EmailMan.php

示例11: explode

                $sms_field = $e->get_custom_phone_field();
                $msg = "";
                $pid = $_GET['pid'];
                $pids = explode(",", $pid);
                $ptype = $_GET['ptype'];
                $pname = isset($_GET['pname']) ? $_GET['pname'] : "";
                $phone_number = $_GET['num'];
                $onclick = "send_sms();";
                $send_to_multi = $_GET['num'] == 'multi' ? '1' : '0';
            }
            include_once "modules/Administration/sugartalk_smsPhone/sms_editor.php";
            break;
        case "template":
            if (isset($_GET['id'])) {
                $et = new EmailTemplate();
                $et->retrieve($_GET['id']);
                echo $et->body;
            }
            break;
        default:
            echo "";
    }
} else {
    // just draw the gateway settings panel
    $_POST['account_id'] = '123';
    if (isset($_POST['account_id'])) {
        $flag = isset($_POST['use_template']) ? true : false;
        $sms->params['sms_instance_id'] = trim($_POST['account_id']);
        $sms->params['uses_sms_template'] = $flag;
        $sms->params['sugartalk_url'] = trim($_POST['sugartalk_url']);
        $sms->params['sender'] = trim($_POST['sender']);
开发者ID:omusico,项目名称:sugar_work,代码行数:31,代码来源:smsProvider.php

示例12: array

 function run_action(SugarBean $bean, $params = array(), $in_save = false)
 {
     global $sugar_config, $beanList;
     include_once 'modules/EmailTemplates/EmailTemplate.php';
     require_once 'modules/AOW_Actions/actions/templateParser.php';
     $emailTemp = new EmailTemplate();
     $emailTemp->retrieve($params['email_template']);
     if ($emailTemp->id == '') {
         return false;
     }
     $object_arr[$bean->module_dir] = $bean->id;
     foreach ($bean->field_defs as $bean_arr) {
         if ($bean_arr['type'] == 'relate') {
             if (isset($bean_arr['module']) && $bean_arr['module'] != '' && isset($bean_arr['id_name']) && $bean_arr['id_name'] != '' && $bean_arr['module'] != 'EmailAddress') {
                 $relate_bean = new $beanList[$bean_arr['module']]();
                 if (!isset($object_arr[$relate_bean->module_dir])) {
                     $object_arr[$relate_bean->module_dir] = $bean->{$bean_arr}['id_name'];
                 }
             }
         } else {
             if ($bean_arr['type'] == 'link') {
                 if (!isset($bean_arr['module']) || $bean_arr['module'] == '') {
                     $bean_arr['module'] = getRelatedModule($bean->module_dir, $bean_arr['name']);
                 }
                 if (isset($bean_arr['module']) && $bean_arr['module'] != '' && !isset($object_arr[$bean_arr['module']]) && $bean_arr['module'] != 'EmailAddress') {
                     $linkedBeans = $bean->get_linked_beans($bean_arr['name'], $bean_arr['module']);
                     if ($linkedBeans) {
                         $linkedBean = $linkedBeans[0];
                         if (!isset($object_arr[$linkedBean->module_dir])) {
                             $object_arr[$linkedBean->module_dir] = $linkedBean->id;
                         }
                     }
                 }
             }
         }
     }
     $object_arr['Users'] = $bean->assigned_user_id;
     $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}";
     $url = $cleanUrl . "/index.php?module={$bean->module_dir}&action=DetailView&record={$bean->id}";
     $subject = str_replace("\$contact_user", "\$user", $emailTemp->subject);
     $body_html = str_replace("\$contact_user", "\$user", $emailTemp->body_html);
     $body_plain = str_replace("\$contact_user", "\$user", $emailTemp->body);
     $subject = aowTemplateParser::parse_template($subject, $object_arr);
     $body_html = aowTemplateParser::parse_template($body_html, $object_arr);
     $body_html = str_replace("\$url", $url, $body_html);
     $body_plain = aowTemplateParser::parse_template($body_plain, $object_arr);
     $body_plain = str_replace("\$url", $url, $body_plain);
     $emails = $this->getEmailsFromParams($bean, $params);
     return $this->sendEmail($emails['to'], $subject, $body_html, $body_plain, $bean, $emails['cc'], $emails['bcc']);
 }
开发者ID:omusico,项目名称:SelkirkCRM,代码行数:57,代码来源:actionSendEmail.php

示例13: handleAutoresponse

 /**
  * handles auto-responses to inbound emails
  *
  * @param object email Email passed as reference
  */
 function handleAutoresponse(&$email, &$contactAddr)
 {
     if ($this->template_id) {
         $GLOBALS['log']->debug('found auto-reply template id - prefilling and mailing response');
         if ($this->getAutoreplyStatus($contactAddr) && $this->checkOutOfOffice($email->name) && $this->checkFilterDomain($email)) {
             // if we haven't sent this guy 10 replies in 24hours
             if (!empty($this->stored_options)) {
                 $storedOptions = unserialize(base64_decode($this->stored_options));
             }
             // get FROM NAME
             if (!empty($storedOptions['from_name'])) {
                 $from_name = $storedOptions['from_name'];
                 $GLOBALS['log']->debug('got from_name from storedOptions: ' . $from_name);
             } else {
                 // use system default
                 $rName = $this->db->query('SELECT value FROM config WHERE name = \'fromname\'');
                 if (is_resource($rName)) {
                     $aName = $this->db->fetchByAssoc($rName);
                 }
                 if (!empty($aName['value'])) {
                     $from_name = $aName['value'];
                 } else {
                     $from_name = '';
                 }
             }
             // get FROM ADDRESS
             if (!empty($storedOptions['from_addr'])) {
                 $from_addr = $storedOptions['from_addr'];
             } else {
                 $rAddr = $this->db->query('SELECT value FROM config WHERE name = \'fromaddress\'');
                 if (is_resource($rAddr)) {
                     $aAddr = $this->db->fetchByAssoc($rAddr);
                 }
                 if (!empty($aAddr['value'])) {
                     $from_addr = $aAddr['value'];
                 } else {
                     $from_addr = '';
                 }
             }
             // handle to: address, prefer reply-to
             if (!empty($email->reply_to_email)) {
                 $to[0]['email'] = $email->reply_to_email;
             } else {
                 $to[0]['email'] = $email->from_addr;
             }
             // handle to name: address, prefer reply-to
             if (!empty($email->reply_to_name)) {
                 $to[0]['display'] = $email->reply_to_name;
             } elseif (!empty($email->from_name)) {
                 $to[0]['display'] = $email->from_name;
             }
             if (!class_exists('EmailTemplate')) {
                 require_once 'modules/EmailTemplates/EmailTemplate.php';
             }
             $et = new EmailTemplate();
             $et->retrieve($this->template_id);
             if (empty($et->subject)) {
                 $et->subject = '';
             }
             if (empty($et->body)) {
                 $et->body = '';
             }
             if (empty($et->body_html)) {
                 $et->body_html = '';
             }
             $reply = new Email();
             $reply->type = 'out';
             $reply->to_addrs = $to[0]['email'];
             $reply->to_addrs_arr = $to;
             $reply->cc_addrs_arr = array();
             $reply->bcc_addrs_arr = array();
             $reply->from_name = $from_name;
             $reply->from_addr = $from_addr;
             $reply->name = $et->subject;
             $reply->description = $et->body;
             $reply->description_html = $et->body_html;
             $GLOBALS['log']->debug('saving and sending auto-reply email');
             //$reply->save(); // don't save the actual email.
             $reply->send();
             $this->setAutoreplyStatus($contactAddr);
         } else {
             $GLOBALS['log']->debug('InboundEmail: auto-reply threshold reached for email (' . $contactAddr . ') - not sending auto-reply');
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:90,代码来源:InboundEmail.php

示例14: array

 function run_action(SugarBean $bean, $params = array())
 {
     global $sugar_config;
     include_once 'modules/EmailTemplates/EmailTemplate.php';
     $emailTemp = new EmailTemplate();
     $emailTemp->retrieve($params['email_template']);
     $object_arr[$bean->module_dir] = $bean->id;
     $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}";
     $url = $cleanUrl . "/index.php?module={$bean->module_dir}&action=DetailView&record={$bean->id}";
     $subject = $emailTemp->parse_template($emailTemp->subject, $object_arr);
     $body_html = $emailTemp->parse_template($emailTemp->body_html, $object_arr);
     $body_html = str_replace("\$url", $url, $body_html);
     $body_plain = $emailTemp->parse_template($emailTemp->body, $object_arr);
     $body_plain = str_replace("\$url", $url, $body_plain);
     $email = $this->getEmailFromParams($bean, $params);
     return $this->sendEmail($email, $subject, $body_html, $body_plain, $bean);
 }
开发者ID:isrealconsulting,项目名称:ic-suite,代码行数:24,代码来源:actionSendEmail.php

示例15: sendEmailTemplate

 /**
  * Send Email with attachment Report to specified emails
  * @param string $attachFileName
  *  name of report file
  * @param string $attachFilePath
  *  path to report file for read it and attach to email
  * @param array $toAddresses
  *  array with email and names of contacts for send him this email
  *  array( array('email' => EMAIL_ADDR, 'display' => DISPLAY_NAME) )
  * @param string $templateId
  *  optional argument. Id of Email template
  * @param SugarBean $bean
  * 	optional argument, uses for parse template with values of this bean
  * @return array
  * return array with status send email in this format: array('status' => TRUE_OR_FALSE, 'error' => ERROR_MSG)
  */
 public static function sendEmailTemplate($attachFileName, $attachFilePath, $toAddresses, $templateId = '', $bean = NULL)
 {
     global $locale, $current_user, $app_strings;
     $sea = new SugarEmailAddress();
     $answer = array('status' => true, 'error' => '');
     $email = new Email();
     $email->email2init();
     $email->type = 'out';
     $email->status = 'sent';
     $email->id = create_guid();
     $email->new_with_id = true;
     $emailTemplate = new EmailTemplate();
     $emailTemplate->retrieve($templateId);
     if (empty($emailTemplate->subject)) {
         $emailTemplate->subject = $attachFileName;
         //set file name as subject
     }
     $email->name = $emailTemplate->subject;
     $email->description = $emailTemplate->body;
     $email->description_html = '&lt;html&gt;&lt;body&gt;' . $emailTemplate->body_html . '&lt;/body&gt;&lt;/html&gt;';
     $mail = new SugarPHPMailer();
     $mail = $email->setMailer($mail, '', '');
     if (empty($mail->Host)) {
         if ($mail->oe->type == 'system') {
             $answer['error'] = $app_strings['LBL_EMAIL_ERROR_PREPEND'] . $app_strings['LBL_EMAIL_INVALID_SYSTEM_OUTBOUND'];
         } else {
             $answer['error'] = $app_strings['LBL_EMAIL_ERROR_PREPEND'] . $app_strings['LBL_EMAIL_INVALID_PERSONAL_OUTBOUND'];
         }
         $answer['status'] = false;
         return $answer;
     }
     $object_arr = array();
     if ($bean !== NULL) {
         $object_arr[$bean->module_dir] = $bean->id;
     }
     foreach ($toAddresses as $addrMeta) {
         $addr = $addrMeta['email'];
         $beans = $sea->getBeansByEmailAddress($addr);
         foreach ($beans as $bean) {
             if (!isset($object_arr[$bean->module_dir])) {
                 $object_arr[$bean->module_dir] = $bean->id;
             }
         }
     }
     $object_arr['Users'] = $current_user->id;
     $email->description_html = $email->decodeDuringSend(from_html(EmailTemplate::parse_template($email->description_html, $object_arr)));
     $email->description = $email->decodeDuringSend(html_entity_decode(EmailTemplate::parse_template($email->description, $object_arr), ENT_COMPAT, 'UTF-8'));
     $email->name = from_html(EmailTemplate::parse_template($email->name, $object_arr));
     $mail->Body = $email->description_html;
     $mail->AltBody = $email->description;
     $mail->Subject = $email->name;
     $replyToAddress = $current_user->emailAddress->getReplyToAddress($current_user);
     $defaults = $current_user->getPreferredEmail();
     $mail->From = $defaults['email'];
     $mail->FromName = $defaults['name'];
     $mail->Sender = $mail->From;
     /* set Return-Path field in header to reduce spam score in emails sent via Sugar's Email module */
     $replyToName = $mail->FromName;
     $OBCharset = $locale->getPrecedentPreference('default_email_charset');
     if (!empty($replyToAddress)) {
         $mail->AddReplyTo($replyToAddress, $locale->translateCharsetMIME(trim($replyToName), 'UTF-8', $OBCharset));
     } else {
         $mail->AddReplyTo($mail->From, $locale->translateCharsetMIME(trim($mail->FromName), 'UTF-8', $OBCharset));
     }
     foreach ($toAddresses as $addr_arr) {
         if (empty($addr_arr['email'])) {
             continue;
         }
         if (empty($addr_arr['display'])) {
             $mail->AddAddress($addr_arr['email'], "");
         } else {
             $mail->AddAddress($addr_arr['email'], $locale->translateCharsetMIME(trim($addr_arr['display']), 'UTF-8', $OBCharset));
         }
     }
     $mail->AddAttachment($attachFilePath, $attachFileName, 'base64', self::getMimeType($attachFileName));
     $mail->prepForOutbound();
     $mail->Body = $email->decodeDuringSend($mail->Body);
     $mail->AltBody = $email->decodeDuringSend($mail->AltBody);
     if (!$mail->Send()) {
         ob_clean();
         $answer['error'] = $app_strings['LBL_EMAIL_ERROR_PREPEND'] . $mail->ErrorInfo;
         $answer['status'] = false;
         return $answer;
     }
//.........这里部分代码省略.........
开发者ID:omusico,项目名称:sugar_work,代码行数:101,代码来源:Utils.php


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