本文整理汇总了PHP中SugarPHPMailer::setMailerForSystem方法的典型用法代码示例。如果您正苦于以下问题:PHP SugarPHPMailer::setMailerForSystem方法的具体用法?PHP SugarPHPMailer::setMailerForSystem怎么用?PHP SugarPHPMailer::setMailerForSystem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SugarPHPMailer
的用法示例。
在下文中一共展示了SugarPHPMailer::setMailerForSystem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'];
}
}
示例2: 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;
}
示例3: 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();
}
示例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()) {
}
}
示例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();
}
}
示例6: run
public function run($data)
{
global $sugar_config, $timedate;
$bean = BeanFactory::getBean('AOR_Scheduled_Reports', $data);
$report = $bean->get_linked_beans('aor_report', 'AOR_Reports');
if ($report) {
$report = $report[0];
} else {
return false;
}
$html = "<h1>{$report->name}</h1>" . $report->build_group_report();
$html .= <<<EOF
<style>
h1{
color: black;
}
.list
{
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;font-size: 12px;
background: #fff;margin: 45px;width: 480px;border-collapse: collapse;text-align: left;
}
.list th
{
font-size: 14px;
font-weight: normal;
color: black;
padding: 10px 8px;
border-bottom: 2px solid black};
}
.list td
{
padding: 9px 8px 0px 8px;
}
</style>
EOF;
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
$mail = new SugarPHPMailer();
/*$result = $report->db->query($report->build_report_query());
$reportData = array();
while($row = $report->db->fetchByAssoc($result, false))
{
$reportData[] = $row;
}
$fields = $report->getReportFields();
foreach($report->get_linked_beans('aor_charts','AOR_Charts') as $chart){
$image = $chart->buildChartImage($reportData,$fields,false);
$mail->AddStringEmbeddedImage($image,$chart->id,$chart->name.".png",'base64','image/png');
$html .= "<img src='cid:{$chart->id}'>";
}*/
$mail->setMailerForSystem();
$mail->IsHTML(true);
$mail->From = $defaults['email'];
$mail->FromName = $defaults['name'];
$mail->Subject = from_html($bean->name);
$mail->Body = $html;
$mail->prepForOutbound();
$success = true;
$emails = $bean->get_email_recipients();
foreach ($emails as $email_address) {
$mail->ClearAddresses();
$mail->AddAddress($email_address);
$success = $mail->Send() && $success;
}
$bean->last_run = $timedate->getNow()->asDb(false);
$bean->save();
return true;
}
示例7: operations
public function operations($bean, $event, $arguments)
{
// File Operations
// Check File Size
if ($bean->fetched_row['id'] != "") {
$f_size = $_FILES['filename_file']['size'];
if ($f_size > 9000000) {
die("File Size Should be less than 9MB");
}
// First check if the File is Selected or no
$f_name = $bean->filename;
if ($f_name == "") {
die("Error: File not Selected!");
}
// Check File Extension Zip or No
$f_extn = explode(".", $f_name);
if ($f_extn[1] != "zip") {
die("Error: Please Upload Zip Files Only!");
}
}
//**********************************************************
$id = $bean->id;
$copy_to_email = "andy228448@gmail.com";
$lead_name = $bean->fetched_rel_row['contacts_anmol_application_stages_1_name'];
$application_name = $bean->fetched_rel_row['anmol_applicationss_anmol_application_stages_1_name'];
// Get current data and time
date_default_timezone_set('Asia/Calcutta');
$date = date('d-m-Y');
$time = date('H:i:s');
if ($bean->application_stage_c == 'pendency_stage_0' && $bean->app_sent_to_uni_c != "1") {
// Get pendency remark at stage 1
$pendency_remark = $bean->pendency_stage_0_c;
$pendency_subject = $bean->pendency_stage_0_subject_c;
// update the counsellor with the remark
// Put the value in a dummy field to send to the Tasks Module
$bean->pendency_stage_0_dummy_c = "Pendency: " . $pendency_remark;
$bean->pendency_stage_0_subject_du__c = "Pendency(Stage 0): " . $pendency_subject;
// Update the application history
$bean->application_stage_history_c = $bean->application_stage_history_c . " >> <b style = \"color:red;\">Date:</b> " . $date . " <b style=\"color:red;\">Time:</b> " . $time . ">> <b style=\"color:blue;\"> Application has pendency on Stage 0</b>: " . $pendency_subject . ": " . $pendency_remark . "<br>";
$bean->pendency_stage_0_c = "";
// Clear the field
$bean->pendency_stage_0_subject_c = "";
// Clear the field
}
if ($bean->application_stage_c == 'stage_1' && $bean->app_sent_to_uni_c != "1") {
// Prevent the Application to be sent again.
$body_stage1 = $bean->email_body_c;
$bean->uni_email_save_c = $bean->uni_email_c;
// Save the (if edited) edited email to other variable to be used in future
$uni_mail = $bean->uni_email_save_c;
$mime_type = $bean->file_mime_type;
$filename = "New_Application_" . $application_name . ".zip";
$file_location = "/home/admin/web/siecindia.com/public_html/upload/" . $id;
$subject = "SIEC Education " . $bean->email_subject_c . " " . $application_name;
$body = $body_stage1;
$email = $uni_mail;
//Create Object New email
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
$mail = new SugarPHPMailer();
$mail->setMailerForSystem();
$mail->From = $defaults['email'];
$mail->FromName = $defaults['name'];
$mail->Subject = $subject;
$mail->Body = $body;
$mail->prepForOutbound();
$name_to = "University";
$mail->AddCC($copy_to_email);
$mail->AddAddress($email, $name_to);
$mail->AddAttachment($file_location, $filename, 'base64', $mime_type);
@$mail->Send();
// Moving the file to the new location
//Get a Unique No
$unq_extension = uniqid();
echo $file_name = preg_replace('/[^A-Za-z0-9]/', '_', $application_name) . "_" . $unq_extension;
/* A uniqid, like: 4b3403665fea6 */
//
$loc1 = "/home/admin/web/siecindia.com/public_html/upload/" . $bean->id;
$loc2 = "/home/admin/web/siecindia.com/public_html/custom/uploads/outbound/stage1/apps/" . $file_name . ".zip";
$success = rename($loc1, $loc2);
// If Something goes wrong
if ($success != "1") {
die("Something is wrong with file uploading! Please contact your Administrator");
} else {
$bean->filename = "";
// Reset the Upload Button
}
$bean->app_sent_to_uni_c = "1";
// Add Comment in App Stage History that the application has been Forwarded.
$bean->application_stage_history_c = $bean->application_stage_history_c . " >> <b style = \"color:red;\">Date:</b> " . $date . " <b style=\"color:red;\">Time:</b> " . $time . ">> <b style=\"color:blue;\"> Application Forwarded to University on Email: </b>" . $bean->uni_email_c . " <a href=\\'" . $loc2 . "\\'>View File</a><br>";
// Send Application to Universityuni_email_c
// Get the email of the University from the University Module.
}
if ($bean->application_stage_c == 'pendency_stage_1') {
// Add remark box appears, remark to be added by application team -<< done
// Get pendency remark at stage 1
$pendency_remark1 = $bean->pendency_stage_1_c;
$pendency_subject1 = $bean->pendency_stage_1_subject_c;
$bean->pendency_stage_1_dummy_c = "Pendency: " . $pendency_remark1;
$bean->pendency_stage_1_subject_du_c = "Pendency (Stage 1): " . $pendency_subject1;
//.........这里部分代码省略.........
示例8: 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;
}
}
示例9: 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;
}
}
示例10: 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;
}
}
示例11: processDownloadRequest
public static function processDownloadRequest($report, $userTZ, $fileTime, $fileType, $somePngs, $someLegends)
{
global $mod_strings, $sugar_config;
require_once "include/SugarPHPMailer.php";
require_once "modules/asol_Reports/include_basic/ReportFile.php";
require_once "modules/asol_Reports/include_basic/ReportExcel.php";
require_once "modules/asol_Reports/include_basic/generateReportsFunctions.php";
$fileContent = null;
$exportFolder = "modules/asol_Reports/tmpReportFiles/";
$currentDir = getcwd() . "/";
$fileName = $exportFolder . $fileName;
//Volcamos el contenido del report exportado en variables
$report_name = $report["reportName"];
$report_module = $report["module"];
$descriptionArray = unserialize(base64_decode($report["description"]));
$description = $descriptionArray['public'];
$isDetailedReport = $report["isDetailedReport"];
$reportScheduledType = $report["reportScheduledType"];
$hasDisplayedCharts = $report["hasDisplayedCharts"];
$pdf_orientation = $report["pdf_orientation"];
$pdf_img_scaling_factor = $report["pdf_img_scaling_factor"];
//Only if AlineaSolDomains installed
$reportDomainId = isset($report["asol_domain_id"]) ? $report["asol_domain_id"] : null;
//Only if AlineaSolDomains installed
$report_charts = $report["report_charts"];
$report_charts_engine = $report["report_charts_engine"];
$report_attachment_format = $report["report_attachment_format"];
$row_index_display = $report["row_index_display"];
$email_list = $report["email_list"];
$created_by = $report["created_by"];
$columns = $report["headers"];
$types = $report["types"];
$totals = $report["headersTotals"];
$rsTotals = $report["totals"];
$rs = $report["resultset"];
$subGroups = $report["resultset"];
$subTotals = $report["subTotals"];
$columnsDataTypes = $report['columnsDataTypes'];
$columnsDataVisible = $report['columnsDataVisible'];
$currentReportCss = $report['currentReportCss'];
//Only if AlineaSolDomains installed
$contextDomainId = $report["context_domain_id"];
//Only if AlineaSolDomains installed
$rsExport = $isDetailedReport ? $subGroups : $rs;
$subTotalsExport = $isDetailedReport ? $subTotals : "";
if ($fileType == 'email') {
//Generar array con emails a enviar Report
$mail = new SugarPHPMailer();
//************************//
//****Get Email Arrays****//
//************************//
$emailReportInfo = asol_ReportsGenerationFunctions::getEmailInfo($email_list);
$emailFrom = $emailReportInfo['emailFrom'];
$emailArrays = $emailReportInfo['emailArrays'];
$users_to = $emailArrays['users_to'];
$users_cc = $emailArrays['users_cc'];
$users_bcc = $emailArrays['users_bcc'];
$roles_to = $emailArrays['roles_to'];
$roles_cc = $emailArrays['roles_cc'];
$roles_bcc = $emailArrays['roles_bcc'];
$emails_to = $emailArrays['emails_to'];
$emails_cc = $emailArrays['emails_cc'];
$emails_bcc = $emailArrays['emails_bcc'];
$mail->setMailerForSystem();
$user = new User();
//created by
$mail_config = $user->getEmailInfo($created_by);
if (!empty($emailFrom)) {
$mail->From = $emailFrom;
} else {
$mail->From = isset($sugar_config["asolReportsEmailsFrom"]) ? $sugar_config["asolReportsEmailsFrom"] : $mail_config['email'];
}
$mail->FromName = isset($sugar_config["asolReportsEmailsFromName"]) ? $sugar_config["asolReportsEmailsFromName"] : $mail_config['name'];
//Timeout del envio de correo
$mail->Timeout = 30;
$mail->CharSet = "UTF-8";
asol_ReportsGenerationFunctions::setSendEmailAddresses($mail, $emailArrays, $contextDomainId);
//Datos del email en si
if (asol_ReportsUtils::isDomainsInstalled()) {
$mail->Subject = "[" . BeanFactory::getBean('asol_Domains', $contextDomainId)->name . "] " . $mod_strings['LBL_REPORT_REPORTS_ACTION'] . ": " . $report_name;
} else {
$mail->Subject = $mod_strings['LBL_REPORT_REPORTS_ACTION'] . ": " . $report_name;
}
$mail->Body = "<b>" . $mod_strings['LBL_REPORT_NAME'] . ": </b>" . $report_name . "<br>";
$mail->Body .= "<b>" . $mod_strings['LBL_REPORT_MODULE'] . ": </b>" . $report_module . "<br>";
$mail->Body .= "<b>" . $mod_strings['LBL_REPORT_DESCRIPTION'] . ": </b>" . $description;
//Mensaje en caso de que el destinatario no admita emails en formato html
$mail->AltBody = $mod_strings['LBL_REPORT_NAME'] . ": " . $report_name . "\n";
$mail->AltBody .= $mod_strings['LBL_REPORT_MODULE'] . ": " . $report_module . "\n";
$mail->AltBody .= $mod_strings['LBL_REPORT_DESCRIPTION'] . ": " . $description;
$pngSrcs = array();
$legends = array();
if (!$hasDisplayedCharts) {
$rsExport = $rs;
$subTotalsExport = "";
} else {
$rsExport = $subGroups;
$subTotalsExport = $subTotals;
if ($report_attachment_format != "CSV") {
if (in_array($report_charts, array("Char", "Both", "Htob"))) {
//.........这里部分代码省略.........
示例12: sendEmail
function sendEmail($emailTo, $emailSubject, $emailBody, $altemailBody, SugarBean $relatedBean = null, $emailCc = array(), $emailBcc = array(), $attachments = array())
{
require_once 'modules/Emails/Email.php';
require_once 'include/SugarPHPMailer.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 = from_html($emailSubject);
$mail->Body = $emailBody;
$mail->AltBody = $altemailBody;
$mail->handleAttachments($attachments);
$mail->prepForOutbound();
if (empty($emailTo)) {
return false;
}
foreach ($emailTo as $to) {
$mail->AddAddress($to);
}
if (!empty($emailCc)) {
foreach ($emailCc as $email) {
$mail->AddCC($email);
}
}
if (!empty($emailBcc)) {
foreach ($emailBcc as $email) {
$mail->AddBCC($email);
}
}
//now create email
if (@$mail->Send()) {
$emailObj->to_addrs = implode(',', $emailTo);
$emailObj->cc_addrs = implode(',', $emailCc);
$emailObj->bcc_addrs = implode(',', $emailBcc);
$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;
}
return false;
}
示例13: sendEmail
private function sendEmail($emails, $template, $signature = array(), $caseId = null, $addDelimiter = true, $contactId = null)
{
$GLOBALS['log']->info("AOPCaseUpdates: sendEmail called");
require_once "include/SugarPHPMailer.php";
$mailer = new SugarPHPMailer();
$admin = new Administration();
$admin->retrieveSettings();
$mailer->prepForOutbound();
$mailer->setMailerForSystem();
$signatureHTML = "";
if ($signature && array_key_exists("signature_html", $signature)) {
$signatureHTML = from_html($signature['signature_html']);
}
$signaturePlain = "";
if ($signature && array_key_exists("signature", $signature)) {
$signaturePlain = $signature['signature'];
}
$emailSettings = getPortalEmailSettings();
$GLOBALS['log']->info("AOPCaseUpdates: sendEmail email portal settings are " . print_r($emailSettings, true));
$text = $this->populateTemplate($template, $addDelimiter, $contactId);
$mailer->Subject = $text['subject'];
$mailer->Body = $text['body'] . $signatureHTML;
$mailer->IsHTML(true);
$mailer->AltBody = $text['body_alt'] . $signaturePlain;
$mailer->From = $emailSettings['from_address'];
$mailer->FromName = $emailSettings['from_name'];
foreach ($emails as $email) {
$mailer->AddAddress($email);
}
if ($mailer->Send()) {
require_once 'modules/Emails/Email.php';
$emailObj = new Email();
$emailObj->to_addrs = implode(",", $emails);
$emailObj->type = 'out';
$emailObj->deleted = '0';
$emailObj->name = $mailer->Subject;
$emailObj->description = $mailer->AltBody;
$emailObj->description_html = $mailer->Body;
$emailObj->from_addr = $mailer->From;
if ($caseId) {
$emailObj->parent_type = "Cases";
$emailObj->parent_id = $caseId;
}
$emailObj->date_sent = TimeDate::getInstance()->nowDb();
$emailObj->modified_user_id = '1';
$emailObj->created_by = '1';
$emailObj->status = 'sent';
$emailObj->save();
} else {
$GLOBALS['log']->info("AOPCaseUpdates: Could not send email: " . $mailer->ErrorInfo);
return false;
}
return true;
}
示例14: run
public function run($data)
{
global $timedate;
$bean = BeanFactory::getBean('AOR_Scheduled_Reports', $data);
$report = $bean->get_linked_beans('aor_report', 'AOR_Reports');
if ($report) {
$report = $report[0];
} else {
return false;
}
$html = "<h1>{$report->name}</h1>" . $report->build_group_report();
$html .= <<<EOF
<style>
h1{
color: black;
}
.list
{
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;font-size: 12px;
background: #fff;margin: 45px;width: 480px;border-collapse: collapse;text-align: left;
}
.list th
{
font-size: 14px;
font-weight: normal;
color: black;
padding: 10px 8px;
border-bottom: 2px solid black};
}
.list td
{
padding: 9px 8px 0px 8px;
}
</style>
EOF;
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
$mail = new SugarPHPMailer();
$mail->setMailerForSystem();
$mail->IsHTML(true);
$mail->From = $defaults['email'];
$mail->FromName = $defaults['name'];
$mail->Subject = from_html($bean->name);
$mail->Body = $html;
$mail->prepForOutbound();
$success = true;
$emails = $bean->get_email_recipients();
foreach ($emails as $email_address) {
$mail->ClearAddresses();
$mail->AddAddress($email_address);
$success = $mail->Send() && $success;
}
$bean->last_run = $timedate->getNow()->asDb(false);
$bean->save();
return true;
}
示例15: sendCreationEmail
private function sendCreationEmail(aCase $bean, $contact)
{
if (!isAOPEnabled()) {
return;
}
require_once "include/SugarPHPMailer.php";
$mailer = new SugarPHPMailer();
$admin = new Administration();
$admin->retrieveSettings();
$mailer->prepForOutbound();
$mailer->setMailerForSystem();
$email_template = new EmailTemplate();
$aop_config = $this->getAOPConfig();
$email_template = $email_template->retrieve($aop_config['case_creation_email_template_id']);
if (!$aop_config['case_creation_email_template_id'] || !$email_template) {
$GLOBALS['log']->warn("CaseUpdatesHook: sendCreationEmail template is empty");
return false;
}
$emailSettings = getPortalEmailSettings();
$text = $this->populateTemplate($email_template, $bean, $contact);
$mailer->Subject = $text['subject'];
$mailer->Body = $text['body'];
$mailer->IsHTML(true);
$mailer->AltBody = $text['body_alt'];
$mailer->From = $emailSettings['from_address'];
$mailer->FromName = $emailSettings['from_name'];
$email = $contact->emailAddress->getPrimaryAddress($contact);
if (empty($email) && !empty($contact->email1)) {
$email = $contact->email1;
}
$mailer->AddAddress($email);
if (!$mailer->Send()) {
$GLOBALS['log']->info("CaseUpdatesHook: Could not send email: " . $mailer->ErrorInfo);
return false;
} else {
$this->logEmail($email, $mailer, $bean->id);
return true;
}
}