本文整理汇总了PHP中Email::getSystemDefaultEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::getSystemDefaultEmail方法的具体用法?PHP Email::getSystemDefaultEmail怎么用?PHP Email::getSystemDefaultEmail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email::getSystemDefaultEmail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: JobsFailure
function JobsFailure()
{
global $sugar_config;
$gb = new Global_Functions();
$GLOBALS['log']->error("JOBS: JobsFailure: Started.");
$bean = BeanFactory::getBean('E_Enrolments');
$j = 0;
$rstSQL = $bean->db->query("SELECT name, (execute_time + interval 11 hour) as exec_time, `status`, resolution, message FROM job_queue\n where resolution = 'failure' and execute_time > (now() - interval 12 hour) order by execute_time DESC;");
$jobs = '<table border = 1><tbody><tr><td><b>Job Name</b></td><td><b>Exec Date</b></td><td><b>Status</b></td><td><b>Result</b></td><td><b>Message</b></td></tr>';
// Failure JOBS
while ($row = $bean->db->fetchByAssoc($rstSQL)) {
if ($j == 0) {
$j = 1;
}
$jobs .= "<tr><td>" . $row['name'] . "</td><td>" . $row['exec_time'] . "</td><td>" . $row['status'] . "</td><td>" . $row['resolution'] . "</td><td>" . $row['message'] . "</td></tr>";
}
//Hangs Up Jobs
$rstSQL = $bean->db->query("SELECT name, (execute_time + interval 11 hour) as exec_time, `status`, resolution, message FROM job_queue\n where status = 'running' and (execute_time + interval 11 hour) < (now() - interval 1 hour) order by execute_time DESC");
while ($row = $bean->db->fetchByAssoc($rstSQL)) {
if ($j == 0) {
$j = 1;
}
$jobs .= "<tr><td>" . $row['name'] . "</td><td>" . $row['exec_time'] . "</td><td>" . $row['status'] . "</td><td>" . $row['resolution'] . "</td><td>" . $row['message'] . "</td></tr>";
}
$jobs .= "</tbody></table>";
if ($j == 1) {
$strEmailBody = "<html><body><strong>Alarm notification about failure Jobs in CRM</strong><br>" . $jobs . "<br><br> Site: <a href='http://pumpkin.crm/'>Pumpkin CRM</a></body></html>";
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
$toAddresses = array();
$toAddresses['Techsupport'] = $sugar_config['alarm_it_address'];
//SEND EMAIL
if ($gb->_Send_Email($defaults['email'], $defaults['name'], $toAddresses, 'CRM: Failure or Hangs up JOBS Alarm.', '', '', html_entity_decode($strEmailBody), array(), false)) {
$GLOBALS['log']->error("JobsFailure: List of failure Jobs has been sent to IT.");
return true;
} else {
$GLOBALS['log']->fatal("JobsFailure: Error send Email.");
return false;
}
}
$GLOBALS['log']->error("JOBS: JobsFailure: Finished.");
return true;
}
示例3: 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()) {
}
}
示例4: substr
if ($_REQUEST['from_addr'] != $_REQUEST['from_addr_name'] . ' <' . $_REQUEST['from_addr_email'] . '>') {
if (false === strpos($_REQUEST['from_addr'], '<')) {
// we have an email only?
$focus->from_addr = $_REQUEST['from_addr'];
$focus->from_name = '';
} else {
// we have a compound string
$newFromAddr = str_replace($old, $new, $_REQUEST['from_addr']);
$focus->from_addr = substr($newFromAddr, 1 + strpos($newFromAddr, '<'), strpos($newFromAddr, '>') - strpos($newFromAddr, '<') - 1);
$focus->from_name = substr($newFromAddr, 0, strpos($newFromAddr, '<') - 1);
}
} elseif (!empty($_REQUEST['from_addr_email']) && isset($_REQUEST['from_addr_email'])) {
$focus->from_addr = $_REQUEST['from_addr_email'];
$focus->from_name = $_REQUEST['from_addr_name'];
} else {
$focus->from_addr = $focus->getSystemDefaultEmail();
}
//// REPLY PROCESSING
///////////////////////////////////////////////////////////////////////////
if ($focus->send()) {
$focus->status = 'sent';
} else {
$focus->status = 'send_error';
}
}
$focus->to_addrs = $_REQUEST['to_addrs'];
$focus->cc_addrs = $_REQUEST['cc_addrs'];
$focus->bcc_addrs = $_REQUEST['bcc_addrs'];
$focus->from_addr = $_REQUEST['from_addr'];
// delete the existing relationship of all the email addresses with this email
$query = "update emails_email_addr_rel set deleted = 1 WHERE email_id = '{$focus->id}'";
示例5: in
require_once 'modules/Emails/Email.php';
/* 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();
示例6: explode
if (!empty($focus->service)) {
// will always have 2 values: /tls || /notls and /validate-cert || /novalidate-cert
$exServ = explode('::', $focus->service);
if ($exServ[0] == 'tls') {
$tls = $app_list_strings['dom_email_bool']['bool_true'];
}
if ($exServ[1] == 'validate-cert') {
$cert = $app_list_strings['dom_email_bool']['bool_true'];
}
if (isset($exServ[2]) && !empty($exServ[2]) && $exServ[2] == 'ssl') {
$ssl = $app_list_strings['dom_email_bool']['bool_true'];
}
}
// FROM NAME FROM ADDRESS STRINGS
$email = new Email();
$from = $email->getSystemDefaultEmail();
$default_from_name = $from['name'];
$default_from_addr = $from['email'];
$from_name = '';
$from_addr = '';
$reply_to_name = '';
$reply_to_addr = '';
$distrib_method = '';
$filterDomain = '';
$trashFolder = '';
$sentFolder = '';
$distributionMethod = '';
$create_case_email_template = '';
$create_case_email_template_name = $mod_strings['LBL_NONE'];
$leaveMessagesOnMailServer = $app_strings['LBL_EMAIL_NO'];
//$fromNameAddr = $fromName.' <'.$from['email'].'> <br><em>('.$mod_strings['LBL_SYSTEM_DEFAULT'].')</em>';
示例7: 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;
}
示例8: getSystemDefaultNameAndEmail
function getSystemDefaultNameAndEmail()
{
$email = new Email();
$return = $email->getSystemDefaultEmail();
$prefAddr = $return['email'];
$fullName = $return['name'];
return array('email' => $prefAddr, 'name' => $fullName);
}
示例9: 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;
//.........这里部分代码省略.........
示例10: testgetSystemDefaultEmail
public function testgetSystemDefaultEmail()
{
$email = new Email();
$expected = array('email' => 'do_not_reply@example.com', 'name' => 'SuiteCRM');
$actual = $email->getSystemDefaultEmail();
$this->assertSame($expected, $actual);
}
示例11: 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;
}
}
示例12: elseif
function Email_Invoice($bean, $event, $arguments)
{
if ($bean->send_invoice_email == 1 && ($bean->trans_type == 'CreditMemo' || $bean->trans_type == 'Invoice')) {
$clientId = $this->_get_related_id($bean, 'contacts_trann_trans_1contacts_ida', 'contacts_trann_trans_1');
$clientObj = BeanFactory::getBean('Contacts');
$clientObj->retrieve($clientId);
$sale_person = $this->_getSalesPerson($clientObj);
$itemObj = BeanFactory::getBean('TRANN_Items', $bean->trann_items_id1_c);
$PS = '';
//GET EMAIL TEMPALTE FOR INVOICE
$emailTemp = BeanFactory::getBean('EmailTemplates');
if ($bean->trans_type == 'Invoice') {
if ($bean->amount_paid == 0) {
$emailTemp->retrieve($this->INVOICE_ZERO_TEMPLATE);
} else {
$emailTemp->retrieve($this->INVOICE_TEMPLATE);
}
} elseif ($bean->trans_type == 'CreditMemo') {
$emailTemp->retrieve($this->CREDIT_MEMO_TEMPLATE);
}
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
//SET TO ADDRESSES
$toAddresses = array();
$toAddresses[$clientObj->first_name . ' ' . $clientObj->last_name] = $clientObj->email1;
if ($bean->email_address != '') {
$extraEmails = explode(',', $bean->email_address);
foreach ($extraEmails as $email) {
$toAddresses[$email] = $email;
}
}
//REPLACE VALUES FOR KEYS IN EMAIL TEMPLATE
$data = array($clientObj->first_name . ' ' . $clientObj->last_name, $clientObj->first_name, $bean->amount_total, $itemObj->display_name, $sale_person['sales_full_name'], $sale_person['sales_first_name']);
$keys = array('$contact_name', '$contact_first_name', '$amount', '$product', '$sales_full_name', '$sales_first_name');
$body = str_replace($keys, $data, $emailTemp->body_html);
$subject = str_replace($keys, $data, $emailTemp->subject);
//ATTACH INVOICE PDF
$attachedFiles = array(array('file_location' => "cache/invoices/", 'filename' => $bean->name . ".pdf"));
//SEND EMAIL
$this->_Send_Email($this->BILLING_EMAIL, $defaults['name'], $toAddresses, $subject . ' - ' . $bean->name, 'Contacts', $clientObj->id, $body, $attachedFiles, true);
}
}
示例13: getPreferredEmail
function getPreferredEmail()
{
$ret = array();
$prefName = $this->getPreference('mail_fromname');
$prefAddr = $this->getPreference('mail_fromaddress');
if (isset($prefAddr) && !empty($prefAddr)) {
$ret['name'] = $prefName;
$ret['email'] = $prefAddr;
} elseif (isset($this->email1) && !empty($this->email1)) {
$ret['name'] = trim($this->first_name . ' ' . $this->last_name);
$ret['email'] = $this->email1;
} elseif (isset($this->email2) && !empty($this->email2)) {
$ret['name'] = trim($this->first_name . ' ' . $this->last_name);
$ret['email'] = $this->email2;
} else {
require_once 'modules/Emails/Email.php';
$email = new Email();
$ret = $email->getSystemDefaultEmail();
}
return $ret;
}
示例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: sendInvoice
function sendInvoice($api, $args)
{
$global = new Global_Functions();
//$GLOBALS['log']->error("PT_Dispatch: Args: ".print_r($args,true));
if (isset($args['invoice']) && !empty($args['invoice'])) {
$InvObj = BeanFactory::getBean('TRANN_Trans', $args['invoice']);
if ($InvObj->trans_type == 'Invoice') {
require_once "custom/CustomHandlers/Invoice_PDF.php";
} elseif ($InvObj->trans_type == 'CreditMemo') {
require_once "custom/CustomHandlers/CreditMemo_PDF.php";
}
$InvObj->load_relationship('contacts_trann_trans_1');
$clientObj = current($InvObj->contacts_trann_trans_1->getBeans());
// if(!empty($clients)) $clientObj = current($clients);
} else {
return false;
}
/* $clientId = $global->_get_related_id($this->bean,'contacts_trann_trans_1contacts_ida','contacts_trann_trans_1');
$clientObj = BeanFactory::getBean('Contacts');
$clientObj->retrieve($clientId);*/
if ($InvObj->trans_type == 'Invoice') {
$PDFObj = new Invoice();
} elseif ($InvObj->trans_type == 'CreditMemo') {
$PDFObj = new CreditMemo();
}
//GET INVOICE PRODUCT ITEMS AND PRICE
$items = array();
for ($k = 1; $k < 5; $k++) {
$itemID = 'trann_items_id' . $k . '_c';
$price = 'amount_' . $k;
if ($InvObj->{$itemID} != '' && $InvObj->{$price} != 0) {
$itemObj = BeanFactory::getBean('TRANN_Items', $InvObj->{$itemID});
$taxObj = BeanFactory::getBean('TAXRA_Tax', $itemObj->taxra_tax_id_c);
$items[$k]['name'] = $itemObj->display_name;
$items[$k]['price'] = number_format($InvObj->{$price}, 2);
$amount_net = round((double) $InvObj->{$price} / (1 + (double) $taxObj->rate / 100), 2);
$amount_tax = round((double) $InvObj->{$price} - (double) $amount_net, 2);
$items[$k]['amount_net'] = number_format($amount_net, 2);
$items[$k]['amount_tax'] = number_format($amount_tax, 2);
}
}
//GET PAYMENTS FOR THIS INVOICE
$query = "SELECT m.name as method,pay.* FROM trann_trans_trann_payments_1_c as link, trann_payments as pay,trann_payment_method as m WHERE link.trann_trans_trann_payments_1trann_trans_ida = '" . $InvObj->id . "' AND link.deleted=0 AND pay.id=link.trann_trans_trann_payments_1trann_payments_idb AND pay.deleted=0 AND m.id=pay.trann_payment_method_id_c AND m.deleted=0 ORDER BY pay.date_entered DESC";
$result = $InvObj->db->query($query, true);
$payments = array();
$j = 0;
while ($row = $InvObj->db->fetchByAssoc($result)) {
$payments[$j]['number'] = $row['name'];
$payments[$j]['method'] = $row['method'];
$payments[$j]['date'] = $row['payment_date'];
if ($row['trann_trans_id1_c'] == $InvObj->id) {
$payments[$j]['amount'] = number_format($row['amount_applied_1'], 2);
}
if ($row['trann_trans_id2_c'] == $InvObj->id) {
$payments[$j]['amount'] = number_format($row['amount_applied_2'], 2);
}
if ($row['trann_trans_id3_c'] == $InvObj->id) {
$payments[$j]['amount'] = number_format($row['amount_applied_3'], 2);
}
$j++;
}
$InvObj->amount_remaining = number_format($InvObj->amount_remaining, 2);
$InvObj->amount_total = number_format($InvObj->amount_total, 2);
//CREATE INVOICE
$PDFObj->Generate_PDF($InvObj, $clientObj, $payments, $items);
//GET EMAIL TEMPALTE FOR INVOICE
$emailTemp = BeanFactory::getBean('EmailTemplates');
if ($InvObj->trans_type == 'Invoice') {
$emailTemp->retrieve($global->INVOICE_TEMPLATE);
} elseif ($InvObj->trans_type == 'CreditMemo') {
$emailTemp->retrieve($global->CREDIT_MEMO_TEMPLATE);
}
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
//SET TO ADDRESSES
$toAddresses = array();
$toAddresses[$clientObj->first_name . ' ' . $clientObj->last_name] = $clientObj->email1;
if ($InvObj->email_address != '') {
$extraEmails = explode(',', $InvObj->email_address);
foreach ($extraEmails as $email) {
$toAddresses[$email] = $email;
}
}
//REPLACE VALUES FOR KEYS IN EMAIL TEMPLATE
$data = array($clientObj->first_name . ' ' . $clientObj->last_name, $clientObj->first_name, $items[1]['name']);
$keys = array('$contact_name', '$contact_first_name', '$product');
$body = str_replace($keys, $data, $emailTemp->body_html);
$subject = str_replace($keys, $data, $emailTemp->subject);
//ATTACH INVOICE PDF
$attachedFiles = array(array('file_location' => "cache/invoices/", 'filename' => $InvObj->name . ".pdf"));
//SEND EMAIL
if (!$global->_Send_Email($defaults['email'], $defaults['name'], $toAddresses, $subject . ' - ' . $InvObj->name, 'Contacts', $clientObj->id, $body, $attachedFiles, true)) {
return false;
} else {
return true;
}
}