Exemplo n.º 1
0
 /**
  * @param $emailName
  * @dataProvider shouldNotQueryProvider
  */
 public function testShouldNotQuery($emailName)
 {
     $db = $this->getMockForAbstractClass('DBManager');
     $db->expects($this->never())->method('query');
     $ie = new InboundEmail();
     $ie->db = $db;
     $ie->getCaseIdFromCaseNumber($emailName, $this->case);
 }
Exemplo n.º 2
0
 /**
  * @group bug45059
  * @dataProvider intlTextProvider
  * @param string $inputText - our input from the provider, base64'ed
  * @param string $expected - what our goal is
  */
 public function testConvertToUtf8($inputText, $expected)
 {
     // the email server is down, so this test doesn't work
     if (!function_exists('mb_convert_encoding')) {
         $this->markTestSkipped('Need multibyte encoding support');
     }
     $ie = new InboundEmail();
     $inputText = base64_decode($inputText);
     $this->assertEquals($expected, $ie->convertToUtf8($inputText), 'We should be able to convert to UTF-8');
 }
Exemplo n.º 3
0
 public function setUp()
 {
     global $current_user, $currentModule;
     $mod_strings = return_module_language($GLOBALS['current_language'], "Contacts");
     $current_user = SugarTestUserUtilities::createAnonymousUser();
     $this->outbound_id = uniqid();
     $time = date('Y-m-d H:i:s');
     $ib = new InboundEmail();
     $ib->is_personal = 1;
     $ib->name = "Test";
     $ib->port = 3309;
     $ib->mailbox = 'empty';
     $ib->created_by = $current_user->id;
     $ib->email_password = "******";
     $ib->protocol = 'IMAP';
     $stored_options['outbound_email'] = $this->outbound_id;
     $ib->stored_options = base64_encode(serialize($stored_options));
     $ib->save();
     $this->ib = $ib;
 }
Exemplo n.º 4
0
 /**
  * @group 49543
  */
 public function testSetCacheValue()
 {
     global $timedate;
     $ie_id = '123';
     $mailbox = 'trash';
     $time = mt_rand();
     $subj = 'test ' . $time;
     $GLOBALS['db']->query(sprintf("INSERT INTO email_cache (ie_id, mbox, subject, fromaddr, toaddr, imap_uid) \n                                VALUES ('%s', '%s', '%s', '*****@*****.**', '*****@*****.**', '11')", $ie_id, $mailbox, $subj));
     //deleted item from inbox which will be inserted in trash
     $insert[0] = $this->createMail($subj . '_new', '*****@*****.**', '*****@*****.**', '12', '2012-11-11 11:11:11', '12');
     //old trash item which should be updated
     $insert[1] = $this->createMail($subj . '_old', '*****@*****.**', '*****@*****.**', '11', '2011-11-11 11:11:11', '11');
     $ie = new InboundEmail();
     $ie->id = $ie_id;
     $ie->setCacheValue($mailbox, $insert, '', '');
     $fr = $GLOBALS['db']->fetchRow($GLOBALS['db']->query("SELECT subject FROM email_cache WHERE imap_uid = '11'"));
     //if old trash item was updated successfully then 'subject' has new value
     $this->assertTrue($fr['subject'] == $subj . '_old');
     $GLOBALS['db']->query(sprintf("DELETE FROM email_cache WHERE mbox = '%s'", $mailbox));
 }
Exemplo n.º 5
0
/**
 * Return bounce handling mailboxes for campaign.
 *
 * @param unknown_type $emails
 * @param unknown_type $get_box_name, Set it to false if want to get "From Name" other than the InboundEmail Name.
 * @return $get_name=true, bounce handling mailboxes' name; $get_name=false, bounce handling mailboxes' from name.
 */
function get_campaign_mailboxes(&$emails, $get_name = true)
{
    if (!class_exists('InboundEmail')) {
        require 'modules/InboundEmail/InboundEmail.php';
    }
    $query = "select id,name,stored_options from inbound_email where mailbox_type='bounce' and status='Active' and deleted='0'";
    $db = DBManagerFactory::getInstance();
    $result = $db->query($query);
    while (($row = $db->fetchByAssoc($result)) != null) {
        if ($get_name) {
            $return_array[$row['id']] = $row['name'];
        } else {
            $return_array[$row['id']] = InboundEmail::get_stored_options('from_name', $row['name'], $row['stored_options']);
        }
        $emails[$row['id']] = InboundEmail::get_stored_options('from_addr', '*****@*****.**', $row['stored_options']);
    }
    if (empty($return_array)) {
        $return_array = array('' => '');
    }
    return $return_array;
}
Exemplo n.º 6
0
function get_campaign_mailboxes(&$emails)
{
    if (!class_exists('InboundEmail')) {
        require 'modules/InboundEmail/InboundEmail.php';
    }
    $query = "select id,name,stored_options from inbound_email where mailbox_type='bounce' and status='Active'";
    if (empty($db)) {
        if (!class_exists('PearDatabase')) {
        }
        $db =& PearDatabase::getInstance();
    }
    $result = $db->query($query);
    while (($row = $db->fetchByAssoc($result)) != null) {
        $return_array[$row['id']] = $row['name'];
        $emails[$row['id']] = InboundEmail::get_stored_options('from_addr', '*****@*****.**', $row['stored_options']);
    }
    if (empty($return_array)) {
        $return_array = array('' => '');
    }
    return $return_array;
}
Exemplo n.º 7
0
 /**
  * Retrieves an array of I-E beans that the user has team access to including group
  */
 function retrieveAllByGroupIdWithGroupAccounts($id, $includePersonal = true)
 {
     global $current_user;
     $beans = $includePersonal ? $this->retrieveByGroupId($id) : array();
     $teamJoin = '';
     $q = "SELECT DISTINCT inbound_email.id FROM inbound_email {$teamJoin} WHERE is_personal = 0 AND mailbox_type not like 'bounce' AND status = 'Active' AND inbound_email.deleted = 0 ";
     $r = $this->db->query($q, true);
     while ($a = $this->db->fetchByAssoc($r)) {
         $found = false;
         foreach ($beans as $bean) {
             if ($bean->id == $a['id']) {
                 $found = true;
             }
         }
         if (!$found) {
             $ie = new InboundEmail();
             $ie->retrieve($a['id']);
             $beans[$a['id']] = $ie;
         }
     }
     return $beans;
 }
Exemplo n.º 8
0
$showCounts = '';
if ($focus->getPreference('email_show_counts')) {
    $showCounts = 'CHECKED';
}
$xtpl->assign('EMAIL_LINK_TYPE', get_select_options_with_id($app_list_strings['dom_email_link_type'], $focus->getPreference('email_link_type')));
$xtpl->assign('EMAIL_SHOW_COUNTS', $showCounts);
$xtpl->assign('EMAIL_EDITOR_OPTION', get_select_options_with_id($app_list_strings['dom_email_editor_option'], $focus->getPreference('email_editor_option')));
$xtpl->assign('EMAIL_CHARSET', get_select_options_with_id($locale->getCharsetSelect(), $locale->getPrecedentPreference('default_email_charset', $focus)));
/////	END EMAIL OPTIONS
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
////	INBOUND EMAIL SETUP
if (function_exists('imap_open')) {
    require_once 'modules/Emails/Email.php';
    require_once 'modules/InboundEmail/InboundEmail.php';
    $ie = new InboundEmail();
    $email = new Email();
    $xtpl->assign('ROLLOVER', $email->rolloverStyle);
    $xtpl->assign('IE_HIDE', '');
    $xtpl->assign('IE_NAME', $focus->user_name);
    $xtpl->assign('GROUP_ID', $focus->id);
    $xtpl->assign('THEME', $theme);
    $status = get_select_options_with_id($app_list_strings['user_status_dom'], '');
    $mailbox_type = get_select_options_with_id($app_list_strings['dom_email_server_type'], '');
    $mailbox = 'INBOX';
    $beans = $ie->retrieveByGroupId($focus->id);
    if (!empty($beans)) {
        foreach ($beans as $bean) {
            // default MAILBOX value
            if (!empty($bean->mailbox)) {
                $mailbox = $bean->mailbox;
 * In accordance with Section 7(b) of the GNU General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/
require_once 'include/DetailView/DetailView.php';
require_once 'include/SugarFolders/SugarFolders.php';
global $mod_strings;
global $app_strings;
global $sugar_config;
global $timedate;
global $theme;
/* start standard DetailView layout process */
$GLOBALS['log']->info("InboundEmails DetailView");
$focus = new InboundEmail();
$focus->retrieve($_REQUEST['record']);
if (empty($focus->id)) {
    sugar_die($app_strings['ERROR_NO_RECORD']);
}
// if
$focus->checkImap();
$detailView = new DetailView();
$offset = 0;
echo get_module_title($mod_strings['LBL_MODULE_TITLE'], $mod_strings['LBL_MODULE_NAME'] . ": " . $focus->name, true);
/* end standard DetailView layout process */
$exServ = explode('::', $focus->service);
if ($focus->delete_seen == 1) {
    $delete_seen = $mod_strings['LBL_MARK_READ_NO'];
} else {
    $delete_seen = $mod_strings['LBL_MARK_READ_YES'];
Exemplo n.º 10
0
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
 ********************************************************************************/
$_REQUEST['edit'] = 'true';
require_once 'include/SugarFolders/SugarFolders.php';
require_once 'include/templates/TemplateGroupChooser.php';
// GLOBALS
global $mod_strings;
global $app_strings;
global $app_list_strings;
global $current_user;
$focus = new InboundEmail();
$focus->checkImap();
$javascript = new Javascript();
$email = new Email();
/* Start standard EditView setup logic */
$domMailBoxType = $app_list_strings['dom_mailbox_type'];
if (isset($_REQUEST['record'])) {
    $GLOBALS['log']->debug("In InboundEmail edit view, about to retrieve record: " . $_REQUEST['record']);
    $result = $focus->retrieve($_REQUEST['record']);
    if ($result == null) {
        sugar_die($app_strings['ERROR_NO_RECORD']);
    }
} else {
    if (!empty($_REQUEST['mailbox_type'])) {
        $focus->mailbox_type = $_REQUEST['mailbox_type'];
    }
Exemplo n.º 11
0
function pollMonitoredInboxesForBouncedCampaignEmails()
{
    $GLOBALS['log']->info('----->Scheduler job of type pollMonitoredInboxesForBouncedCampaignEmails()');
    global $dictionary;
    $ie = new InboundEmail();
    $r = $ie->db->query('SELECT id FROM inbound_email WHERE deleted=0 AND status=\'Active\' AND mailbox_type=\'bounce\'');
    while ($a = $ie->db->fetchByAssoc($r)) {
        $ieX = new InboundEmail();
        $ieX->retrieve($a['id']);
        $ieX->connectMailserver();
        $GLOBALS['log']->info("Bounced campaign scheduler connected to mail server id: {$a['id']} ");
        $newMsgs = array();
        if ($ieX->isPop3Protocol()) {
            $newMsgs = $ieX->getPop3NewMessagesToDownload();
        } else {
            $newMsgs = $ieX->getNewMessageIds();
        }
        //$newMsgs = $ieX->getNewMessageIds();
        if (is_array($newMsgs)) {
            foreach ($newMsgs as $k => $msgNo) {
                $uid = $msgNo;
                if ($ieX->isPop3Protocol()) {
                    $uid = $ieX->getUIDLForMessage($msgNo);
                } else {
                    $uid = imap_uid($ieX->conn, $msgNo);
                }
                // else
                $GLOBALS['log']->info("Bounced campaign scheduler will import message no: {$msgNo}");
                $ieX->importOneEmail($msgNo, $uid, false, false);
            }
        }
        imap_expunge($ieX->conn);
        imap_close($ieX->conn);
    }
    return true;
}
Exemplo n.º 12
0
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
 ********************************************************************************/
global $current_user;
if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'personal') {
    if ($current_user->hasPersonalEmail()) {
        $ie = new InboundEmail();
        $beans = $ie->retrieveByGroupId($current_user->id);
        if (!empty($beans)) {
            /** @var InboundEmail $bean */
            foreach ($beans as $bean) {
                $bean->importMessages();
            }
        }
    }
    header('Location: index.php?module=Emails&action=ListView&type=inbound&assigned_user_id=' . $current_user->id);
} elseif (isset($_REQUEST['type']) && $_REQUEST['type'] == 'group') {
    $ie = new InboundEmail();
    // this query only polls Group Inboxes
    $r = $ie->db->query('SELECT inbound_email.id FROM inbound_email JOIN users ON inbound_email.group_id = users.id WHERE inbound_email.deleted=0 AND inbound_email.status = \'Active\' AND mailbox_type != \'bounce\' AND users.deleted = 0 AND users.is_group = 1');
    while ($a = $ie->db->fetchByAssoc($r)) {
        $ieX = new InboundEmail();
        $ieX->retrieve($a['id']);
        $ieX->importMessages();
    }
    header('Location: index.php?module=Emails&action=ListViewGroup');
} else {
    // fail gracefully
    header('Location: index.php?module=Emails&action=index');
}
Exemplo n.º 13
0
 *
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
 ********************************************************************************/
global $theme;
global $mod_strings;
global $app_list_strings;
global $current_user;
$focus = new InboundEmail();
$focus->checkImap();
///////////////////////////////////////////////////////////////////////////////
////	I-E SYSTEM SETTINGS
////	handle saving settings
if (isset($_REQUEST['save']) && $_REQUEST['save'] == 'true') {
    $focus->saveInboundEmailSystemSettings('Case', $_REQUEST['inbound_email_case_macro']);
}
////	END I-E SYSTEM SETTINGS
///////////////////////////////////////////////////////////////////////////////
if (is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {
    $ListView->setHeaderText("<a href='index.php?action=index&module=DynamicLayout&from_action=ListView&from_module=" . $_REQUEST['module'] . "'>" . SugarThemeRegistry::current()->getImage("EditLayout", "border='0' align='bottom'", null, null, '.gif', $mod_strings['LBL_EDIT_LAYOUT']) . "</a>");
}
$where = '';
$limit = '0';
$orderBy = 'date_entered';
 /**
  * @access public
  * @param User         $user    required
  * @param Localization $locale
  * @param string       $charset
  * @return array MailConfigurations
  * @throws MailerException
  */
 public static function listMailConfigurations(User $user, Localization $locale = null, $charset = null)
 {
     global $app_strings;
     $outboundEmailConfigurations = array();
     $ret = $user->getUsersNameAndEmail();
     $systemDefaultOutbound = null;
     if (empty($ret['email'])) {
         $systemReturn = $user->getSystemDefaultNameAndEmail();
         $ret['email'] = $systemReturn['email'];
         $ret['name'] = $systemReturn['name'];
         $system_replyToAddress = $ret['email'];
     } else {
         $system_replyToAddress = '';
     }
     $system_replyToName = $ret['name'];
     $replyTo = $user->emailAddress->getReplyToAddress($user, true);
     if (!empty($replyTo)) {
         $system_replyToAddress = $replyTo;
     }
     /* Retrieve any Inbound User Mail Accounts and the Outbound Mail Accounts Associated with them */
     $inboundEmail = new InboundEmail();
     $ieAccounts = $inboundEmail->retrieveAllByGroupIdWithGroupAccounts($user->id);
     $ie_ids = array_keys($ieAccounts);
     foreach ($ieAccounts as $inbox_id => $ie) {
         $name = $ie->get_stored_options('from_name');
         $addr = $ie->get_stored_options('from_addr');
         $storedOptions = unserialize(base64_decode($ie->stored_options));
         $isAllowedGroup = $ie->get_stored_options('allow_outbound_group_usage', false);
         if (!$ie->is_personal && !$isAllowedGroup) {
             continue;
         }
         $outbound_config_id = empty($storedOptions["outbound_email"]) ? null : $storedOptions["outbound_email"];
         $oe = null;
         if (!empty($outbound_config_id)) {
             $oe = static::loadOutboundEmail();
             $oe->retrieve($outbound_config_id);
         } else {
             if (empty($systemDefaultOutbound)) {
                 $systemDefaultOutbound = self::getSystemMailConfiguration($user, $locale, $charset);
             }
             $outbound_config_id = $systemDefaultOutbound->getConfigId();
             $oe = static::loadOutboundEmail();
             $oe->retrieve($outbound_config_id);
         }
         if ($name != null && $addr != null && !empty($outbound_config_id) && !empty($oe) && $outbound_config_id == $oe->id) {
             // turn the OutboundEmail object into a useable set of mail configurations
             $configurations = array();
             $configurations["config_id"] = $outbound_config_id;
             $configurations["config_type"] = "user";
             $configurations["inbox_id"] = $inbox_id;
             $configurations["from_email"] = $addr;
             $configurations["from_name"] = $name;
             if ($isAllowedGroup) {
                 $configurations["display_name"] = "{$name} ({$addr}) - [" . $app_strings['LBL_GROUP_EMAIL_ACCOUNT_CONFIGURATION'] . "]";
             } else {
                 $configurations["display_name"] = "{$name} ({$addr}) - [" . $app_strings['LBL_USER_OUTBOUND_EMAIL_ACCOUNT_CONFIGURATION'] . "]";
             }
             $configurations["personal"] = (bool) $ie->is_personal;
             $configurations["replyto_email"] = !empty($storedOptions["reply_to_addr"]) ? $storedOptions["reply_to_addr"] : $addr;
             $configurations["replyto_name"] = !empty($storedOptions["reply_to_name"]) ? $storedOptions["reply_to_name"] : $name;
             $outboundEmailConfiguration = self::buildOutboundEmailConfiguration($user, $configurations, $oe, $locale, $charset);
             $outboundEmailConfigurations[] = $outboundEmailConfiguration;
         }
     }
     $systemUser = BeanFactory::getBean("Users");
     $systemUser->getSystemUser();
     $oe = static::loadOutboundEmail();
     $systemMailerConfiguration = $oe->getSystemMailerSettings();
     if ($oe->isAllowUserAccessToSystemDefaultOutbound()) {
         $system = $systemMailerConfiguration;
         $personal = false;
     } else {
         $system = $oe->getUsersMailerForSystemOverride($user->id);
         $personal = true;
         if (empty($system)) {
             // Create a User System-Override Configuration
             if ($user->id == $systemUser->id) {
                 $oe = $oe->createUserSystemOverrideAccount($user->id, $systemMailerConfiguration->mail_smtpuser, $systemMailerConfiguration->mail_smtppass);
             } else {
                 $oe = $oe->createUserSystemOverrideAccount($user->id);
             }
             $system = $oe->getUsersMailerForSystemOverride($user->id);
         }
     }
     if (empty($system->id)) {
         throw new MailerException("No Valid Mail Configurations Found", MailerException::InvalidConfiguration);
     }
     // turn the OutboundEmail object into a useable set of mail configurations
     $oe = static::loadOutboundEmail();
     $oe->retrieve($system->id);
     $configurations = array();
     $configurations["config_id"] = $system->id;
     $configurations["config_type"] = "system";
     $configurations["inbox_id"] = null;
     $configurations["from_email"] = $ret["email"];
     $configurations["from_name"] = $ret["name"];
     $configurations["display_name"] = "{$ret['name']} ({$ret['email']}) - [" . ($personal ? $app_strings['LBL_USER_DEFAULT_OUTBOUND_EMAIL_CONFIGURATION'] : $app_strings['LBL_SYSTEM_DEFAULT_OUTBOUND_EMAIL_CONFIGURATION']) . "]";
     $configurations["personal"] = $personal;
     $configurations["replyto_email"] = $system_replyToAddress;
     $configurations["replyto_name"] = $system_replyToName;
     $configurations["inbound_ids"] = $ie_ids;
     $outboundEmailConfiguration = self::buildOutboundEmailConfiguration($user, $configurations, $oe, $locale, $charset);
     $outboundEmailConfigurations[] = $outboundEmailConfiguration;
     return $outboundEmailConfigurations;
 }
Exemplo n.º 15
0
					<input name="close" type="button" title="' . $mod_strings['LBL_CLOSE_POPUP'] . '"  value="    ' . $mod_strings['LBL_CLOSE_POPUP'] . '    " onClick="window.close()">
					</form>
				</td>
			</tr>';
}
echo '	</table>';
sleep(1);
ob_flush();
flush();
ob_end_flush();
ob_start();
ob_flush();
flush();
ob_end_flush();
ob_start();
$ie = new InboundEmail();
$ie->email_user = $_REQUEST['email_user'];
$ie->server_url = $_REQUEST['server_url'];
$ie->port = $_REQUEST['port'];
$ie->protocol = $_REQUEST['protocol'];
$ie->email_password = str_rot13($_REQUEST['email_password']);
$ie->mailbox = $_REQUEST['mailbox'];
if ($_REQUEST['target'] == 'Popup') {
    $msg = $ie->connectMailserver(true);
}
////	END COMMON CODE
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
////	COMPLETE RENDERING OF THE POPUP
echo '
<script type="text/javascript">
Exemplo n.º 16
0
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 *
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
 ********************************************************************************/
require_once 'include/SugarFolders/SugarFolders.php';
global $current_user;
$focus = new InboundEmail();
if (!empty($_REQUEST['record'])) {
    $focus->retrieve($_REQUEST['record']);
} elseif (!empty($_REQUEST['origin_id'])) {
    $focus->retrieve($_REQUEST['origin_id']);
    unset($focus->id);
    unset($focus->groupfolder_id);
}
foreach ($focus->column_fields as $field) {
    if ($field == 'email_password' && empty($_REQUEST['email_password']) && !empty($_REQUEST['email_user'])) {
        continue;
    }
    if (isset($_REQUEST[$field])) {
        if ($field != "group_id") {
            $focus->{$field} = trim($_REQUEST[$field]);
        }
Exemplo n.º 17
0
    $useSsl = true;
}
$searchField = !empty($_REQUEST['searchField']) ? $_REQUEST['searchField'] : "";
$multipleString = "multiple=\"true\"";
if (!empty($searchField)) {
    $subdcriptionFolderHelp = "";
    $multipleString = "";
    if ($searchField == 'trash') {
        $title = $mod_strings['LBL_SELECT_TRASH_FOLDERS'];
    } else {
        $title = $mod_strings['LBL_SELECT_SENT_FOLDERS'];
    }
    // else
}
// else
$ie = new InboundEmail();
if (!empty($_REQUEST['ie_id'])) {
    $ie->retrieve($_REQUEST['ie_id']);
}
$ie->email_user = $_REQUEST['email_user'];
$ie->server_url = $_REQUEST['server_url'];
$ie->port = $_REQUEST['port'];
$ie->protocol = $_REQUEST['protocol'];
//Bug 23083.Special characters in email password results in IMAP authentication failure
if (!empty($_REQUEST['email_password'])) {
    $ie->email_password = html_entity_decode($_REQUEST['email_password'], ENT_QUOTES);
    $ie->email_password = str_rot13($ie->email_password);
}
//$ie->mailbox      = $_REQUEST['mailbox'];
$ie->mailbox = 'INBOX';
if ($popupBoolean) {
Exemplo n.º 18
0
 * for the specific language governing rights and limitations under the
 * License.
 *
 * All copies of the Covered Code must include on each user interface screen:
 *    (i) the "Powered by SugarCRM" logo and
 *    (ii) the SugarCRM copyright notice
 * in the same form as they appear in the distribution.  See full license for
 * requirements.
 *
 * The Original Code is: SugarCRM Open Source
 * The Initial Developer of the Original Code is SugarCRM, Inc.
 * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.;
 * All Rights Reserved.
 * Contributor(s): ______________________________________.
 ********************************************************************************/
/*********************************************************************************
 * Description:
 * Created On: Sep 28, 2005
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
 * All Rights Reserved.
 * Contributor(s): Chris Nojima
 ********************************************************************************/
global $mod_strings;
if (empty($_REQUEST['record'])) {
    sugar_die($mod_strings['LBL_DELETE_ERROR']);
} else {
    require_once 'modules/InboundEmail/InboundEmail.php';
    $focus = new InboundEmail();
    $focus->mark_deleted($_REQUEST['record']);
    header("Location: index.php?module=" . $_REQUEST['return_module'] . "&action=" . $_REQUEST['return_action'] . "&record=" . $_REQUEST['return_id']);
}
Exemplo n.º 19
0
 /**
  * Returns the HTML for a list of emails in a given folder
  * @param GUID $ieId GUID to InboundEmail instance
  * @param string $mbox Mailbox path name in dot notation
  * @param int $folderListCacheOffset Seconds for valid cache file
  * @return string HTML render of list.
  */
 function getListEmails($ieId, $mbox, $folderListCacheOffset, $forceRefresh = 'false')
 {
     global $sugar_config;
     $ie = new InboundEmail();
     $ie->retrieve($ieId);
     $list = $ie->displayFolderContents($mbox, $forceRefresh);
     return $list;
 }
Exemplo n.º 20
0
 /**
  * Delete this inbound account.
  *
  */
 function _tearDownInboundAccount($inbound_account_id)
 {
     $focus = new InboundEmail();
     $focus->retrieve($inbound_account_id);
     $focus->mark_deleted($inbound_account_id);
     $focus->db->query("delete from inbound_email WHERE id = '{$inbound_account_id}'");
 }
Exemplo n.º 21
0
function pollMonitoredInboxesForBouncedCampaignEmails()
{
    Log::info('----->Scheduler job of type pollMonitoredInboxesForBouncedCampaignEmails()');
    global $dictionary;
    $ie = new InboundEmail();
    $r = $ie->db->query('SELECT id FROM inbound_email WHERE deleted=0 AND status=\'Active\' AND mailbox_type=\'bounce\'');
    while ($a = $ie->db->fetchByAssoc($r)) {
        $ieX = new InboundEmail();
        $ieX->retrieve($a['id']);
        $ieX->connectMailserver();
        $ieX->importMessages();
    }
    return true;
}
Exemplo n.º 22
0
     $oe->mail_smtpserver = $_REQUEST['mail_smtpserver'];
     $oe->mail_smtpport = $_REQUEST['mail_smtpport'];
     $oe->mail_smtpssl = $_REQUEST['mail_smtpssl'];
     $oe->mail_smtpauth_req = isset($_REQUEST['mail_smtpauth_req']) ? 1 : 0;
     $oe->mail_smtpuser = $_REQUEST['mail_smtpuser'];
     if (!empty($_REQUEST['mail_smtppass'])) {
         $oe->mail_smtppass = $_REQUEST['mail_smtppass'];
     }
     $oe = $oe->save();
     echo $oe->id;
     break;
 case "saveDefaultOutbound":
     global $current_user;
     $GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: saveDefaultOutbound");
     $outbound_id = empty($_REQUEST['id']) ? "" : $_REQUEST['id'];
     $ie = new InboundEmail();
     $ie->setUsersDefaultOutboundServerId($current_user, $outbound_id);
     break;
 case "testOutbound":
     $GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: testOutbound");
     $pass = '';
     if (!empty($_REQUEST['mail_smtppass'])) {
         $pass = $_REQUEST['mail_smtppass'];
     } elseif (isset($_REQUEST['mail_name'])) {
         $oe = new OutboundEmail();
         $oe = $oe->getMailerByName($current_user, $_REQUEST['mail_name']);
         if (!empty($oe)) {
             $pass = $oe->mail_smtppass;
         }
     }
     $out = $email->sendEmailTest($_REQUEST['mail_smtpserver'], $_REQUEST['mail_smtpport'], $_REQUEST['mail_smtpssl'], isset($_REQUEST['mail_smtpauth_req']) ? 1 : 0, $_REQUEST['mail_smtpuser'], $pass, $_REQUEST['outboundtest_from_address'], $_REQUEST['outboundtest_from_address']);
Exemplo n.º 23
0
                $sysOutboundAccunt->createUserSystemOverrideAccount($focus->id, $_REQUEST['mail_smtpuser'], $_REQUEST['mail_smtppass']);
            }
        }
    }
    ///////////////////////////////////////////////////////////////////////////
    ////	INBOUND EMAIL SAVES
    if (isset($_REQUEST['server_url']) && !empty($_REQUEST['server_url'])) {
        $ie = new InboundEmail();
        if (false === $ie->savePersonalEmailAccount($return_id, $focus->user_name)) {
            header("Location: index.php?action=Error&module=Users&error_string=&ie_error=true&id=" . $return_id);
            die;
            // die here, else the header redirect below takes over.
        }
    } elseif (isset($_REQUEST['ie_id']) && !empty($_REQUEST['ie_id']) && empty($_REQUEST['server_url'])) {
        // user is deleting their I-E
        $ie = new InboundEmail();
        $ie->deletePersonalEmailAccount($_REQUEST['ie_id'], $focus->user_name);
    }
    ////	END INBOUND EMAIL SAVES
    ///////////////////////////////////////////////////////////////////////////
    if ($newUser && !$focus->is_group && !$focus->portal_only && isset($sugar_config['passwordsetting']['SystemGeneratedPasswordON']) && $sugar_config['passwordsetting']['SystemGeneratedPasswordON']) {
        $new_pwd = '2';
        require_once 'modules/Users/GeneratePassword.php';
    }
}
//handle navigation from user wizard
if (isset($_REQUEST['whatnext'])) {
    if ($_REQUEST['whatnext'] == 'import') {
        header("Location:index.php?module=Import&action=step1&import_module=Administration");
        return;
    } elseif ($_REQUEST['whatnext'] == 'users') {
Exemplo n.º 24
0
}
$sugar_smarty->assign("settings", $focus->settings);
if ($valid_public_key) {
    if (!empty($focus->settings['captcha_on'])) {
        $sugar_smarty->assign("CAPTCHA_CONFIG_DISPLAY", 'inline');
    } else {
        $sugar_smarty->assign("CAPTCHA_CONFIG_DISPLAY", 'none');
    }
} else {
    $sugar_smarty->assign("CAPTCHA_CONFIG_DISPLAY", 'inline');
}
$sugar_smarty->assign("VALID_PUBLIC_KEY", $valid_public_key);
$res = $GLOBALS['sugar_config']['passwordsetting'];
require_once 'include/SugarPHPMailer.php';
$mail = new SugarPHPMailer();
$mail->setMailerForSystem();
if ($mail->Mailer == 'smtp' && $mail->Host == '') {
    $sugar_smarty->assign("SMTP_SERVER_NOT_SET", '1');
} else {
    $sugar_smarty->assign("SMTP_SERVER_NOT_SET", '0');
}
$focus = new InboundEmail();
$focus->checkImap();
$storedOptions = unserialize(base64_decode($focus->stored_options));
$email_templates_arr = get_bean_select_array(true, 'EmailTemplate', 'name', '', 'name', true);
$create_case_email_template = isset($storedOptions['create_case_email_template']) ? $storedOptions['create_case_email_template'] : "";
$TMPL_DRPDWN_LOST = get_select_options_with_id($email_templates_arr, $res['lostpasswordtmpl']);
$TMPL_DRPDWN_GENERATE = get_select_options_with_id($email_templates_arr, $res['generatepasswordtmpl']);
$sugar_smarty->assign("TMPL_DRPDWN_LOST", $TMPL_DRPDWN_LOST);
$sugar_smarty->assign("TMPL_DRPDWN_GENERATE", $TMPL_DRPDWN_GENERATE);
$sugar_smarty->display('modules/Administration/PasswordManager.tpl');
Exemplo n.º 25
0
                        // else
                        $bean->importOneEmail($msgNo, $uid);
                    }
                }
                imap_expunge($bean->conn);
                imap_close($bean->conn);
            }
        }
    }
    header('Location: index.php?module=Emails&action=ListView&type=inbound&assigned_user_id=' . $current_user->id);
} elseif (isset($_REQUEST['type']) && $_REQUEST['type'] == 'group') {
    $ie = new InboundEmail();
    // this query only polls Group Inboxes
    $r = $ie->db->query('SELECT inbound_email.id FROM inbound_email JOIN users ON inbound_email.group_id = users.id WHERE inbound_email.deleted=0 AND inbound_email.status = \'Active\' AND mailbox_type != \'bounce\' AND users.deleted = 0 AND users.is_group = 1');
    while ($a = $ie->db->fetchByAssoc($r)) {
        $ieX = new InboundEmail();
        $ieX->retrieve($a['id']);
        $ieX->connectMailserver();
        //$newMsgs = $ieX->getNewMessageIds();
        $newMsgs = array();
        if ($ieX->isPop3Protocol()) {
            $newMsgs = $ieX->getPop3NewMessagesToDownload();
        } else {
            $newMsgs = $ieX->getNewMessageIds();
        }
        if (is_array($newMsgs)) {
            foreach ($newMsgs as $k => $msgNo) {
                $uid = $msgNo;
                if ($ieX->isPop3Protocol()) {
                    $uid = $ieX->getUIDLForMessage($msgNo);
                } else {
function pollMonitoredInboxesForBouncedCampaignEmails()
{
    $GLOBALS['log']->info('----->Scheduler job of type pollMonitoredInboxesForBouncedCampaignEmails()');
    global $dictionary;
    require_once 'modules/InboundEmail/InboundEmail.php';
    $ie = new InboundEmail();
    $r = $ie->db->query('SELECT id FROM inbound_email WHERE deleted=0 AND status=\'Active\' AND mailbox_type=\'bounce\'');
    while ($a = $ie->db->fetchByAssoc($r)) {
        $ieX = new InboundEmail();
        $ieX->retrieve($a['id']);
        $ieX->connectMailserver();
        $newMsgs = $ieX->getNewMessageIds();
        if (is_array($newMsgs)) {
            foreach ($newMsgs as $k => $msgNo) {
                $ieX->importOneEmail($msgNo);
            }
        }
        imap_expunge($ieX->conn);
        imap_close($ieX->conn);
    }
    return true;
}
Exemplo n.º 27
0
 /**
  * Sends Email for Email 2.0
  */
 function email2Send($request)
 {
     global $mod_strings;
     global $app_strings;
     global $current_user;
     global $sugar_config;
     global $locale;
     global $timedate;
     global $beanList;
     global $beanFiles;
     $OBCharset = $locale->getPrecedentPreference('default_email_charset');
     /**********************************************************************
      * Sugar Email PREP
      */
     /* preset GUID */
     $orignialId = "";
     if (!empty($this->id)) {
         $orignialId = $this->id;
     }
     // if
     if (empty($this->id)) {
         $this->id = create_guid();
         $this->new_with_id = true;
     }
     /* satisfy basic HTML email requirements */
     $this->name = $request['sendSubject'];
     $this->description_html = '&lt;html&gt;&lt;body&gt;' . $request['sendDescription'] . '&lt;/body&gt;&lt;/html&gt;';
     /**********************************************************************
      * PHPMAILER PREP
      */
     $mail = new SugarPHPMailer();
     $mail = $this->setMailer($mail, '', $_REQUEST['fromAccount']);
     if (empty($mail->Host) && !$this->isDraftEmail($request)) {
         $this->status = 'send_error';
         if ($mail->oe->type == 'system') {
             echo $app_strings['LBL_EMAIL_ERROR_PREPEND'] . $app_strings['LBL_EMAIL_INVALID_SYSTEM_OUTBOUND'];
         } else {
             echo $app_strings['LBL_EMAIL_ERROR_PREPEND'] . $app_strings['LBL_EMAIL_INVALID_PERSONAL_OUTBOUND'];
         }
         return false;
     }
     $subject = $this->name;
     $mail->Subject = from_html($this->name);
     // work-around legacy code in SugarPHPMailer
     if ($_REQUEST['setEditor'] == 1) {
         $_REQUEST['description_html'] = $_REQUEST['sendDescription'];
         $this->description_html = $_REQUEST['description_html'];
     } else {
         $this->description_html = '';
         $this->description = $_REQUEST['sendDescription'];
     }
     // end work-around
     if ($this->isDraftEmail($request)) {
         if ($this->type != 'draft' && $this->status != 'draft') {
             $this->id = create_guid();
             $this->new_with_id = true;
             $this->date_entered = "";
         }
         // if
         $q1 = "update emails_email_addr_rel set deleted = 1 WHERE email_id = '{$this->id}'";
         $r1 = $this->db->query($q1);
     }
     // if
     if (isset($request['saveDraft'])) {
         $this->type = 'draft';
         $this->status = 'draft';
         $forceSave = true;
     } else {
         /* Apply Email Templates */
         // do not parse email templates if the email is being saved as draft....
         $toAddresses = $this->email2ParseAddresses($_REQUEST['sendTo']);
         $sea = new SugarEmailAddress();
         $object_arr = array();
         if (isset($_REQUEST['parent_type']) && !empty($_REQUEST['parent_type']) && isset($_REQUEST['parent_id']) && !empty($_REQUEST['parent_id']) && ($_REQUEST['parent_type'] == 'Accounts' || $_REQUEST['parent_type'] == 'Contacts' || $_REQUEST['parent_type'] == 'Leads' || $_REQUEST['parent_type'] == 'Users' || $_REQUEST['parent_type'] == 'Prospects')) {
             if (isset($beanList[$_REQUEST['parent_type']]) && !empty($beanList[$_REQUEST['parent_type']])) {
                 $className = $beanList[$_REQUEST['parent_type']];
                 if (isset($beanFiles[$className]) && !empty($beanFiles[$className])) {
                     if (!class_exists($className)) {
                         require_once $beanFiles[$className];
                     }
                     $bean = new $className();
                     $bean->retrieve($_REQUEST['parent_id']);
                     $object_arr[$bean->module_dir] = $bean->id;
                 }
                 // if
             }
             // if
         }
         foreach ($toAddresses as $addrMeta) {
             $addr = $addrMeta['email'];
             $beans = $sea->getBeansByEmailAddress($addr);
             foreach ($beans as $bean) {
                 if (!isset($object_arr[$bean->module_dir])) {
                     $object_arr[$bean->module_dir] = $bean->id;
                 }
             }
         }
         /* template parsing */
         if (empty($object_arr)) {
             $object_arr = array('Contacts' => '123');
         }
         $object_arr['Users'] = $current_user->id;
         $this->description_html = EmailTemplate::parse_template($this->description_html, $object_arr);
         $this->name = EmailTemplate::parse_template($this->name, $object_arr);
         $this->description = EmailTemplate::parse_template($this->description, $object_arr);
         $this->description = html_entity_decode($this->description, ENT_COMPAT, 'UTF-8');
         if ($this->type != 'draft' && $this->status != 'draft') {
             $this->id = create_guid();
             $this->date_entered = "";
             $this->new_with_id = true;
             $this->type = 'out';
             $this->status = 'sent';
         }
     }
     if (isset($_REQUEST['parent_type']) && empty($_REQUEST['parent_type']) && isset($_REQUEST['parent_id']) && empty($_REQUEST['parent_id'])) {
         $this->parent_id = "";
         $this->parent_type = "";
     }
     // if
     $mail->Subject = $this->name;
     $mail = $this->handleBody($mail);
     $mail->Subject = $this->name;
     $this->description_html = from_html($this->description_html);
     $this->description_html = $this->decodeDuringSend($this->description_html);
     $this->description = $this->decodeDuringSend($this->description);
     /* from account */
     $replyToAddress = $current_user->emailAddress->getReplyToAddress($current_user);
     $replyToName = "";
     if (empty($request['fromAccount'])) {
         $defaults = $current_user->getPreferredEmail();
         $mail->From = $defaults['email'];
         $mail->FromName = $defaults['name'];
         $replyToName = $mail->FromName;
         //$replyToAddress = $current_user->emailAddress->getReplyToAddress($current_user);
     } else {
         // passed -> user -> system default
         $ie = new InboundEmail();
         $ie->retrieve($request['fromAccount']);
         $storedOptions = unserialize(base64_decode($ie->stored_options));
         $fromName = "";
         $fromAddress = "";
         $replyToName = "";
         //$replyToAddress = "";
         if (!empty($storedOptions)) {
             $fromAddress = $storedOptions['from_addr'];
             $fromName = from_html($storedOptions['from_name']);
             $replyToAddress = isset($storedOptions['reply_to_addr']) ? $storedOptions['reply_to_addr'] : "";
             $replyToName = isset($storedOptions['reply_to_name']) ? from_html($storedOptions['reply_to_name']) : "";
         }
         // if
         $defaults = $current_user->getPreferredEmail();
         // Personal Account doesn't have reply To Name and Reply To Address. So add those columns on UI
         // After adding remove below code
         // code to remove
         if ($ie->is_personal) {
             if (empty($replyToAddress)) {
                 $replyToAddress = $current_user->emailAddress->getReplyToAddress($current_user);
             }
             // if
             if (empty($replyToName)) {
                 $replyToName = $defaults['name'];
             }
             // if
             //Personal accounts can have a reply_address, which should
             //overwrite the users set default.
             if (!empty($storedOptions['reply_to_addr'])) {
                 $replyToAddress = $storedOptions['reply_to_addr'];
             }
         }
         // end of code to remove
         $mail->From = !empty($fromAddress) ? $fromAddress : $defaults['email'];
         $mail->FromName = !empty($fromName) ? $fromName : $defaults['name'];
         $replyToName = !empty($replyToName) ? $replyToName : $mail->FromName;
     }
     $mail->Sender = $mail->From;
     /* set Return-Path field in header to reduce spam score in emails sent via Sugar's Email module */
     if (!empty($replyToAddress)) {
         $mail->AddReplyTo($replyToAddress, $locale->translateCharsetMIME(trim($replyToName), 'UTF-8', $OBCharset));
     } else {
         $mail->AddReplyTo($mail->From, $locale->translateCharsetMIME(trim($mail->FromName), 'UTF-8', $OBCharset));
     }
     // else
     $emailAddressCollection = array();
     // used in linking to beans below
     // handle to/cc/bcc
     foreach ($this->email2ParseAddresses($request['sendTo']) as $addr_arr) {
         if (empty($addr_arr['email'])) {
             continue;
         }
         if (empty($addr_arr['display'])) {
             $mail->AddAddress($addr_arr['email'], "");
         } else {
             $mail->AddAddress($addr_arr['email'], $locale->translateCharsetMIME(trim($addr_arr['display']), 'UTF-8', $OBCharset));
         }
         $emailAddressCollection[] = $addr_arr['email'];
     }
     foreach ($this->email2ParseAddresses($request['sendCc']) as $addr_arr) {
         if (empty($addr_arr['email'])) {
             continue;
         }
         if (empty($addr_arr['display'])) {
             $mail->AddCC($addr_arr['email'], "");
         } else {
             $mail->AddCC($addr_arr['email'], $locale->translateCharsetMIME(trim($addr_arr['display']), 'UTF-8', $OBCharset));
         }
         $emailAddressCollection[] = $addr_arr['email'];
     }
     foreach ($this->email2ParseAddresses($request['sendBcc']) as $addr_arr) {
         if (empty($addr_arr['email'])) {
             continue;
         }
         if (empty($addr_arr['display'])) {
             $mail->AddBCC($addr_arr['email'], "");
         } else {
             $mail->AddBCC($addr_arr['email'], $locale->translateCharsetMIME(trim($addr_arr['display']), 'UTF-8', $OBCharset));
         }
         $emailAddressCollection[] = $addr_arr['email'];
     }
     /* parse remove attachments array */
     $removeAttachments = array();
     if (!empty($request['templateAttachmentsRemove'])) {
         $exRemove = explode("::", $request['templateAttachmentsRemove']);
         foreach ($exRemove as $file) {
             $removeAttachments = substr($file, 0, 36);
         }
     }
     /* handle attachments */
     if (!empty($request['attachments'])) {
         $exAttachments = explode("::", $request['attachments']);
         foreach ($exAttachments as $file) {
             $file = trim(from_html($file));
             $file = str_replace("\\", "", $file);
             if (!empty($file)) {
                 //$fileLocation = $this->et->userCacheDir."/{$file}";
                 $fileGUID = substr($file, 0, 36);
                 $fileLocation = $this->et->userCacheDir . "/{$fileGUID}";
                 $filename = substr($file, 36, strlen($file));
                 // strip GUID	for PHPMailer class to name outbound file
                 $mail->AddAttachment($fileLocation, $filename, 'base64', $this->email2GetMime($fileLocation));
                 //$mail->AddAttachment($fileLocation, $filename, 'base64');
                 // only save attachments if we're archiving or drafting
                 if ($this->type == 'draft' && !empty($this->id) || isset($request['saveToSugar']) && $request['saveToSugar'] == 1) {
                     $note = new Note();
                     $note->id = create_guid();
                     $note->new_with_id = true;
                     // duplicating the note with files
                     $note->parent_id = $this->id;
                     $note->parent_type = $this->module_dir;
                     $note->name = $filename;
                     $note->filename = $filename;
                     $noteFile = "{$sugar_config['upload_dir']}{$note->id}";
                     $note->file_mime_type = $this->email2GetMime($fileLocation);
                     if (!copy($fileLocation, $noteFile)) {
                         $GLOBALS['log']->debug("EMAIL 2.0: could not copy attachment file to cache/upload [ {$fileLocation} ]");
                     }
                     $note->save();
                 }
             }
         }
     }
     /* handle sugar documents */
     if (!empty($request['documents'])) {
         $exDocs = explode("::", $request['documents']);
         foreach ($exDocs as $docId) {
             $docId = trim($docId);
             if (!empty($docId)) {
                 $doc = new Document();
                 $docRev = new DocumentRevision();
                 $doc->retrieve($docId);
                 $docRev->retrieve($doc->document_revision_id);
                 $filename = $docRev->filename;
                 $fileLocation = "{$sugar_config['upload_dir']}{$docRev->id}";
                 $mime_type = $docRev->file_mime_type;
                 $mail->AddAttachment($fileLocation, $locale->translateCharsetMIME(trim($filename), 'UTF-8', $OBCharset), 'base64', $mime_type);
                 // only save attachments if we're archiving or drafting
                 if ($this->type == 'draft' && !empty($this->id) || isset($request['saveToSugar']) && $request['saveToSugar'] == 1) {
                     $note = new Note();
                     $note->id = create_guid();
                     $note->new_with_id = true;
                     // duplicating the note with files
                     $note->parent_id = $this->id;
                     $note->parent_type = $this->module_dir;
                     $note->name = $filename;
                     $note->filename = $filename;
                     $note->file_mime_type = $mime_type;
                     $noteFile = "{$sugar_config['upload_dir']}{$note->id}";
                     if (!copy($fileLocation, $noteFile)) {
                         $GLOBALS['log']->debug("EMAIL 2.0: could not copy SugarDocument revision file to {$sugar_config['upload_dir']} [ {$fileLocation} ]");
                     }
                     $note->save();
                 }
             }
         }
     }
     /* handle template attachments */
     if (!empty($request['templateAttachments'])) {
         $exNotes = explode("::", $request['templateAttachments']);
         foreach ($exNotes as $noteId) {
             $noteId = trim($noteId);
             if (!empty($noteId)) {
                 $note = new Note();
                 $note->retrieve($noteId);
                 if (!empty($note->id)) {
                     $filename = $note->filename;
                     $fileLocation = "{$sugar_config['upload_dir']}{$note->id}";
                     $mime_type = $note->file_mime_type;
                     if (!$note->embed_flag) {
                         $mail->AddAttachment($fileLocation, $filename, 'base64', $mime_type);
                         // only save attachments if we're archiving or drafting
                         if ($this->type == 'draft' && !empty($this->id) || isset($request['saveToSugar']) && $request['saveToSugar'] == 1) {
                             if ($note->parent_id != $this->id) {
                                 $this->saveTempNoteAttachments($filename, $fileLocation, $mime_type);
                             }
                         }
                         // if
                     }
                     // if
                 } else {
                     //$fileLocation = $this->et->userCacheDir."/{$file}";
                     $fileGUID = substr($noteId, 0, 36);
                     $fileLocation = $this->et->userCacheDir . "/{$fileGUID}";
                     //$fileLocation = $this->et->userCacheDir."/{$noteId}";
                     $filename = substr($noteId, 36, strlen($noteId));
                     // strip GUID	for PHPMailer class to name outbound file
                     $mail->AddAttachment($fileLocation, $locale->translateCharsetMIME(trim($filename), 'UTF-8', $OBCharset), 'base64', $this->email2GetMime($fileLocation));
                     //If we are saving an email we were going to forward we need to save the attachments as well.
                     if ($this->type == 'draft' && !empty($this->id) || isset($request['saveToSugar']) && $request['saveToSugar'] == 1) {
                         $mimeType = $this->email2GetMime($fileLocation);
                         $this->saveTempNoteAttachments($filename, $fileLocation, $mimeType);
                     }
                     // if
                 }
             }
         }
     }
     /**********************************************************************
      * Final Touches
      */
     /* save email to sugar? */
     $forceSave = false;
     if ($this->type == 'draft' && !isset($request['saveDraft'])) {
         // sending a draft email
         $this->type = 'out';
         $this->status = 'sent';
         $forceSave = true;
     } elseif (isset($request['saveDraft'])) {
         $this->type = 'draft';
         $this->status = 'draft';
         $forceSave = true;
     }
     /**********************************************************************
      * SEND EMAIL (finally!)
      */
     $mailSent = false;
     if ($this->type != 'draft') {
         $mail->prepForOutbound();
         $mail->Body = $this->decodeDuringSend($mail->Body);
         $mail->AltBody = $this->decodeDuringSend($mail->AltBody);
         if (!$mail->Send()) {
             $this->status = 'send_error';
             ob_clean();
             echo $app_strings['LBL_EMAIL_ERROR_PREPEND'] . $mail->ErrorInfo;
             return false;
         }
     }
     if (!(empty($orignialId) || isset($request['saveDraft']) || $this->type == 'draft' && $this->status == 'draft') && ($_REQUEST['composeType'] == 'reply' || $_REQUEST['composeType'] == 'replyAll' || $_REQUEST['composeType'] == 'replyCase') && $orignialId != $this->id) {
         $originalEmail = new Email();
         $originalEmail->retrieve($orignialId);
         $originalEmail->reply_to_status = 1;
         $originalEmail->save();
         $this->reply_to_status = 0;
     }
     // if
     if ($_REQUEST['composeType'] == 'reply' || $_REQUEST['composeType'] == 'replyCase') {
         if (isset($_REQUEST['ieId']) && isset($_REQUEST['mbox'])) {
             $emailFromIe = new InboundEmail();
             $emailFromIe->retrieve($_REQUEST['ieId']);
             $emailFromIe->mailbox = $_REQUEST['mbox'];
             if (isset($emailFromIe->id) && $emailFromIe->is_personal) {
                 if ($emailFromIe->isPop3Protocol()) {
                     $emailFromIe->mark_answered($this->uid, 'pop3');
                 } elseif ($emailFromIe->connectMailserver() == 'true') {
                     $emailFromIe->markEmails($this->uid, 'answered');
                     $emailFromIe->mark_answered($this->uid);
                 }
             }
         }
     }
     if ($forceSave || $this->type == 'draft' || isset($request['saveToSugar']) && $request['saveToSugar'] == 1) {
         // saving a draft OR saving a sent email
         $decodedFromName = mb_decode_mimeheader($mail->FromName);
         $this->from_addr = "{$decodedFromName} <{$mail->From}>";
         $this->from_addr_name = $this->from_addr;
         $this->to_addrs = $_REQUEST['sendTo'];
         $this->to_addrs_names = $_REQUEST['sendTo'];
         $this->cc_addrs = $_REQUEST['sendCc'];
         $this->cc_addrs_names = $_REQUEST['sendCc'];
         $this->bcc_addrs = $_REQUEST['sendBcc'];
         $this->bcc_addrs_names = $_REQUEST['sendBcc'];
         $this->assigned_user_id = $current_user->id;
         $this->date_sent = $timedate->now();
         ///////////////////////////////////////////////////////////////////
         ////	LINK EMAIL TO SUGARBEANS BASED ON EMAIL ADDY
         if (isset($_REQUEST['parent_type']) && !empty($_REQUEST['parent_type']) && isset($_REQUEST['parent_id']) && !empty($_REQUEST['parent_id'])) {
             $this->parent_id = $_REQUEST['parent_id'];
             $this->parent_type = $_REQUEST['parent_type'];
             $q = "SELECT count(*) c FROM emails_beans WHERE  email_id = '{$this->id}' AND bean_id = '{$_REQUEST['parent_id']}' AND bean_module = '{$_REQUEST['parent_type']}'";
             $r = $this->db->query($q);
             $a = $this->db->fetchByAssoc($r);
             if ($a['c'] <= 0) {
                 if (isset($beanList[$_REQUEST['parent_type']]) && !empty($beanList[$_REQUEST['parent_type']])) {
                     $className = $beanList[$_REQUEST['parent_type']];
                     if (isset($beanFiles[$className]) && !empty($beanFiles[$className])) {
                         if (!class_exists($className)) {
                             require_once $beanFiles[$className];
                         }
                         $bean = new $className();
                         $bean->retrieve($_REQUEST['parent_id']);
                         if ($bean->load_relationship('emails')) {
                             $bean->emails->add($this->id);
                         }
                         // if
                     }
                     // if
                 }
                 // if
             }
             // if
         } else {
             if (!class_exists('aCase')) {
             } else {
                 $c = new aCase();
                 if ($caseId = InboundEmail::getCaseIdFromCaseNumber($mail->Subject, $c)) {
                     $c->retrieve($caseId);
                     $c->load_relationship('emails');
                     $c->emails->add($this->id);
                     $this->parent_type = "Cases";
                     $this->parent_id = $caseId;
                 }
                 // if
             }
         }
         // else
         ////	LINK EMAIL TO SUGARBEANS BASED ON EMAIL ADDY
         ///////////////////////////////////////////////////////////////////
         $this->save();
     }
     if (!empty($request['fromAccount'])) {
         if (isset($ie->id) && !$ie->isPop3Protocol()) {
             $sentFolder = $ie->get_stored_options("sentFolder");
             if (!empty($sentFolder)) {
                 $data = $mail->CreateHeader() . "\r\n" . $mail->CreateBody() . "\r\n";
                 $ie->mailbox = $sentFolder;
                 if ($ie->connectMailserver() == 'true') {
                     $connectString = $ie->getConnectString($ie->getServiceString(), $ie->mailbox);
                     $returnData = imap_append($ie->conn, $connectString, $data, "\\Seen");
                     if (!$returnData) {
                         $GLOBALS['log']->debug("could not copy email to {$ie->mailbox} for {$ie->name}");
                     }
                     // if
                 } else {
                     $GLOBALS['log']->debug("could not connect to mail serve for folder {$ie->mailbox} for {$ie->name}");
                 }
                 // else
             } else {
                 $GLOBALS['log']->debug("could not copy email to {$ie->mailbox} sent folder as its empty");
             }
             // else
         }
         // if
     }
     // if
     return true;
 }
Exemplo n.º 28
0
$popupBoolean = false;
if (isset($_REQUEST['target']) && $_REQUEST['target'] == 'Popup') {
    $popupBoolean = true;
}
if (isset($_REQUEST['target1']) && $_REQUEST['target1'] == 'Popup') {
    $popupBoolean = true;
}
if ($popupBoolean) {
    $title = '';
    $msg = $mod_strings['LBL_TEST_WAIT_MESSAGE'];
}
if (isset($_REQUEST['ssl']) && ($_REQUEST['ssl'] == "true" || $_REQUEST['ssl'] == 1)) {
    $msg .= $mod_strings['LBL_FIND_SSL_WARN'];
    $useSsl = true;
}
$ie = new InboundEmail();
if (!empty($_REQUEST['ie_id'])) {
    $ie->retrieve($_REQUEST['ie_id']);
}
$ie->email_user = $_REQUEST['email_user'];
$ie->server_url = $_REQUEST['server_url'];
$ie->port = $_REQUEST['port'];
$ie->protocol = $_REQUEST['protocol'];
//Bug 23083.Special characters in email password results in IMAP authentication failure
if (!empty($_REQUEST['email_password'])) {
    $ie->email_password = html_entity_decode($_REQUEST['email_password'], ENT_QUOTES);
    $ie->email_password = str_rot13($ie->email_password);
}
$ie->mailbox = 'INBOX';
if ($popupBoolean) {
    $msg = $ie->connectMailserver(true);
Exemplo n.º 29
0
 /**
  * performs a rudimentary check to verify if a given user has setup personal
  * InboundEmail
  *
  * @return bool
  */
 public function hasPersonalEmail()
 {
     $focus = new InboundEmail();
     $focus->retrieve_by_string_fields(array('group_id' => $this->id));
     return !empty($focus->id);
 }
Exemplo n.º 30
0
 * In accordance with Section 7(b) of the GNU General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/
/*********************************************************************************
 * Description:
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
 * Reserved. Contributor(s): ______________________________________..
 * *******************************************************************************/
$db = DBManagerFactory::getInstance();
$badAccts = array();
$q = "SELECT id, name, email_password FROM inbound_email WHERE deleted=0 AND status='Active'";
$r = $db->query($q);
while ($a = $db->fetchByAssoc($r)) {
    $ieX = new InboundEmail();
    $ieX->retrieve($a['id']);
    if (!$ieX->repairAccount()) {
        // none of the iterations worked.  flag for display
        $badAccts[$a['id']] = $a['name'];
    }
}
if (empty($badAccts)) {
    echo $mod_strings['LBL_REPAIR_IE_SUCCESS'];
} else {
    echo "<div class='error'>{$mod_strings['LBL_REPAIR_IE_FAILURE']}</div><br />";
    foreach ($badAccts as $id => $acctName) {
        echo "<a href='index.php?module=InboundEmail&action=EditView&record={$id}' target='_blank'>{$acctName}</a><br />";
    }
}