本文整理汇总了PHP中Email::email2init方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::email2init方法的具体用法?PHP Email::email2init怎么用?PHP Email::email2init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email::email2init方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testemail2ParseAddresses
public function testemail2ParseAddresses()
{
$email = new Email();
$email->email2init();
$addresses = 'abc<abc@xyz.com>,xyz<xyz@abc.com>';
$expected = array(array('email' => 'abc@xyz.com', 'display' => 'abc'), array('email' => 'xyz@abc.com', 'display' => 'xyz'));
$result = $email->email2ParseAddresses($addresses);
$this->assertSame($expected, $result);
}
示例2: toEmailBean
/**
* Prepares and executes the email request according to the expectations of the status.
*
* @param $status
* @return array - Mail API Response Record
* @throws MailerException
*/
protected function toEmailBean($status)
{
if (!empty($this->mockEmailBean)) {
$email = $this->mockEmailBean;
// Testing purposes only
} else {
$email = new Email();
}
$email->email2init();
$fromAccount = null;
if (!empty($this->mailConfig)) {
$fromAccount = $this->mailConfig;
}
$to = $this->addRecipients($this->toAddresses);
$cc = $this->addRecipients($this->ccAddresses);
$bcc = $this->addRecipients($this->bccAddresses);
$attachments = $this->splitAttachments($this->attachments);
$request = $this->setupSendRequest($status, $fromAccount, $to, $cc, $bcc, $attachments);
$_REQUEST = array_merge($_REQUEST, $request);
$errorData = null;
try {
$this->startCapturingOutput();
$email->email2Send($request);
$errorData = $this->endCapturingOutput();
if (strlen($errorData) > 0) {
throw new MailerException('Email2Send returning unexpected output: ' . $errorData);
}
$response = $this->toApiResponse($status, $email);
return $response;
} catch (Exception $e) {
if (is_null($errorData)) {
$errorData = $this->endCapturingOutput();
}
if (!$e instanceof MailerException) {
$e = new MailerException($e->getMessage());
}
if (empty($errorData)) {
$GLOBALS["log"]->error("Message: " . $e->getLogMessage());
} else {
$GLOBALS["log"]->error("Message: " . $e->getLogMessage() . " Data: " . $errorData);
}
throw $e;
}
}
示例3: syncEmail
/**
* full synchronization
*/
function syncEmail()
{
global $sugar_config;
global $current_user;
$showFolders = unserialize(base64_decode($current_user->getPreference('showFolders', 'Emails')));
if (empty($showFolders)) {
$showFolders = array();
}
$email = new Email();
$email->email2init();
// personal accounts
if ($current_user->hasPersonalEmail()) {
$personals = $this->retrieveByGroupId($current_user->id);
foreach ($personals as $personalAccount) {
if (in_array($personalAccount->id, $showFolders)) {
$personalAccount->email = $email;
if ($personalAccount->isPop3Protocol()) {
$personalAccount->deletePop3Cache();
continue;
}
$personalAccount->cleanOutCache();
$personalAccount->connectMailserver();
$mailboxes = $personalAccount->getMailboxes(true);
$mailboxes[] = 'INBOX';
sort($mailboxes);
$GLOBALS['log']->info("[EMAIL] Start checking account [{$personalAccount->name}] for user [{$current_user->user_name}]");
foreach ($mailboxes as $mailbox) {
$GLOBALS['log']->info("[EMAIL] Start checking mailbox [{$mailbox}] of account [{$personalAccount->name}] for user [{$current_user->user_name}]");
$personalAccount->checkEmailOneMailbox($mailbox, false, true);
$GLOBALS['log']->info("[EMAIL] Done checking mailbox [{$mailbox}] of account [{$personalAccount->name}] for user [{$current_user->user_name}]");
}
$GLOBALS['log']->info("[EMAIL] Done checking account [{$personalAccount->name}] for user [{$current_user->user_name}]");
}
}
}
// group accounts
$beans = $this->retrieveAllByGroupId($current_user->id, false);
foreach ($beans as $k => $groupAccount) {
if (in_array($groupAccount->id, $showFolders)) {
$groupAccount->email = $email;
$groupAccount->cleanOutCache();
$groupAccount->connectMailserver();
$mailboxes = $groupAccount->getMailboxes(true);
$mailboxes[] = 'INBOX';
sort($mailboxes);
$GLOBALS['log']->info("INBOUNDEMAIL: checking account [ {$groupAccount->name} ]");
foreach ($mailboxes as $mailbox) {
$groupAccount->checkEmailOneMailbox($mailbox, false, true);
}
}
}
}
示例4: Email
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* 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. 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): ______________________________________..
*********************************************************************************/
$focus = new Email();
$focus->email2init();
$focus->et->preflightUser($current_user);
$out = $focus->et->displayEmailFrame();
echo $out;
echo "<script>var composePackage = null;</script>";
$skipFooters = true;
示例5: Email
* 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): ______________________________________..
*********************************************************************************/
//increate timeout for phpo script execution
ini_set('max_execution_time', 300);
//ajaxInit();
require_once "include/OutboundEmail/OutboundEmail.php";
require_once "include/ytree/Tree.php";
require_once "include/ytree/ExtNode.php";
$email = new Email();
$email->email2init();
$ie = new InboundEmail();
$ie->email = $email;
$json = getJSONobj();
$showFolders = unserialize(base64_decode($current_user->getPreference('showFolders', 'Emails')));
if (isset($_REQUEST['emailUIAction'])) {
switch ($_REQUEST['emailUIAction']) {
///////////////////////////////////////////////////////////////////////////
//// COMPOSE REPLY FORWARD
// this is used in forward/reply
case "composeEmail":
$GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: composeEmail");
if (isset($_REQUEST['sugarEmail']) && $_REQUEST['sugarEmail'] == 'true' && isset($_REQUEST['uid']) && !empty($_REQUEST['uid'])) {
$ie->email->retrieve($_REQUEST['uid']);
$ie->email->from_addr = $ie->email->from_addr_name;
$ie->email->to_addrs = to_html($ie->email->to_addrs_names);
示例6: sendEmailTemplate
/**
* Send Email with attachment Report to specified emails
* @param string $attachFileName
* name of report file
* @param string $attachFilePath
* path to report file for read it and attach to email
* @param array $toAddresses
* array with email and names of contacts for send him this email
* array( array('email' => EMAIL_ADDR, 'display' => DISPLAY_NAME) )
* @param string $templateId
* optional argument. Id of Email template
* @param SugarBean $bean
* optional argument, uses for parse template with values of this bean
* @return array
* return array with status send email in this format: array('status' => TRUE_OR_FALSE, 'error' => ERROR_MSG)
*/
public static function sendEmailTemplate($attachFileName, $attachFilePath, $toAddresses, $templateId = '', $bean = NULL)
{
global $locale, $current_user, $app_strings;
$sea = new SugarEmailAddress();
$answer = array('status' => true, 'error' => '');
$email = new Email();
$email->email2init();
$email->type = 'out';
$email->status = 'sent';
$email->id = create_guid();
$email->new_with_id = true;
$emailTemplate = new EmailTemplate();
$emailTemplate->retrieve($templateId);
if (empty($emailTemplate->subject)) {
$emailTemplate->subject = $attachFileName;
//set file name as subject
}
$email->name = $emailTemplate->subject;
$email->description = $emailTemplate->body;
$email->description_html = '<html><body>' . $emailTemplate->body_html . '</body></html>';
$mail = new SugarPHPMailer();
$mail = $email->setMailer($mail, '', '');
if (empty($mail->Host)) {
if ($mail->oe->type == 'system') {
$answer['error'] = $app_strings['LBL_EMAIL_ERROR_PREPEND'] . $app_strings['LBL_EMAIL_INVALID_SYSTEM_OUTBOUND'];
} else {
$answer['error'] = $app_strings['LBL_EMAIL_ERROR_PREPEND'] . $app_strings['LBL_EMAIL_INVALID_PERSONAL_OUTBOUND'];
}
$answer['status'] = false;
return $answer;
}
$object_arr = array();
if ($bean !== NULL) {
$object_arr[$bean->module_dir] = $bean->id;
}
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;
}
}
}
$object_arr['Users'] = $current_user->id;
$email->description_html = $email->decodeDuringSend(from_html(EmailTemplate::parse_template($email->description_html, $object_arr)));
$email->description = $email->decodeDuringSend(html_entity_decode(EmailTemplate::parse_template($email->description, $object_arr), ENT_COMPAT, 'UTF-8'));
$email->name = from_html(EmailTemplate::parse_template($email->name, $object_arr));
$mail->Body = $email->description_html;
$mail->AltBody = $email->description;
$mail->Subject = $email->name;
$replyToAddress = $current_user->emailAddress->getReplyToAddress($current_user);
$defaults = $current_user->getPreferredEmail();
$mail->From = $defaults['email'];
$mail->FromName = $defaults['name'];
$mail->Sender = $mail->From;
/* set Return-Path field in header to reduce spam score in emails sent via Sugar's Email module */
$replyToName = $mail->FromName;
$OBCharset = $locale->getPrecedentPreference('default_email_charset');
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));
}
foreach ($toAddresses 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));
}
}
$mail->AddAttachment($attachFilePath, $attachFileName, 'base64', self::getMimeType($attachFileName));
$mail->prepForOutbound();
$mail->Body = $email->decodeDuringSend($mail->Body);
$mail->AltBody = $email->decodeDuringSend($mail->AltBody);
if (!$mail->Send()) {
ob_clean();
$answer['error'] = $app_strings['LBL_EMAIL_ERROR_PREPEND'] . $mail->ErrorInfo;
$answer['status'] = false;
return $answer;
}
//.........这里部分代码省略.........
示例7: setUpForRelatedEmailQueries
/**
* An InboundEmail object must be set up a particular way in order to make the EmailUI::getRelatedEmail calls found
* in EmailRecipientsService::findCount and EmailRecipientsService::find. The InboundEmail object is also needed to
* complete other logic found in those methods.
*
* @see EmailRecipientsService::findCount()
* @see EmailRecipientsService::find()
* @return InboundEmail
*/
protected function setUpForRelatedEmailQueries()
{
$email = new Email();
$email->email2init();
$inboundEmail = new InboundEmail();
$inboundEmail->email = $email;
return $inboundEmail;
}
示例8: send_email
/**
* @param $email_to email address to send to
* @param $subject subject of the email
* @param $bodyHTML HTML body content
* @param $bcc (Optional) email address to bcc
*/
public static function send_email($email_to, $subject, $bodyHTML, $bcc = null)
{
try {
global $sugar_config, $sugar_version, $sugar_flavor;
require_once "modules/Emails/Email.php";
$body = wordwrap($bodyHTML, 900);
$_REQUEST['sendDescription'] = htmlentities($body);
// Email Settings
$send_config = array('sendTo' => $email_to, 'saveToSugar' => false, 'sendSubject' => $subject, 'sendCc' => '', 'sendBcc' => '');
if (!empty($bcc)) {
$send_config['sendBcc'] = $bcc;
}
$email = new Email();
$email->email2init();
//sending email
if (!$email->email2Send($send_config)) {
AddonBoilerplate_Helper::log('fatal', "AddonBoilerplate error. Something pretty major is going on and we are trying to email " . $email_to . " about something pretty major. Please forward this message along: Subject: " . $subject . " Body: " . $body);
return false;
}
} catch (Exception $e) {
AddonBoilerplate_Helper::log('fatal', "AddonBoilerplate error. Something pretty major is going on and we are trying to email " . $email_to . " about something pretty major. Please forward this message along: Subject: " . $subject . " Body: " . $body . ". General email error: " . $e->getMessage());
return false;
}
return true;
}