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


PHP SugarPHPMailer::AddAttachment方法代码示例

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


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

示例1: Email

$excelreport->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
$excelreport->getActiveSheet()->getColumnDimension('D')->setAutoSize(true);
$excelreport->getActiveSheet()->getColumnDimension('E')->setAutoSize(true);
$excelreport->getActiveSheet()->getColumnDimension('F')->setAutoSize(true);
$excelreport->getActiveSheet()->getColumnDimension('G')->setAutoSize(true);
/* Set Formatting on Sheet */
$excelreport->getActiveSheet()->getStyle('A1:G2')->getFont()->setBold(true);
$excelreport->getActiveSheet()->getStyle('A2:G2')->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THICK);
/* Write it out to a temp file */
$objWriter = PHPExcel_IOFactory::createWriter($excelreport, 'Excel2007');
$objWriter->save('/tmp/Tetra-Monthly-Report.xlsx');
/* 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 = "Tetra Monthly Report Draft";
$mail->IsHTML(true);
$mail->Body = $emailbody;
$mail->AltBody = $emailbody;
$mail->AddAttachment('/tmp/Tetra-Monthly-Report.xlsx');
$mail->prepForOutbound();
$mail->AddAddress('daldridge@globalgroup.us');
$mail->Send();
/* Clean up shop */
$mail->SMTPClose();
unlink('/tmp/Tetra-Monthly-Report.xlsx');
开发者ID:aldridged,项目名称:gtg-sugar,代码行数:31,代码来源:casetetramonthly.php

示例2: send


//.........这里部分代码省略.........
                 $file_location = rawurldecode(UploadFile::get_file_path($note->filename, $note->id));
                 $filename = $note->name;
                 $mime_type = $note->file_mime_type;
             }
         } elseif ($note->object_name == 'DocumentRevision') {
             // from Documents
             $filename = $note->id;
             $file_location = getcwd() . '/cache/upload/' . $filename;
             $mime_type = $note->file_mime_type;
         }
         // strip out the "Email attachment label if exists
         $filename = str_replace($mod_strings['LBL_EMAIL_ATTACHMENT'] . ': ', '', $filename);
         // cn: bug 9233 attachment filenames need to be translated into the destination charset.
         $filename = $locale->translateCharset($filename, 'UTF-8', $locale->getPrecedentPreference('default_email_charset'));
         //is attachment in our list of bad files extensions?  If so, append .txt to file location
         //get position of last "." in file name
         $file_ext_beg = strrpos($file_location, ".");
         $file_ext = "";
         //get file extension
         if ($file_ext_beg > 0) {
             $file_ext = substr($file_location, $file_ext_beg + 1);
         }
         //check to see if this is a file with extension located in "badext"
         foreach ($sugar_config['upload_badext'] as $badExt) {
             if (strtolower($file_ext) == strtolower($badExt)) {
                 //if found, then append with .txt to filename and break out of lookup
                 //this will make sure that the file goes out with right extension, but is stored
                 //as a text in db.
                 $file_location = $file_location . ".txt";
                 break;
                 // no need to look for more
             }
         }
         $mail->AddAttachment($file_location, $filename, 'base64', $mime_type);
     }
     ////	END ATTACHMENTS
     ///////////////////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////////////
     ////	HANDLE EMAIL FORMAT PREFERENCE
     // the if() below is HIGHLY dependent on the Javascript unchecking the Send HTML Email box
     // HTML email
     if (isset($_REQUEST['setEditor']) && $_REQUEST['setEditor'] == 1 && trim($_REQUEST['description_html']) != '' || trim($this->description_html) != '') {
         // wp: if body is html, then insert new lines at 996 characters. no effect on client side
         // due to RFC 2822 which limits email lines to 998
         $mail->IsHTML(true);
         $body = from_html(wordwrap($this->description_html, 996));
         $mail->Body = $body;
         // if alternative body is defined, use that, else, striptags the HTML part
         if (trim($this->description) == '') {
             $plainText = from_html($this->description_html);
             $plainText = strip_tags(br2nl($plainText));
             //$plainText = $locale->translateCharset($plainText, 'UTF-8', $locale->getPrecedentPreference('default_email_charset'));
             $mail->AltBody = $plainText;
             $this->description = $plainText;
         } else {
             $mail->AltBody = wordwrap(from_html($this->description), 996);
         }
         // cn: bug 9709 - html email sent accidentally
         // handle signatures fubar'ing the type
         $sigs = $current_user->getDefaultSignature();
         $htmlSig = trim(str_replace(" ", "", strip_tags(from_html($sigs['signature_html']))));
         $htmlBody = trim(str_replace(" ", "", strip_tags(from_html($this->description_html))));
         if ($htmlSig == $htmlBody) {
             // found just a sig. ignore it.
             $this->description_html = '';
             $mail->IsHTML(false);
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:67,代码来源:Email.php

示例3: 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

示例4: empty

         $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'];
         }
     } else {
         $mail->Mailer = 'sendmail';
     }
     $reportname = empty($_REQUEST["reportname"]) ? $focus->get_summary_text() : $_REQUEST["reportname"];
     $mail->From = $admin->settings['notify_fromaddress'];
     $mail->FromName = empty($admin->settings['notify_fromname']) ? ' ' : $admin->settings['notify_fromname'];
     $mail->Subject = sprintf($mod_strings["LBL_SEND_EMAIL_SUBJECT"], $reportname);
     $mail->Body = sprintf($mod_strings["LBL_SEND_EMAIL_BODY"], date('Y-m-d H:i:s', time()), $reportname);
     $mail->AddAttachment($focus->report_result);
     if ($mail->Send()) {
         $mail_msg = sprintf($mod_strings["LBL_SEND_EMAIL_OK"], $_REQUEST['send_email']);
     } else {
         $mail_msg = $mail->ErrorInfo;
     }
 }
 if (!$is_scheduler) {
     if (!empty($note_url)) {
         header("Location: " . $note_url);
         sugar_die();
     } else {
         if (!empty($cat_url)) {
             header("Location: " . $cat_url);
             sugar_die();
         } else {
开发者ID:aldridged,项目名称:gtg-sugar,代码行数:31,代码来源:ReportOnDemand.php

示例5: sendSugarPHPMail

/**
* Created by iluxovi4 - Убирайте везде эту подпись
* Protected by SugarTalk.ru greshdrtju
=======
*/
function sendSugarPHPMail($tos, $subject, $body, $attach = "", $nameToSend = "", $assigned_user_id, $type)
{
    require_once 'include/SugarPHPMailer.php';
    require_once 'modules/Administration/Administration.php';
    global $current_user;
    $mail = new SugarPHPMailer();
    $admin = new Administration();
    $admin->retrieveSettings();
    $user = new User();
    if ($type == 'Realty') {
        $user_id = $assigned_user_id;
        $user->retrieve($user_id);
        $oe = new OutboundEmail();
        $userSettings = $oe->getUserMailerSettings($user);
        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->Body = $body."<br/> <b style='color: red;'><strong> Важно! </strong> Ответ присылайте на почту: </b>".$userSettings->mail_smtpuser;
        $mail->Body = $body;
        $mail->From = $admin->settings['notify_fromaddress'];
    } elseif ($type == 'Contacts' or $type == 'Accounts') {
        $user_id = $assigned_user_id;
        $user->retrieve($user_id);
        $oe = new OutboundEmail();
        $userSettings = $oe->getUserMailerSettings($user);
        if ($userSettings->mail_sendtype == "SMTP") {
            $mail->Host = $admin->settings['mail_smtpserver'];
            $mail->Port = $admin->settings['mail_smtpport'];
            if ($userSettings->mail_smtpauth_req) {
                $mail->SMTPAuth = TRUE;
                $mail->Username = $userSettings->mail_smtpuser;
                $mail->Password = $userSettings->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->Body = $body;
        $mail->From = $user->email1;
    }
    //$user->retrieve();
    $mail->CharSet = 'UTF-8';
    $mail->FromName = $admin->settings['notify_fromname'];
    $mail->ContentType = "text/html";
    //"text/plain"
    $mail->IsHTML(true);
    $mail->Subject = $subject;
    $mail->AddAttachment($attach, $nameToSend);
    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,代码行数:88,代码来源:send_mail.php

示例6: 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;
//.........这里部分代码省略.........
开发者ID:anmoldeep,项目名称:erp,代码行数:101,代码来源:operations.php


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