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


PHP Email::sendTo方法代码示例

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


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

示例1: sendReminderMail

 /**
  * Sends a reminder mail to definined member groups.
  */
 public function sendReminderMail()
 {
     // first check if required extension 'associategroups' is installed
     if (!in_array('associategroups', $this->Config->getActiveModules())) {
         $this->log('RscNewsletterReminder: Extension "associategroups" is required!', 'RscNewsletterReminder sendReminderMail()', TL_ERROR);
         return false;
     }
     $this->loadLanguageFile("tl_settings");
     if ($this->timeleadReached()) {
         $objEmail = new \Email();
         $objEmail->logFile = 'RscNewsletterReminderEmail.log';
         $objEmail->from = $GLOBALS['TL_CONFIG']['rscNewsletterReminderEmailSenderAddress'];
         $objEmail->fromName = strlen($GLOBALS['TL_CONFIG']['rscNewsletterReminderEmailSenderName']) > 0 ? $GLOBALS['TL_CONFIG']['rscNewsletterReminderEmailSenderName'] : $GLOBALS['TL_CONFIG']['websiteTitle'];
         $objEmail->subject = $this->replaceEmailInsertTags($GLOBALS['TL_CONFIG']['rscNewsletterReminderEmailSubject']);
         $objEmail->html = $this->replaceEmailInsertTags($GLOBALS['TL_CONFIG']['rscNewsletterReminderEmailContent']);
         $objEmail->text = $this->transformEmailHtmlToText($objEmail->html);
         try {
             $objEmail->sendTo($this->getReceiverEmails());
             $this->log('Monthly sending newsletter reminder finished successfully.', 'RscNewsletterReminder sendReminderMail()', TL_CRON);
             return true;
         } catch (Swift_RfcComplianceException $e) {
             $this->log("Mail could not be send: " . $e->getMessage(), "RscNewsletterReminder sendReminderMail()", TL_ERROR);
             return false;
         }
     }
     return true;
 }
开发者ID:rsclg,项目名称:RscNewsletterReminder,代码行数:30,代码来源:RscNewsletterReminder.php

示例2: sendEmail

 public function sendEmail($subject, $body)
 {
     $email = $this->email;
     $e = new Email();
     $e->subject = $subject;
     $e->body = $body;
     $e->sendTo($email);
 }
开发者ID:jamesdcampbell,项目名称:clemsoncfa,代码行数:8,代码来源:CfaEmployee.php

示例3: defaultEvents

 /**
  * Execute the default Events (send mail / add/remove groups)
  * @param string $strEvent
  * @param object $objMember
  * @param object $objAbo
  * @param object $objAboOrder
  */
 public function defaultEvents($strEvent, $objMember, $objAbo, $objAboOrder)
 {
     $objEvents = \Database::getInstance()->prepare("\n\t\t\tSELECT\t* FROM tl_abo_events as e\n\t\t\t\tLEFT JOIN tl_abo as a\n\t\t\t\tON a.id = e.pid\n\t\t\tWHERE a.id = ?\n\t\t\t\tAND e.published = 1\n\t\t\t\tAND e.event = ?")->execute($objAbo->id, $strEvent);
     if (!$objEvents->numRows) {
         return;
     }
     $this->aboLog("Event: " . $strEvent . " ausgeführt", __METHOD__, 'INFO', $objMember->id);
     // Load Current Abo
     $this->setAbo($objAbo);
     $this->setMember($objMember);
     $this->setAboOrder($objAboOrder);
     while ($objEvents->next()) {
         // send mail ?
         if ($objEvents->use_email) {
             $objMail = new \Email();
             $objMail->subject = $this->replaceInsertTagsAbo($objEvents->email_subject, $objMember);
             $objMail->text = $this->replaceInsertTagsAbo($objEvents->email_text, $objMember);
             if ($objEvents->email_template) {
                 $strTemplatePath = $objEvents->email_template;
                 if (VERSION >= 3) {
                     $objFile = \FilesModel::findByPk($strTemplatePath);
                     $strTemplatePath = $objFile->path;
                 }
                 $objMailTemplate = new File($strTemplatePath);
                 $objMail->html = $this->replaceInsertTagsAbo($objMailTemplate->getContent(), $objMember);
             }
             $objMail->from = $objEvents->email_from;
             $objMail->fromName = $objEvents->email_fromname;
             if ($objEvents->email_bcc) {
                 $objMail->sendBcc($objEvents->email_bcc);
             }
             $objMail->sendTo($objMember->email);
             $this->aboLog("E-Mail an " . $objMember->email . ' versendet.', __METHOD__, 'INFO', $objMember->id);
         }
         // set groups ?
         if ($objEvents->use_groups) {
             $arrMergedGroups = $this->groupManager($objMember, $objEvents->addGroups, $objEvents->removeGroups);
             Database::getInstance()->prepare("UPDATE tl_member SET groups = ? WHERE id = ?")->execute(serialize($arrMergedGroups), $objMember->id);
             $this->aboLog("Mitgliedergruppen: Aktiviert (" . implode(',', deserialize($objEvents->addGroups, true)) . ') / Deaktiviert: (' . implode(',', deserialize($objEvents->removeGroups, true)) . ')', __METHOD__, 'INFO', $objMember->id);
         }
     }
 }
开发者ID:thescrat,项目名称:abonnement,代码行数:49,代码来源:AboEvents.php

示例4: showPopup

 public function showPopup()
 {
     $objTemplate = new \BackendTemplate('be_formbox');
     $objUser = \BackendUser::getInstance();
     if (\Input::post('FORM_SUBMIT') == 'formbox') {
         $objDate = new \Date();
         $objEmail = new \Email();
         $objEmail->subject = $GLOBALS['TL_CONFIG']['websiteTitle'] . ' - ' . $GLOBALS['TL_CONFIG']['be_formbox_button_text'];
         $strHtml = '<p>User: ' . $objUser->username . ' (' . $objUser->email . ')</p>';
         $strHtml .= '<p>Site: ' . \Input::post('url') . '</p>';
         $strHtml .= '<p>Datum: ' . $objDate->datim . '</p>';
         $strHtml .= '<p>Message: ' . \Input::post('message') . '</p>';
         $objEmail->html = $strHtml;
         $objEmail->replyTo($objUser->name . ' <' . $objUser->email . '>');
         $objEmail->sendTo($GLOBALS['TL_CONFIG']['be_formbox_email']);
         $objTemplate->strMessageSent = $GLOBALS['TL_CONFIG']['be_formbox_message_sent'];
     }
     $objTemplate->strFormUrl = 'contao/main.php?do=undo&key=be-formbox&nb=1&popup=1';
     $objTemplate->strUrl = base64_decode(\Input::get('link'));
     $objTemplate->strFormboxMessage = $GLOBALS['TL_CONFIG']['be_formbox_message'];
     return $objTemplate->parse();
 }
开发者ID:mindbird,项目名称:contao-be-formbox,代码行数:22,代码来源:Formbox.php

示例5: sendNewsletter

 /**
  * Compile the newsletter and send it
  * @param object
  * @param object
  * @param array
  * @param string
  * @param string
  * @param string
  * @return string
  */
 protected function sendNewsletter(Email $objEmail, Database_Result $objNewsletter, $arrRecipient, $text, $html, $css)
 {
     // Prepare text content
     $objEmail->text = $this->parseSimpleTokens($text, $arrRecipient);
     // Add HTML content
     if (!$objNewsletter->sendText) {
         // Get the mail template
         $objTemplate = new BackendTemplate(strlen($objNewsletter->template) ? $objNewsletter->template : 'mail_default');
         $objTemplate->setData($objNewsletter->row());
         $objTemplate->title = $objNewsletter->subject;
         $objTemplate->body = $this->parseSimpleTokens($html, $arrRecipient);
         $objTemplate->charset = $GLOBALS['TL_CONFIG']['characterSet'];
         $objTemplate->css = $css;
         // Parse template
         $objEmail->html = $objTemplate->parse();
         $objEmail->imageDir = TL_ROOT . '/';
     }
     // Deactivate invalid addresses
     try {
         $objEmail->sendTo($arrRecipient['email']);
     } catch (Swift_RfcComplianceException $e) {
         $_SESSION['REJECTED_RECIPIENTS'][] = $arrRecipient['email'];
     }
     // Rejected recipients
     if (count($objEmail->failures)) {
         $_SESSION['REJECTED_RECIPIENTS'][] = $arrRecipient['email'];
     }
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:38,代码来源:Newsletter.php

示例6: login

 /**
  * Try to login the current user
  * 
  * @return boolean True if the user could be logged in
  */
 public function login()
 {
     $this->loadLanguageFile('default');
     // Do not continue if username or password are missing
     if (!\Input::post('username') || !\Input::post('password')) {
         return false;
     }
     // Load the user object
     if ($this->findBy('username', \Input::post('username')) == false) {
         $blnLoaded = false;
         // HOOK: pass credentials to callback functions
         if (isset($GLOBALS['TL_HOOKS']['importUser']) && is_array($GLOBALS['TL_HOOKS']['importUser'])) {
             foreach ($GLOBALS['TL_HOOKS']['importUser'] as $callback) {
                 $this->import($callback[0], 'objImport', true);
                 $blnLoaded = $this->objImport->{$callback}[1](\Input::post('username'), \Input::post('password'), $this->strTable);
                 // Load successfull
                 if ($blnLoaded === true) {
                     break;
                 }
             }
         }
         // Return if the user still cannot be loaded
         if (!$blnLoaded || $this->findBy('username', \Input::post('username')) == false) {
             \Message::addError($GLOBALS['TL_LANG']['ERR']['invalidLogin']);
             $this->log('Could not find user "' . \Input::post('username') . '"', get_class($this) . ' login()', TL_ACCESS);
             return false;
         }
     }
     $time = time();
     // Set the user language
     if (\Input::post('language')) {
         $this->language = \Input::post('language');
     }
     // Lock the account if there are too many login attempts
     if ($this->loginCount < 1) {
         $this->locked = $time;
         $this->loginCount = $GLOBALS['TL_CONFIG']['loginCount'];
         $this->save();
         // Add a log entry
         $this->log('The account has been locked for security reasons', get_class($this) . ' login()', TL_ACCESS);
         // Send admin notification
         if (strlen($GLOBALS['TL_CONFIG']['adminEmail'])) {
             $objEmail = new \Email();
             $objEmail->subject = $GLOBALS['TL_LANG']['MSC']['lockedAccount'][0];
             $objEmail->text = sprintf($GLOBALS['TL_LANG']['MSC']['lockedAccount'][1], $this->username, TL_MODE == 'FE' ? $this->firstname . " " . $this->lastname : $this->name, \Environment::get('base'), ceil($GLOBALS['TL_CONFIG']['lockPeriod'] / 60));
             $objEmail->sendTo($GLOBALS['TL_CONFIG']['adminEmail']);
         }
         return false;
     }
     // Check the account status
     if ($this->checkAccountStatus() == false) {
         return false;
     }
     $blnAuthenticated = false;
     list($strPassword, $strSalt) = explode(':', $this->password);
     // Password is correct but not yet salted
     if (!strlen($strSalt) && $strPassword == sha1(\Input::post('password'))) {
         $strSalt = substr(md5(uniqid(mt_rand(), true)), 0, 23);
         $strPassword = sha1($strSalt . \Input::post('password'));
         $this->password = $strPassword . ':' . $strSalt;
     }
     // Check the password against the database
     if (strlen($strSalt) && $strPassword == sha1($strSalt . \Input::post('password'))) {
         $blnAuthenticated = true;
     } elseif (isset($GLOBALS['TL_HOOKS']['checkCredentials']) && is_array($GLOBALS['TL_HOOKS']['checkCredentials'])) {
         foreach ($GLOBALS['TL_HOOKS']['checkCredentials'] as $callback) {
             $this->import($callback[0], 'objAuth', true);
             $blnAuthenticated = $this->objAuth->{$callback}[1](\Input::post('username'), \Input::post('password'), $this);
             // Authentication successfull
             if ($blnAuthenticated === true) {
                 break;
             }
         }
     }
     // Redirect if the user could not be authenticated
     if (!$blnAuthenticated) {
         --$this->loginCount;
         $this->save();
         \Message::addError($GLOBALS['TL_LANG']['ERR']['invalidLogin']);
         $this->log('Invalid password submitted for username "' . $this->username . '"', get_class($this) . ' login()', TL_ACCESS);
         return false;
     }
     $this->setUserFromDb();
     // Update the record
     $this->lastLogin = $this->currentLogin;
     $this->currentLogin = $time;
     $this->loginCount = $GLOBALS['TL_CONFIG']['loginCount'];
     $this->save();
     // Generate the session
     $this->generateSession();
     $this->log('User "' . $this->username . '" has logged in', get_class($this) . ' login()', TL_ACCESS);
     // HOOK: post login callback
     if (isset($GLOBALS['TL_HOOKS']['postLogin']) && is_array($GLOBALS['TL_HOOKS']['postLogin'])) {
         foreach ($GLOBALS['TL_HOOKS']['postLogin'] as $callback) {
             $this->import($callback[0], 'objLogin', true);
//.........这里部分代码省略.........
开发者ID:rikaix,项目名称:core,代码行数:101,代码来源:User.php

示例7: sendNewsletter

 /**
  * Send a newsletter.
  */
 protected function sendNewsletter(Email $email, $plain, $html, $recipientData, $personalized)
 {
     // set text content
     $email->text = $plain;
     // Prepare html content
     $email->html = $html;
     $email->imageDir = TL_ROOT . '/';
     $failed = false;
     // Deactivate invalid addresses
     try {
         if ($GLOBALS['TL_CONFIG']['avisota_developer_mode']) {
             $email->sendTo($GLOBALS['TL_CONFIG']['avisota_developer_email']);
         } else {
             $email->sendTo($recipientData['email']);
         }
     } catch (Swift_RfcComplianceException $e) {
         $failed = true;
     }
     // Rejected recipients
     if (count($email->failures)) {
         $failed = true;
     }
     $this->Static->resetRecipient();
     return !$failed;
 }
开发者ID:Ainschy,项目名称:contao-core,代码行数:28,代码来源:AvisotaNewsletterTransport.php

示例8: editTask


//.........这里部分代码省略.........
			$this->redirect('contao/main.php?act=error');
		}

		// Advanced options
		$this->blnAdvanced = ($this->User->isAdmin || $objTask->createdBy == $this->User->id);
		$this->Template->advanced = $this->blnAdvanced;

		$this->Template->title = $this->blnAdvanced ? $this->getTitleWidget($objTask->title) : $objTask->title;
		$this->Template->deadline = $this->blnAdvanced ? $this->getDeadlineWidget($this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $objTask->deadline)) : $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $objTask->deadline);

		$arrHistory = array();

		// Get the status
		$objStatus = $this->Database->prepare("SELECT *, (SELECT name FROM tl_user u WHERE u.id=s.assignedTo) AS name FROM tl_task_status s WHERE pid=? ORDER BY tstamp")
									->execute($this->Input->get('id'));

		while($objStatus->next())
		{
			$arrHistory[] = array
			(
				'creator' => $objTask->creator,
				'date' => $this->parseDate($GLOBALS['TL_CONFIG']['dateFormat'], $objStatus->tstamp),
				'status' => (($GLOBALS['TL_LANG']['tl_task_status'][$objStatus->status] != '') ? $GLOBALS['TL_LANG']['tl_task_status'][$objStatus->status] : $objStatus->status),
				'comment' => (($objStatus->comment != '') ? nl2br_html5($objStatus->comment) : '&nbsp;'),
				'assignedTo' => $objStatus->assignedTo,
				'progress' => $objStatus->progress,
				'class' => $objStatus->status,
				'name' => $objStatus->name
			);
		}

		$this->Template->assignedTo = $this->getAssignedToWidget($objStatus->assignedTo);
		$this->Template->notify = $this->getNotifyWidget();
		$this->Template->status = $this->getStatusWidget($objStatus->status, $objStatus->progress);
		$this->Template->progress = $this->getProgressWidget($objStatus->progress);
		$this->Template->comment = $this->getCommentWidget();

		// Update task
		if ($this->Input->post('FORM_SUBMIT') == 'tl_tasks' && $this->blnSave)
		{
			// Update task
			if ($this->blnAdvanced)
			{
				$deadline = new Date($this->Template->deadline->value, $GLOBALS['TL_CONFIG']['dateFormat']);

				$this->Database->prepare("UPDATE tl_task SET title=?, deadline=? WHERE id=?")
							   ->execute($this->Template->title->value, $deadline->dayBegin, $this->Input->get('id'));
			}

			// Insert status
			$arrSet = array
			(
				'pid' => $this->Input->get('id'),
				'tstamp' => time(),
				'assignedTo' => $this->Template->assignedTo->value,
				'status' => $this->Template->status->value,
				'progress' => (($this->Template->status->value == 'completed') ? 100 : $this->Template->progress->value),
				'comment' => trim($this->Template->comment->value)
			);

			$this->Database->prepare("INSERT INTO tl_task_status %s")->set($arrSet)->execute();

			// Notify user
			if ($this->Input->post('notify'))
			{
				$objUser = $this->Database->prepare("SELECT email FROM tl_user WHERE id=?")
										  ->limit(1)
										  ->execute($this->Template->assignedTo->value);

				if ($objUser->numRows)
				{
					$objEmail = new Email();

					$objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
					$objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
					$objEmail->subject = $objTask->title;

					$objEmail->text = trim($this->Template->comment->value);
					$objEmail->text .= sprintf($GLOBALS['TL_LANG']['tl_task']['message'], $this->User->name, $this->Environment->base . 'contao/main.php?do=tasks&act=edit&id=' . $objTask->id);

					$objEmail->sendTo($objUser->email);
				}
			}

			// Go back
			$this->redirect('contao/main.php?do=tasks');
		}

		$this->Template->history = $arrHistory;
		$this->Template->historyLabel = $GLOBALS['TL_LANG']['tl_task']['history'];
		$this->Template->deadlineLabel = $GLOBALS['TL_LANG']['tl_task']['deadline'][0];
		$this->Template->dateLabel = $GLOBALS['TL_LANG']['tl_task']['date'];
		$this->Template->assignedToLabel = $GLOBALS['TL_LANG']['tl_task']['assignedTo'];
		$this->Template->createdByLabel = $GLOBALS['TL_LANG']['tl_task']['creator'];
		$this->Template->statusLabel = $GLOBALS['TL_LANG']['tl_task']['status'][0];
		$this->Template->progressLabel = $GLOBALS['TL_LANG']['tl_task']['progress'][0];
		$this->Template->submit = $GLOBALS['TL_LANG']['tl_task']['editSubmit'];
		$this->Template->titleLabel = $GLOBALS['TL_LANG']['tl_task']['title'][0];
		$this->Template->assignLabel = $GLOBALS['TL_LANG']['tl_task']['assignedTo'];
	}
开发者ID:narrenfrei,项目名称:core,代码行数:101,代码来源:ModuleTasks.php

示例9: addRecipient

 /**
  * Add a new recipient
  */
 protected function addRecipient()
 {
     if (!\Environment::get('isAjaxRequest')) {
         return parent::addRecipient();
     }
     $arrChannels = \Input::post('channels');
     if (!is_array($arrChannels)) {
         $_SESSION['UNSUBSCRIBE_ERROR'] = $GLOBALS['TL_LANG']['ERR']['noChannels'];
         return false;
     }
     $arrChannels = array_intersect($arrChannels, $this->nl_channels);
     // see #3240
     // Check the selection
     if (!is_array($arrChannels) || empty($arrChannels)) {
         $_SESSION['SUBSCRIBE_ERROR'] = $GLOBALS['TL_LANG']['ERR']['noChannels'];
         return false;
     }
     $varInput = \Idna::encodeEmail(\Input::post('email', true));
     // Validate the e-mail address
     if (!\Validator::isEmail($varInput)) {
         $_SESSION['SUBSCRIBE_ERROR'] = $GLOBALS['TL_LANG']['ERR']['email'];
         return false;
     }
     $arrSubscriptions = array();
     // Get the existing active subscriptions
     if (($objSubscription = \NewsletterRecipientsModel::findBy(array("email=? AND active=1"), $varInput)) !== null) {
         $arrSubscriptions = $objSubscription->fetchEach('pid');
     }
     $arrNew = array_diff($arrChannels, $arrSubscriptions);
     // Return if there are no new subscriptions
     if (!is_array($arrNew) || empty($arrNew)) {
         $_SESSION['SUBSCRIBE_ERROR'] = $GLOBALS['TL_LANG']['ERR']['subscribed'];
         return false;
     }
     // Remove old subscriptions that have not been activated yet
     if (($objOld = \NewsletterRecipientsModel::findBy(array("email=? AND active=''"), $varInput)) !== null) {
         while ($objOld->next()) {
             $objOld->delete();
         }
     }
     $time = time();
     $strToken = md5(uniqid(mt_rand(), true));
     // Add the new subscriptions
     foreach ($arrNew as $id) {
         $objRecipient = new \NewsletterRecipientsModel();
         $objRecipient->pid = $id;
         $objRecipient->tstamp = $time;
         $objRecipient->email = $varInput;
         $objRecipient->active = '';
         $objRecipient->addedOn = $time;
         $objRecipient->ip = $this->anonymizeIp(\Environment::get('ip'));
         $objRecipient->token = $strToken;
         $objRecipient->confirmed = '';
         $objRecipient->save();
     }
     // Get the channels
     $objChannel = \NewsletterChannelModel::findByIds($arrChannels);
     // Prepare the e-mail text
     $strText = str_replace('##token##', $strToken, $this->nl_subscribe);
     $strText = str_replace('##domain##', \Idna::decode(\Environment::get('host')), $strText);
     $strText = str_replace('##link##', \Idna::decode(\Environment::get('base')) . \Environment::get('request') . (\Config::get('disableAlias') || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $strToken, $strText);
     $strText = str_replace(array('##channel##', '##channels##'), implode("\n", $objChannel->fetchEach('title')), $strText);
     // Activation e-mail
     $objEmail = new \Email();
     $objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
     $objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
     $objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['nl_subject'], \Idna::decode(\Environment::get('host')));
     $objEmail->text = $strText;
     $objEmail->sendTo($varInput);
     // Redirect to the jumpTo page
     if ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) !== null) {
         $this->redirect($this->generateFrontendUrl($objTarget->row()));
     }
     $_SESSION['SUBSCRIBE_CONFIRM'] = $GLOBALS['TL_LANG']['MSC']['nl_confirm'];
     return true;
 }
开发者ID:heimrichhannot,项目名称:contao-bootstrapper,代码行数:79,代码来源:ModuleAjaxSubscribe.php

示例10: onSubmitCbSendEmail

 /**
  * onsubmit_callback
  * send email
  */
 public function onSubmitCbSendEmail()
 {
     // the save-button is a fileupload-button
     if (!\Input::post('saveNclose')) {
         return;
     }
     $email = new Email();
     $fromMail = $this->User->email;
     $subject = \Input::post('subject');
     $email->replyTo($fromMail);
     $email->from = $fromMail;
     $email->subject = $subject;
     $email->html = base64_decode($_POST['content']);
     //save attachment
     $arrFiles = array();
     $db = $this->Database->prepare('SELECT attachment FROM tl_be_email WHERE id=?')->execute(\Input::get('id'));
     // Attachment
     if ($db->attachment != '') {
         $arrFiles = unserialize($db->attachment);
         foreach ($arrFiles as $filekey => $filename) {
             if (file_exists(TL_ROOT . '/' . BE_EMAIL_UPLOAD_DIR . '/' . $filekey)) {
                 $this->Files->copy(BE_EMAIL_UPLOAD_DIR . '/' . $filekey, 'system/tmp/' . $filename);
                 $email->attachFile(TL_ROOT . '/system/tmp/' . $filename);
             }
         }
     }
     // Cc
     $cc_recipients = array_unique($this->validateEmailAddresses(\Input::post('recipientsCc'), 'recipientsCc'));
     if (count($cc_recipients)) {
         $email->sendCc($cc_recipients);
     }
     // Bcc
     $bcc_recipients = array_unique($this->validateEmailAddresses(\Input::post('recipientsBcc'), 'recipientsBcc'));
     if (count($bcc_recipients)) {
         $email->sendBcc($bcc_recipients);
     }
     // To
     $recipients = array_unique($this->validateEmailAddresses(\Input::post('recipientsTo'), 'recipientsTo'));
     if (count($recipients)) {
         $email->sendTo($recipients);
     }
     // Delete attachment from server
     foreach ($arrFiles as $filekey => $filename) {
         // delete file in the tmp-folder
         if (is_file(TL_ROOT . '/system/tmp/' . $filename)) {
             $this->Files->delete('/system/tmp/' . $filename);
         }
     }
 }
开发者ID:markocupic,项目名称:be_email,代码行数:53,代码来源:tl_be_email.php

示例11: createNewUser

 /**
  * Create a new user and redirect
  * @param array
  */
 protected function createNewUser($arrData)
 {
     $arrData['tstamp'] = time();
     $arrData['login'] = $this->reg_allowLogin;
     $arrData['activation'] = md5(uniqid(mt_rand(), true));
     $arrData['dateAdded'] = $arrData['tstamp'];
     if ($this->reg_createLoginCredentials) {
         $this->createLoginCredentials($arrData);
     }
     // Set default groups
     if (!array_key_exists('groups', $arrData)) {
         $arrData['groups'] = $this->reg_groups;
     }
     // Disable account
     $arrData['disable'] = 1;
     // Send activation e-mail
     if ($this->reg_activate) {
         $arrChunks = array();
         $strConfirmation = $this->reg_text;
         preg_match_all('/##[^#]+##/i', $strConfirmation, $arrChunks);
         foreach ($arrChunks[0] as $strChunk) {
             $strKey = substr($strChunk, 2, -2);
             switch ($strKey) {
                 case 'domain':
                     $strConfirmation = str_replace($strChunk, $this->Environment->host, $strConfirmation);
                     break;
                 case 'link':
                     $strConfirmation = str_replace($strChunk, $this->Environment->base . $this->Environment->request . ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos($this->Environment->request, '?') !== false ? '&' : '?') . 'token=' . $arrData['activation'], $strConfirmation);
                     break;
                     // HOOK: support newsletter subscriptions
                 // HOOK: support newsletter subscriptions
                 case 'channel':
                 case 'channels':
                     if (!in_array('newsletter', $this->Config->getActiveModules())) {
                         break;
                     }
                     // Make sure newsletter is an array
                     if (!is_array($arrData['newsletter'])) {
                         if ($arrData['newsletter'] != '') {
                             $arrData['newsletter'] = array($arrData['newsletter']);
                         } else {
                             $arrData['newsletter'] = array();
                         }
                     }
                     // Replace the wildcard
                     if (count($arrData['newsletter']) > 0) {
                         $objChannels = $this->Database->execute("SELECT title FROM tl_newsletter_channel WHERE id IN(" . implode(',', array_map('intval', $arrData['newsletter'])) . ")");
                         $strConfirmation = str_replace($strChunk, implode("\n", $objChannels->fetchEach('title')), $strConfirmation);
                     } else {
                         $strConfirmation = str_replace($strChunk, '', $strConfirmation);
                     }
                     break;
                 default:
                     $strConfirmation = str_replace($strChunk, $arrData[$strKey], $strConfirmation);
                     break;
             }
         }
         $objEmail = new Email();
         $objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
         $objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
         $objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['emailSubject'], $this->Environment->host);
         $objEmail->text = $strConfirmation;
         $objEmail->sendTo($arrData['email']);
     }
     // replace password in database with encrypted version after mail is sent
     if ($this->reg_createLoginCredentials) {
         // ony encrypt password if its not already encrypted
         if (!empty($arrData['password']) && strpos($arrData['password'], ':') != 40) {
             $strSalt = substr(md5(uniqid(mt_rand(), true)), 0, 23);
             $arrData['password'] = sha1($strSalt . $arrData['password']) . ':' . $strSalt;
             $this->Database->prepare("UPDATE tl_member SET password=? WHERE id=?")->execute($arrData['password'], $insertId);
         }
     }
     // Make sure newsletter is an array
     if (isset($arrData['newsletter']) && !is_array($arrData['newsletter'])) {
         $arrData['newsletter'] = array($arrData['newsletter']);
     }
     // Create user
     $objNewUser = $this->Database->prepare("INSERT INTO tl_member %s")->set($arrData)->execute();
     $insertId = $objNewUser->insertId;
     // Assign home directory
     if ($this->reg_assignDir && is_dir(TL_ROOT . '/' . $this->reg_homeDir)) {
         $this->import('Files');
         $strUserDir = strlen($arrData['username']) ? $arrData['username'] : 'user_' . $insertId;
         // Add the user ID if the directory exists
         if (is_dir(TL_ROOT . '/' . $this->reg_homeDir . '/' . $strUserDir)) {
             $strUserDir .= '_' . $insertId;
         }
         new Folder($this->reg_homeDir . '/' . $strUserDir);
         $this->Database->prepare("UPDATE tl_member SET homeDir=?, assignDir=1 WHERE id=?")->execute($this->reg_homeDir . '/' . $strUserDir, $insertId);
     }
     // HOOK: send insert ID and user data
     if (isset($GLOBALS['TL_HOOKS']['createNewUser']) && is_array($GLOBALS['TL_HOOKS']['createNewUser'])) {
         foreach ($GLOBALS['TL_HOOKS']['createNewUser'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback}[0]->{$callback}[1]($insertId, $arrData);
//.........这里部分代码省略.........
开发者ID:numero2,项目名称:contao-autologincredentials,代码行数:101,代码来源:AutoLoginCredentials.php

示例12: renderTestimonialForm


//.........这里部分代码省略.........
     $objTemplate->formId = $strFormId;
     $objTemplate->hasError = $doNotSubmit;
     // Do not index or cache the page with the confirmation message
     if ($_SESSION['TL_TESTIMONIAL_ADDED']) {
         global $objPage;
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         $objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['com_confirm'];
         $_SESSION['TL_TESTIMONIAL_ADDED'] = false;
     }
     // Store the testimonial
     if (!$doNotSubmit && \Input::post('FORM_SUBMIT') == $strFormId) {
         $strWebsite = $arrWidgets['url']->value;
         if ($strWebsite == $GLOBALS['TL_LANG']['MSC']['tm_url']) {
             $strWebsite = '';
         }
         // Add http:// to the website
         if ($strWebsite != '' && !preg_match('@^(https?://|ftp://|mailto:|#)@i', $strWebsite)) {
             $strWebsite = 'http://' . $strWebsite;
         }
         // Do not parse any tags in the testimonial
         $strTestimonial = htmlspecialchars(trim($arrWidgets['testimonial']->value));
         $strTestimonial = str_replace(array('&amp;', '&lt;', '&gt;'), array('[&]', '[lt]', '[gt]'), $strTestimonial);
         // Remove multiple line feeds
         $strTestimonial = preg_replace('@\\n\\n+@', "\n\n", $strTestimonial);
         // Parse BBCode
         if ($objConfig->bbcode) {
             $strTestimonial = $this->parseBbCode($strTestimonial);
         }
         // Prevent cross-site request forgeries
         $strTestimonial = preg_replace('/(href|src|on[a-z]+)="[^"]*(contao\\/main\\.php|typolight\\/main\\.php|javascript|vbscri?pt|script|alert|document|cookie|window)[^"]*"+/i', '$1="#"', $strTestimonial);
         $time = time();
         if ($objConfig->addVote) {
             // make the totalvote object
             $fields = 0;
             $value = 0.0;
             if ($objConfig->enableVoteField1) {
                 $arrWidgets['votefield1']->value = $this->getRatingValue($arrWidgets['votefield1']->value);
                 $value = $value + $arrWidgets['votefield1']->value;
                 $fields++;
             }
             if ($objConfig->enableVoteField2) {
                 $arrWidgets['votefield2']->value = $this->getRatingValue($arrWidgets['votefield2']->value);
                 $value = $value + $arrWidgets['votefield2']->value;
                 $fields++;
             }
             if ($objConfig->enableVoteField3) {
                 $arrWidgets['votefield3']->value = $this->getRatingValue($arrWidgets['votefield3']->value);
                 $value = $value + $arrWidgets['votefield3']->value;
                 $fields++;
             }
             if ($objConfig->enableVoteField4) {
                 $arrWidgets['votefield4']->value = $this->getRatingValue($arrWidgets['votefield4']->value);
                 $value = $value + $arrWidgets['votefield4']->value;
                 $fields++;
             }
             if ($objConfig->enableVoteField5) {
                 $arrWidgets['votefield5']->value = $this->getRatingValue($arrWidgets['votefield5']->value);
                 $value = $value + $arrWidgets['votefield5']->value;
                 $fields++;
             }
             if ($objConfig->enableVoteField6) {
                 $arrWidgets['votefield6']->value = $this->getRatingValue($arrWidgets['votefield6']->value);
                 $value = $value + $arrWidgets['votefield6']->value;
                 $fields++;
             }
             $totalvote = $value / $fields;
             $strTVotes = number_format($totalvote, 2);
         }
         if ($arrWidgets['company']->value == $value_company) {
             $arrWidgets['company']->value = '';
         }
         if ($arrWidgets['title']->value == $value_title) {
             $arrWidgets['title']->value = '';
         }
         // Prepare the record
         $arrSet = array('tstamp' => $time, 'name' => $arrWidgets['name']->value, 'email' => $arrWidgets['email']->value, 'company' => $arrWidgets['company']->value, 'title' => $arrWidgets['title']->value, 'url' => $strWebsite, 'testimonial' => $this->convertLineFeeds($strTestimonial), 'ip' => $this->anonymizeIp($this->Environment->ip), 'date' => $time, 'votestotal' => $strTVotes, 'votefield1' => !$objConfig->enableVoteField1 ? '' : $arrWidgets['votefield1']->value, 'votefield2' => !$objConfig->enableVoteField2 ? '' : $arrWidgets['votefield2']->value, 'votefield3' => !$objConfig->enableVoteField3 ? '' : $arrWidgets['votefield3']->value, 'votefield4' => !$objConfig->enableVoteField4 ? '' : $arrWidgets['votefield4']->value, 'votefield5' => !$objConfig->enableVoteField5 ? '' : $arrWidgets['votefield5']->value, 'votefield6' => !$objConfig->enableVoteField6 ? '' : $arrWidgets['votefield6']->value, 'published' => $objConfig->moderate ? '' : 1);
         // Store the testimonial
         $objTestimonials = new \TestimonialsModel();
         $objTestimonials->setRow($arrSet)->save();
         // Prepare the notification mail
         $objEmail = new \Email();
         $objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
         $objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
         $objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['tm_subject'], \Idna::decode(\Environment::get('host')));
         // Convert the testimonial to plain text
         $strTestimonial = strip_tags($strTestimonial);
         $strTestimonial = \StringUtil::decodeEntities($strTestimonial);
         $strTestimonial = str_replace(array('[&]', '[lt]', '[gt]'), array('&', '<', '>'), $strTestimonial);
         // Add the testimonial details
         $objEmail->text = sprintf($GLOBALS['TL_LANG']['MSC']['tm_message'], $arrSet['name'] . ' (' . $arrSet['email'] . ')', $strTestimonial, \Idna::decode(\Environment::get('base')) . \Environment::get('request'), \Idna::decode(\Environment::get('base')) . 'contao/main.php?do=testimonials&act=edit&id=' . $objTestimonials->id);
         $objEmail->sendTo($GLOBALS['TL_ADMIN_EMAIL']);
         // Pending for approval
         if ($objConfig->moderate) {
             // FIXME: notify the subscribers when the testimonial is published
             $_SESSION['TL_TESTIMONIAL_ADDED'] = true;
         }
         $this->reload();
     }
 }
开发者ID:jedostyle,项目名称:contao-testimonials,代码行数:101,代码来源:Testimonials.php

示例13: sendNewsletter

 /**
  * Compile the newsletter and send it
  * @param \Email
  * @param \Database_Result
  * @param array
  * @param string
  * @param string
  * @param string
  * @return string
  */
 protected function sendNewsletter(\Email $objEmail, \Database_Result $objNewsletter, $arrRecipient, $text, $html, $css = null)
 {
     // Prepare the text content
     $objEmail->text = \String::parseSimpleTokens($text, $arrRecipient);
     // Add the HTML content
     if (!$objNewsletter->sendText) {
         // Default template
         if ($objNewsletter->template == '') {
             $objNewsletter->template = 'mail_default';
         }
         // Load the mail template
         $objTemplate = new \BackendTemplate($objNewsletter->template);
         $objTemplate->setData($objNewsletter->row());
         $objTemplate->title = $objNewsletter->subject;
         $objTemplate->body = \String::parseSimpleTokens($html, $arrRecipient);
         $objTemplate->charset = $GLOBALS['TL_CONFIG']['characterSet'];
         $objTemplate->css = $css;
         // Backwards compatibility
         // Parse template
         $objEmail->html = $objTemplate->parse();
         $objEmail->imageDir = TL_ROOT . '/';
     }
     // Deactivate invalid addresses
     try {
         $objEmail->sendTo($arrRecipient['email']);
     } catch (Swift_RfcComplianceException $e) {
         $_SESSION['REJECTED_RECIPIENTS'][] = $arrRecipient['email'];
     }
     // Rejected recipients
     if ($objEmail->hasFailures()) {
         $_SESSION['REJECTED_RECIPIENTS'][] = $arrRecipient['email'];
     }
 }
开发者ID:rikaix,项目名称:core,代码行数:43,代码来源:Newsletter.php

示例14: sendPasswordLink

 /**
  * Create a new user and redirect
  *
  * @param \MemberModel $objMember
  */
 protected function sendPasswordLink($objMember)
 {
     $confirmationId = md5(uniqid(mt_rand(), true));
     // Store the confirmation ID
     $objMember = \MemberModel::findByPk($objMember->id);
     $objMember->activation = $confirmationId;
     $objMember->save();
     // Prepare the simple token data
     $arrData = $objMember->row();
     $arrData['domain'] = \Idna::decode(\Environment::get('host'));
     $arrData['link'] = \Idna::decode(\Environment::get('base')) . \Environment::get('request') . (\Config::get('disableAlias') || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $confirmationId;
     // Send e-mail
     $objEmail = new \Email();
     $objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
     $objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
     $objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['passwordSubject'], \Idna::decode(\Environment::get('host')));
     $objEmail->text = \String::parseSimpleTokens($this->reg_password, $arrData);
     $objEmail->sendTo($objMember->email);
     $this->log('A new password has been requested for user ID ' . $objMember->id . ' (' . $objMember->email . ')', __METHOD__, TL_ACCESS);
     // Check whether there is a jumpTo page
     if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null) {
         $this->jumpToOrReload($objJumpTo->row());
     }
     $this->reload();
 }
开发者ID:juergen83,项目名称:contao,代码行数:30,代码来源:ModulePassword.php

示例15: sendUnSubscribeMail

 public function sendUnSubscribeMail($channels, $subject = '', $text = '')
 {
     $objChannel = \Database::getInstance()->prepare("SELECT * FROM tl_newsletter_channel WHERE id IN (" . implode(',', $channels) . ")")->limit(1)->execute();
     $objEmail = new \Email();
     if (empty($subject)) {
         $subject = $objChannel->first()->nl_unsubscribe_subject;
     }
     if (empty($text)) {
         $text = $objChannel->first()->nl_unsubscribe_text;
     }
     $strSubject = str_replace(array('##channel##', '##channels##'), implode(",", $objChannel->fetchEach('title')), $subject);
     $strText = str_replace('##salutation##', $this->getSalutation(), $text);
     $strText = str_replace('##domain##', \Idna::decode(\Environment::get('host')), $strText);
     $strText = str_replace('##link##', \Idna::decode(\Environment::get('base')) . \Environment::get('request') . (\Config::get('disableAlias') || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $this->token, $strText);
     $strText = str_replace(array('##channel##', '##channels##'), implode("\n", $objChannel->fetchEach('title')), $strText);
     $objEmail->from = $objChannel->first()->nl_unsubscribe_sender_mail ? $objChannel->first()->nl_unsubscribe_sender_mail : $GLOBALS['TL_ADMIN_EMAIL'];
     $objEmail->fromName = $objChannel->first()->nl_unsubscribe_sender_name ? $objChannel->first()->nl_unsubscribe_sender_name : $GLOBALS['TL_ADMIN_NAME'];
     $objEmail->subject = $this->replaceInsertTags($strSubject);
     $objEmail->text = $this->replaceInsertTags($strText);
     if ($objEmail->sendTo($this->email)) {
         $_SESSION['UNSUBSCRIBE_CONFIRM'] = $GLOBALS['TL_LANG']['MSC']['nl_removed'];
         return true;
     }
     return false;
 }
开发者ID:heimrichhannot,项目名称:contao-newsletter_plus,代码行数:25,代码来源:Subscriber.php


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