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


PHP SugarPHPMailer::AddAddress方法代码示例

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


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

示例1: sendReminders

 /**
  * send reminders
  * @param SugarBean $bean
  * @param Administration $admin
  * @param array $recipients
  * @return boolean
  */
 protected function sendReminders(SugarBean $bean, Administration $admin, $recipients)
 {
     global $sugar_config;
     $user = new User();
     $user->retrieve($bean->created_by);
     $OBCharset = $GLOBALS['locale']->getPrecedentPreference('default_email_charset');
     ///////////////////EMAIL///////////////////////////
     require_once "include/SugarPHPMailer.php";
     $mail = new SugarPHPMailer();
     $mail->setMailerForSystem();
     if (empty($admin->settings['notify_send_from_assigning_user'])) {
         $from_address = $admin->settings['notify_fromaddress'];
         $from_name = $admin->settings['notify_fromname'] ? "" : $admin->settings['notify_fromname'];
     } else {
         $from_address = $user->emailAddress->getReplyToAddress($user);
         $from_name = $user->full_name;
     }
     $mail->From = $from_address;
     $mail->FromName = $from_name;
     $mail->Body = "Напоминание о сделке '{$bean->name}' - {$sugar_config['site_url']}/index.php?action=DetailView&module=Opportunities&record={$bean->id}";
     $mail->Subject = "SugarCRM::Напоминание о сделке";
     $oe = new OutboundEmail();
     $oe = $oe->getSystemMailerSettings();
     if (empty($oe->mail_smtpserver)) {
         $GLOBALS['log']->fatal("Email Reminder: error sending email, system smtp server is not set");
         return;
     }
     foreach ($recipients as $r) {
         $mail->ClearAddresses();
         $mail->AddAddress($r['email'], $GLOBALS['locale']->translateCharsetMIME(trim($r['name']), 'UTF-8', $OBCharset));
         $mail->prepForOutbound();
         if (!$mail->Send()) {
             $GLOBALS['log']->fatal("Email Reminder: error sending e-mail (method: {$mail->Mailer}), (error: {$mail->ErrorInfo})");
         }
     }
     ///////////////////SMS///////////////////////////
     require_once 'custom/sms/sms.php';
     $sms = new sms();
     $sms->parent_type = 'Users';
     foreach ($recipients as $r) {
         $sms->parent_id = $r['id'];
         $sms->pname = $r['name'];
         $type = "Напоминание о сделке ";
         $text = $type . $bean->name;
         /*if($sms->send_message($r['number'], $text) == "SENT")
         		return true;
                   else
         		return false;*/
     }
     ///////////////////ALERT/////////////////////////// !TODO
     /*$timeStart = strtotime($db->fromConvert($bean->date_start, 'datetime'));
     		$this->addAlert($app_strings['MSG_JS_ALERT_MTG_REMINDER_CALL'], $bean->name, $app_strings['MSG_JS_ALERT_MTG_REMINDER_TIME'].$timedate->to_display_date_time($db->fromConvert($bean->date_remind, 'datetime')) , $app_strings['MSG_JS_ALERT_MTG_REMINDER_DESC'].$bean->description. $app_strings['MSG_JS_ALERT_MTG_REMINDER_CALL_MSG'] , $timeStart - strtotime($this->now), 'index.php?action=DetailView&module=Opportunities&record=' . $bean->id);
     		*/
     return true;
 }
开发者ID:omusico,项目名称:sugar_work,代码行数:62,代码来源:Reminder.php

示例2: notify_on_delete

 public function notify_on_delete($bean, $event, $arguments)
 {
     //Send an email to the department manager
     require_once "include/SugarPHPMailer.php";
     $email_obj = new Email();
     $defaults = $email_obj->getSystemDefaultEmail();
     $mail = new SugarPHPMailer();
     $mail->setMailerForSystem();
     $mail->From = $defaults["email"];
     $mail->FromName = $defaults["name"];
     $mail->Subject = "Account record deleted";
     $mail->Body = "The account record with ID: " . $bean->id . ", Name: " . $bean->name . ", Address: " . $bean->billing_address_street . ", " . $bean->billing_address_city . ", " . $bean->billing_address_state . ", " . $bean->billing_address_postalcode . ", " . $bean->billing_address_country . " is being deleted.";
     $mail->prepForOutbound();
     $mail->AddAddress("test@test.com");
     @$mail->Send();
 }
开发者ID:mihir-parikh,项目名称:sugarcrm_playground,代码行数:16,代码来源:AccountHooks.php

示例3: sendSugarPHPMail

function sendSugarPHPMail($tos, $subject, $body)
{
    require_once 'include/SugarPHPMailer.php';
    require_once 'modules/Administration/Administration.php';
    global $current_user;
    $mail = new SugarPHPMailer();
    $admin = new Administration();
    $admin->retrieveSettings();
    if ($admin->settings['mail_sendtype'] == "SMTP") {
        $mail->Host = $admin->settings['mail_smtpserver'];
        $mail->Port = $admin->settings['mail_smtpport'];
        if ($admin->settings['mail_smtpauth_req']) {
            $mail->SMTPAuth = TRUE;
            $mail->Username = $admin->settings['mail_smtpuser'];
            $mail->Password = $admin->settings['mail_smtppass'];
        }
        $mail->Mailer = "smtp";
        $mail->SMTPKeepAlive = true;
    } else {
        $mail->mailer = 'sendmail';
    }
    $mail->IsSMTP();
    // send via SMTP
    if ($admin->settings['mail_smtpssl'] == '2') {
        $mail->SMTPSecure = "tls";
    } elseif ($admin->settings['mail_smtpssl'] == '1') {
        $mail->SMTPSecure = "ssl";
    }
    $mail->CharSet = 'UTF-8';
    $mail->From = $admin->settings['notify_fromaddress'];
    $mail->FromName = $admin->settings['notify_fromname'];
    $mail->ContentType = "text/html";
    //"text/plain"
    $mail->IsHTML(true);
    $mail->Subject = $subject;
    $mail->Body = $body;
    foreach ($tos as $name => $address) {
        $mail->AddAddress("{$address}", "{$name}");
    }
    if (!$mail->send()) {
        $GLOBALS['log']->info("sendSugarPHPMail - Mailer error: " . $mail->ErrorInfo);
        return false;
    } else {
        return true;
    }
}
开发者ID:omusico,项目名称:sugar_work,代码行数:46,代码来源:send_mail.php

示例4: SendEmail

 function SendEmail($emailsTo, $emailSubject, $emailBody)
 {
     $emailObj = new Email();
     $defaults = $emailObj->getSystemDefaultEmail();
     $mail = new SugarPHPMailer();
     $mail->setMailerForSystem();
     $mail->From = $defaults['email'];
     $mail->FromName = $defaults['name'];
     $mail->ClearAllRecipients();
     $mail->ClearReplyTos();
     $mail->Subject = from_html($emailSubject);
     $mail->Body = $emailBody;
     $mail->AltBody = from_html($emailBody);
     $mail->prepForOutbound();
     foreach ($emailsTo as &$value) {
         $mail->AddAddress($value);
     }
     if (@$mail->Send()) {
     }
 }
开发者ID:julieth756,项目名称:SugarCRMLogicHooks,代码行数:20,代码来源:OpportunitiesHooks.php

示例5: sendEmail

 function sendEmail($emailTo, $emailSubject, $emailBody, $altemailBody, SugarBean $relatedBean = null)
 {
     require_once 'modules/Emails/Email.php';
     require_once 'include/SugarPHPMailer.php';
     $emailObj = new Email();
     $emailSettings = getPortalEmailSettings();
     $mail = new SugarPHPMailer();
     $mail->setMailerForSystem();
     $mail->From = $emailSettings['from_address'];
     $mail->FromName = $emailSettings['from_name'];
     $mail->ClearAllRecipients();
     $mail->ClearReplyTos();
     $mail->Subject = from_html($emailSubject);
     $mail->Body = $emailBody;
     $mail->AltBody = $altemailBody;
     $mail->prepForOutbound();
     $mail->AddAddress($emailTo);
     //now create email
     if (@$mail->Send()) {
         $emailObj->to_addrs = '';
         $emailObj->type = 'archived';
         $emailObj->deleted = '0';
         $emailObj->name = $mail->Subject;
         $emailObj->description = $mail->AltBody;
         $emailObj->description_html = $mail->Body;
         $emailObj->from_addr = $mail->From;
         if ($relatedBean instanceof SugarBean && !empty($relatedBean->id)) {
             $emailObj->parent_type = $relatedBean->module_dir;
             $emailObj->parent_id = $relatedBean->id;
         }
         $emailObj->date_sent = TimeDate::getInstance()->nowDb();
         $emailObj->modified_user_id = '1';
         $emailObj->created_by = '1';
         $emailObj->status = 'sent';
         $emailObj->save();
     }
 }
开发者ID:BMLP,项目名称:memoryhole-ansible,代码行数:37,代码来源:updatePortal.php

示例6: enviarEmail

 public static function enviarEmail($asunto, $mensaje, $direcciones, $from)
 {
     require_once "include/SugarPHPMailer.php";
     $mailer = new SugarPHPMailer();
     $mailer->Subject = $asunto;
     $mailer->From = $from['from'];
     $mailer->FromName = $from['from_name'];
     foreach ($direcciones as $email) {
         $mailer->AddAddress($email);
     }
     $mailer->Body = $mensaje;
     $mailer->prepForOutbound();
     $mailer->setMailerForSystem();
     $mailer->IsHTML(true);
     if ($mailer->Send()) {
         return true;
     } else {
         $GLOBALS['log']->info("No se ha podido enviar el correo electronico:  " . $mailer->ErrorInfo);
         return false;
     }
 }
开发者ID:juanOspina13,项目名称:SRX,代码行数:21,代码来源:FnCrm.php

示例7: Email

        $idx++;
        $emailbody[$idx]['email'] = "CS@globalgroup.us";
        $emailbody[$idx]['subject'] = "CS All Unassigned Case Report";
        $emailbody[$idx]['body'] .= "The following cases are unassigned :<br /><br />";
        $emailbody[$idx]['body'] .= "<a href='" . $row['link'] . "'>" . $row['case_number'] . " - " . $row['name'] . "</a><br />";
        $prevemail = "CS@globalgroup.us";
    } else {
        $emailbody[$idx]['body'] .= "<a href='" . $row['link'] . "'>" . $row['case_number'] . " - " . $row['name'] . "</a><br />";
        $prevemail = "CS@globalgroup.us";
    }
}
/* Send out emails */
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
$mail = new SugarPHPMailer();
$mail->setMailerForSystem();
$mail->From = $defaults['email'];
$mail->FromName = $defaults['name'];
foreach ($emailbody as $data) {
    $mail->ClearAllRecipients();
    $mail->ClearReplyTos();
    $mail->Subject = $data['subject'];
    $mail->IsHTML(true);
    $mail->Body = $data['body'];
    $mail->AltBody = $data['body'];
    $mail->prepForOutbound();
    $mail->AddAddress($data['email']);
    $mail->Send();
}
/* Clean up shop */
$mail->SMTPClose();
开发者ID:aldridged,项目名称:gtg-sugar,代码行数:31,代码来源:casegroupcs.php

示例8:

    echo $app_strings['LBL_EMAIL_TEMPLATE_EDIT_PLAIN_TEXT'];
    $new_pwd = '4';
    return;
}
if ($mail->Mailer == 'smtp' && $mail->Host == '' && $current_user->is_admin) {
    echo $mod_strings['ERR_SERVER_SMTP_EMPTY'];
    $new_pwd = '4';
    return;
}
$mail->prepForOutbound();
$hasRecipients = false;
if (!empty($itemail)) {
    if ($hasRecipients) {
        $mail->AddBCC($itemail);
    } else {
        $mail->AddAddress($itemail);
    }
    $hasRecipients = true;
}
$success = false;
if ($hasRecipients) {
    $success = @$mail->Send();
}
//now create email
if ($success) {
    $emailObj->team_id = 1;
    $emailObj->to_addrs = '';
    $emailObj->type = 'archived';
    $emailObj->deleted = '0';
    $emailObj->name = $mail->Subject;
    $emailObj->description = $mail->Body;
开发者ID:jgera,项目名称:sugarcrm_dev,代码行数:31,代码来源:GeneratePassword.php

示例9: sendEmailPassword

 /**
  * Sends the users password to the email address or sends
  *
  * @param unknown_type $user_id
  * @param unknown_type $password
  */
 function sendEmailPassword($user_id, $password)
 {
     $result = $GLOBALS['db']->query("SELECT email1, email2, first_name, last_name FROM users WHERE id='{$user_id}'");
     $row = $GLOBALS['db']->fetchByAssoc($result);
     global $sugar_config;
     if (empty($row['email1']) && empty($row['email2'])) {
         $_SESSION['login_error'] = 'Please contact an administrator to setup up your email address associated to this account';
         return;
     }
     global $locale;
     $OBCharset = $locale->getPrecedentPreference('default_email_charset');
     $notify_mail = new SugarPHPMailer();
     $notify_mail->CharSet = $sugar_config['default_charset'];
     $notify_mail->AddAddress(!empty($row['email1']) ? $row['email1'] : $row['email2'], $locale->translateCharsetMIME(trim($row['first_name'] . ' ' . $row['last_name']), 'UTF-8', $OBCharset));
     if (empty($_SESSION['authenticated_user_language'])) {
         $current_language = $sugar_config['default_language'];
     } else {
         $current_language = $_SESSION['authenticated_user_language'];
     }
     $notify_mail->Subject = 'Sugar Token';
     $notify_mail->Body = 'Your sugar session authentication token  is: ' . $password;
     $notify_mail->setMailerForSystem();
     $notify_mail->From = 'no-reply@sugarcrm.com';
     $notify_mail->FromName = 'Sugar Authentication';
     if (!$notify_mail->Send()) {
         Log::warn("Notifications: error sending e-mail (method: {$notify_mail->Mailer}), (error: {$notify_mail->ErrorInfo})");
     } else {
         Log::info("Notifications: e-mail successfully sent");
     }
 }
开发者ID:butschster,项目名称:sugarcrm_dev,代码行数:36,代码来源:EmailAuthenticateUser.php

示例10: emails

 function generate_email()
 {
     global $mod_strings;
     global $current_user;
     global $sugar_config;
     global $locale;
     require_once 'include/utils.php';
     $query = 'SELECT name';
     $query .= ' FROM emails';
     $query .= " WHERE deleted=0";
     $query .= " AND name='{$this->pnum}-Estimate'";
     $result = $this->db->query($query, true, " Error filling in additional detail fields: ");
     $n = $this->db->getRowCount($result);
     if ($n == 0) {
         $queryname = 'SELECT user_name';
         $queryname .= ' FROM users';
         $queryname .= " WHERE deleted=0";
         $queryname .= " AND id='{$this->assigned_user_id}'";
         $result_name = $this->db->query($queryname, true, " Error filling in additional detail fields: ");
         $username = $this->db->fetchByAssoc($result_name);
         $to_addrs_names = $username['user_name'];
         $queryemail = 'SELECT email1';
         $queryemail .= ' FROM users';
         $queryemail .= " WHERE deleted=0";
         $queryemail .= " AND id='{$this->assigned_user_id}'";
         $result_email = $this->db->query($queryemail, true, " Error filling in additional detail fields: ");
         $useremail = $this->db->fetchByAssoc($result_email);
         $to_addrs_emails = $useremail['email1'];
         $id = create_guid();
         $from_addr = $current_user->name;
         $from_name = $current_user->email1;
         $name = $this->pnum . '-Estimate';
         $description = $this->pnum . ' is waiting for estimate';
         $query2 = "INSERT into emails (id,  assigned_user_id, created_by, name, status,  to_addrs_names, to_addrs_emails, from_addr, from_name, description, deleted, type, intent) ";
         $query2 .= " VALUES ('{$id}', '{$this->assigned_user_id}', '{$current_user->id}', '{$name}', 'sent', '{$to_addrs_names}', '{$to_addrs_emails}', '{$from_addr}', '{$from_name}', '{$description}', '0', 'out', 'pick') ";
         $this->db->query($query2, true, " Error filling in additional detail fields: ");
         $mail = new SugarPHPMailer();
         $mail->AddAddress($to_addrs_emails, $to_addrs_names);
         $mail->Mailer = "sendmail";
         // FROM ADDRESS
         $mail->From = $from_addr;
         // FROM NAME
         $mail->FromName = $from_name;
         $mail->Sender = $mail->From;
         /* set Return-Path field in header to reduce spam score in emails sent via Sugar's Email module */
         $mail->AddReplyTo($mail->From, $mail->FromName);
         $encoding = version_compare(phpversion(), '5.0', '>=') ? 'UTF-8' : 'ISO-8859-1';
         $mail->Subject = html_entity_decode($name, ENT_QUOTES, $encoding);
         ///////////////////////////////////////////////////////////////////////
         ////	HANDLE EMAIL FORMAT PREFERENCE
         // the if() below is HIGHLY dependent on the Javascript unchecking the Send HTML Email box
         // HTML email
         // plain text only
         $description_html = '';
         $mail->IsHTML(false);
         $mail->Body = wordwrap(from_html($description, 996));
         // wp: if plain text version has lines greater than 998, use base64 encoding
         foreach (explode("\n", $mail->ContentType == "text/html" ? $mail->AltBody : $mail->Body) as $line) {
             if (strlen($line) > 998) {
                 $mail->Encoding = 'base64';
                 break;
             }
         }
         ////	HANDLE EMAIL FORMAT PREFERENCE
         ///////////////////////////////////////////////////////////////////////
         ///////////////////////////////////////////////////////////////////////
         ////    SAVE RAW MESSAGE
         $mail->SetMessageType();
         $raw = $mail->CreateHeader();
         $raw .= $mail->CreateBody();
         $raw_source = urlencode($raw);
         ////    END SAVE RAW MESSAGE
         ///////////////////////////////////////////////////////////////////////
         $GLOBALS['log']->debug('Email sending --------------------- ');
         ///////////////////////////////////////////////////////////////////////
         ////	I18N TRANSLATION
         $mail->prepForOutbound();
         ////	END I18N TRANSLATION
         ///////////////////////////////////////////////////////////////////////
         $mail->Send();
     }
 }
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:82,代码来源:Products.php

示例11: sendEmail

 public function sendEmail($emailTo, $emailSubject, $emailToname, $emailBody, $altemailBody, SugarBean $relatedBean = null, $attachments = array())
 {
     $emailObj = new Email();
     $defaults = $emailObj->getSystemDefaultEmail();
     $mail = new SugarPHPMailer();
     $mail->setMailerForSystem();
     $mail->From = $defaults['email'];
     $mail->FromName = $defaults['name'];
     $mail->ClearAllRecipients();
     $mail->ClearReplyTos();
     $mail->Subject = from_html($emailSubject);
     $mail->Body = $emailBody;
     $mail->AltBody = $altemailBody;
     $mail->handleAttachments($attachments);
     $mail->prepForOutbound();
     $mail->AddAddress($emailTo);
     //now create email
     if (@$mail->Send()) {
         $emailObj->to_addrs = '';
         $emailObj->type = 'out';
         $emailObj->deleted = '0';
         $emailObj->name = $mail->Subject;
         $emailObj->description = $mail->AltBody;
         $emailObj->description_html = $mail->Body;
         $emailObj->from_addr = $mail->From;
         if ($relatedBean instanceof SugarBean && !empty($relatedBean->id)) {
             $emailObj->parent_type = $relatedBean->module_dir;
             $emailObj->parent_id = $relatedBean->id;
         }
         $emailObj->date_sent = TimeDate::getInstance()->nowDb();
         $emailObj->modified_user_id = '1';
         $emailObj->created_by = '1';
         $emailObj->status = 'sent';
         $emailObj->save();
         return true;
     } else {
         return false;
     }
 }
开发者ID:omusico,项目名称:SelkirkCRM,代码行数:39,代码来源:controller.php

示例12: define

<?php

/* Test email script */
if (!defined('sugarEntry')) {
    define('sugarEntry', true);
}
require_once 'include/entryPoint.php';
require_once 'include/SugarPHPMailer.php';
require_once 'modules/Emails/Email.php';
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
$mail = new SugarPHPMailer();
$mail->setMailerForSystem();
$mail->From = $defaults['email'];
$mail->FromName = $defaults['name'];
$mail->ClearAllRecipients();
$mail->ClearReplyTos();
$mail->Subject = "Test Email Script";
$mail->IsHTML(true);
$mail->Body = "<i>Body Text</i>";
$mail->AltBody = "Body Text";
$mail->prepForOutbound();
$mail->AddAddress("daldridge@globalgroup.us");
$mail->Send();
$mail->SMTPClose();
开发者ID:aldridged,项目名称:gtg-sugar,代码行数:25,代码来源:testemail.php

示例13: in

/* Query database to get case aging */
$query = 'select c.case_number,c.name,concat("http://dcmaster.mydatacom.com/index.php?module=Cases&action=DetailView&record=",c.id) as link from cases as c where c.id not in (select distinct case_id from projects_cases) and c.account_id is null and c.status="New" and c.deleted=0;';
$db = DBManagerFactory::getInstance();
$result = $db->query($query, true, 'Case Unassigned Query Failed');
/* Create email bodies to send */
$linecount = 0;
$emailbody = "The following cases are currently unassigned:<br /><br />";
while (($row = $db->fetchByAssoc($result)) != null) {
    $emailbody .= "<a href='" . $row['link'] . "'>" . $row['case_number'] . " - " . $row['name'] . " </a><br />";
    $linecount++;
}
if ($linecount > 0) {
    /* Send out emails */
    $emailObj = new Email();
    $defaults = $emailObj->getSystemDefaultEmail();
    $mail = new SugarPHPMailer();
    $mail->setMailerForSystem();
    $mail->From = $defaults['email'];
    $mail->FromName = $defaults['name'];
    $mail->ClearAllRecipients();
    $mail->ClearReplyTos();
    $mail->Subject = "Unassigned Case Report";
    $mail->IsHTML(true);
    $mail->Body = $emailbody;
    $mail->AltBody = $emailbody;
    $mail->prepForOutbound();
    $mail->AddAddress('noc@getdatacom.com');
    $mail->Send();
    /* Clean up shop */
    $mail->SMTPClose();
}
开发者ID:aldridged,项目名称:gtg-sugar,代码行数:31,代码来源:caseunassigned.php

示例14: empty

 /**
  * This function handles sending out email notifications when items are first assigned to users.
  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  * All Rights Reserved.
  * Contributor(s): ______________________________________..
  */
 function create_notification_email($notify_user)
 {
     global $sugar_version;
     global $sugar_config;
     global $app_list_strings;
     global $current_user;
     global $locale;
     require_once "XTemplate/xtpl.php";
     require_once "include/SugarPHPMailer.php";
     $notify_address = empty($notify_user->email1) ? from_html($notify_user->email2) : from_html($notify_user->email1);
     $notify_name = empty($notify_user->first_name) ? from_html($notify_user->user_name) : from_html($notify_user->first_name . " " . $notify_user->last_name);
     $GLOBALS['log']->debug("Notifications: user has e-mail defined");
     $notify_mail = new SugarPHPMailer();
     $notify_mail->AddAddress($notify_address, $notify_name);
     if (empty($_SESSION['authenticated_user_language'])) {
         $current_language = $sugar_config['default_language'];
     } else {
         $current_language = $_SESSION['authenticated_user_language'];
     }
     $xtpl = new XTemplate("include/language/{$current_language}.notify_template.html");
     $template_name = $this->object_name;
     $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", $this->object_name);
         $template_name = "Default";
     }
     $xtpl->assign("ASSIGNED_USER", $this->new_assigned_user_name);
     $xtpl->assign("ASSIGNER", $current_user->name);
     $port = '';
     if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
         $port = $_SERVER['SERVER_PORT'];
     }
     $httpHost = $_SERVER['HTTP_HOST'];
     if ($colon = strpos($httpHost, ':')) {
         $httpHost = substr($httpHost, 0, $colon);
     }
     $parsedSiteUrl = parse_url($sugar_config['site_url']);
     $host = $parsedSiteUrl['host'] != $httpHost ? $httpHost : $parsedSiteUrl['host'];
     if (!isset($parsedSiteUrl['port'])) {
         $parsedSiteUrl['port'] = 80;
     }
     $port = $parsedSiteUrl['port'] != 80 ? ":" . $parsedSiteUrl['port'] : '';
     $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 Suite v{$sugar_version}");
     $xtpl->parse($template_name);
     $xtpl->parse($template_name . "_Subject");
     $notify_mail->Body = from_html(trim($xtpl->text($template_name)));
     $notify_mail->Subject = 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:BackupTheBerlios,项目名称:livealphaprint,代码行数:62,代码来源:SugarBean.php

示例15: array

 function _Send_Email($fromAddress, $fromName, $toAddresses, $subject, $module, $bean_id, $body, $attachedFiles = array(), $saveCopy = true)
 {
     global $current_user, $sugar_config;
     if ($sugar_config['dbconfig']['db_host_name'] != '10.2.1.20' && $sugar_config['dbconfig']['db_host_name'] != '127.0.0.1') {
         $send_ok = false;
     } else {
         $send_ok = true;
     }
     //Replace general variables for all email templates.
     $keys = array('$contact_name', '$contact_first_name', '$sales_full_name', '$sales_first_name');
     $vars_count = $this->substr_count_array($body, $keys);
     if (($module == 'Contacts' || $module == 'Leads') && $vars_count > 0) {
         $clientObj = BeanFactory::getBean($module, $bean_id);
         $sale_person = $this->_getSalesPerson($clientObj);
         $data = array($clientObj->first_name . ' ' . $clientObj->last_name, $clientObj->first_name, $sale_person['sales_full_name'], $sale_person['sales_first_name']);
         $body = str_replace($keys, $data, $body);
     }
     //if(!$send_ok) $GLOBALS['log']->error('Mail Service: not a Live Server, trashmail accounts service only. ');
     $emailObj = new Email();
     $defaults = $emailObj->getSystemDefaultEmail();
     $mail = new SugarPHPMailer();
     $mail->setMailerForSystem();
     $mail->From = $fromAddress;
     $mail->FromName = $fromName;
     $mail->Subject = $subject;
     $mail->Body = $body;
     $mail->ContentType = "text/html";
     $mail->prepForOutbound();
     $test_addr = false;
     foreach ($toAddresses as $name => $email) {
         $mail->AddAddress($email, $name);
         if (substr_count($email, '@trashmail') > 0 || $email == 'dsmikhal@gmail.com') {
             $test_addr = true;
         }
     }
     if ($send_ok || $test_addr) {
         if (!empty($attachedFiles)) {
             foreach ($attachedFiles as $files) {
                 $mail->AddAttachment($files['file_location'] . $files['filename'], $files['filename'], 'base64');
             }
         }
         if (@$mail->Send()) {
             if ($saveCopy) {
                 $emailObj->from_addr = $fromAddress;
                 $emailObj->reply_to_addr = implode(',', $toAddresses);
                 $emailObj->to_addrs = implode(',', $toAddresses);
                 $emailObj->name = $subject;
                 $emailObj->type = 'out';
                 $emailObj->status = 'sent';
                 $emailObj->intent = 'pick';
                 $emailObj->parent_type = $module;
                 $emailObj->parent_id = $bean_id;
                 $emailObj->description_html = $body;
                 $emailObj->description = $body;
                 $emailObj->assigned_user_id = $current_user->id;
                 $emailObj->save();
                 if (!empty($attachedFiles)) {
                     foreach ($attachedFiles as $files) {
                         $Notes = BeanFactory::getBean('Notes');
                         $Notes->name = $files['filename'];
                         $Notes->file_mime_type = 'pdf';
                         $Notes->filename = $files['filename'];
                         $Notes->parent_type = 'Emails';
                         $Notes->parent_id = $emailObj->id;
                         $Notes->save();
                         $pdf = file_get_contents($files['file_location'] . $files['filename']);
                         file_put_contents('upload/' . $Notes->id, $pdf);
                     }
                 }
             }
             return true;
         } else {
             $GLOBALS['log']->info("Mailer error: " . $mail->ErrorInfo);
             return false;
         }
     } else {
         $GLOBALS['log']->error('Mail Service: not a Live Server(' . $sugar_config['dbconfig']['db_host_name'] . '), trashmail accounts service only. Cannot send mail to ' . print_r($toAddresses, true));
         $emailObj->from_addr = $fromAddress;
         $emailObj->reply_to_addr = implode(',', $toAddresses);
         $emailObj->to_addrs = implode(',', $toAddresses);
         $emailObj->name = 'TEST MODE, NOT SENT: ' . $subject;
         $emailObj->type = 'out';
         $emailObj->status = 'NOT sent';
         $emailObj->intent = 'pick';
         $emailObj->parent_type = $module;
         $emailObj->parent_id = $bean_id;
         $emailObj->description_html = $body;
         $emailObj->description = $body;
         $emailObj->assigned_user_id = $current_user->id;
         $emailObj->save();
         return false;
     }
 }
开发者ID:dsmikhal,项目名称:SugarCRM-Integrations,代码行数:93,代码来源:Global_Functions.php


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