本文整理汇总了PHP中FabrikWorker::sendMail方法的典型用法代码示例。如果您正苦于以下问题:PHP FabrikWorker::sendMail方法的具体用法?PHP FabrikWorker::sendMail怎么用?PHP FabrikWorker::sendMail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FabrikWorker
的用法示例。
在下文中一共展示了FabrikWorker::sendMail方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAfterProcess
/**
* Run right at the end of the form processing
* form needs to be set to record in database for this to hook to be called
*
* @return bool
*/
public function onAfterProcess()
{
$params = $this->getParams();
$input = $this->app->input;
$formModel = $this->getModel();
if ($params->get('ask-receipt')) {
if (!array_key_exists('fabrik_email_copy', $_POST)) {
return;
}
}
$rowId = $input->get('rowid');
$config = JFactory::getConfig();
$w = new FabrikWorker();
$data = $this->getProcessData();
$message = $params->get('receipt_message');
$editURL = COM_FABRIK_LIVESITE . "index.php?option=com_" . $this->package . "&view=form&fabrik=" . $formModel->get('id') . "&rowid=" . $rowId;
$viewURL = COM_FABRIK_LIVESITE . "index.php?option=com_" . $this->package . "&view=details&fabrik=" . $formModel->get('id') . "&rowid=" . $rowId;
$editLink = "<a href=\"{$editURL}\">" . FText::_('EDIT') . "</a>";
$viewLink = "<a href=\"{$viewURL}\">" . FText::_('VIEW') . "</a>";
$message = str_replace('{fabrik_editlink}', $editLink, $message);
$message = str_replace('{fabrik_viewlink}', $viewLink, $message);
$message = str_replace('{fabrik_editurl}', $editURL, $message);
$message = str_replace('{fabrik_viewurl}', $viewURL, $message);
$message = $w->parseMessageForPlaceHolder($message, $data, false);
$to = $w->parseMessageForPlaceHolder($params->get('receipt_to'), $data, false);
$to = FabrikString::stripSpace($to);
if (empty($to)) {
/* $$$ hugh - not much point trying to send if we don't have a To address
* (happens frequently if folk don't properly validate their form inputs and are using placeholders)
* @TODO - might want to add some feedback about email not being sent
*/
return;
}
$to = explode(',', $to);
$subject = html_entity_decode($params->get('receipt_subject', ''));
$subject = JText::_($w->parseMessageForPlaceHolder($subject, $data, false));
$from = $config->get('mailfrom', '');
$fromName = $config->get('fromname', '');
// Darn silly hack for poor joomfish settings where lang parameters are set to override joomla global config but not mail translations entered
$rawConfig = new JConfig();
if ($from === '') {
$from = $rawConfig->mailfrom;
}
if ($fromName === '') {
$fromName = $rawConfig->fromname;
}
$from = $params->get('from_email', $from);
$res = FabrikWorker::sendMail($from, $fromName, $to, $subject, $message, true);
if (!$res) {
throw new RuntimeException('Couldn\'t send receipt', 500);
}
}
示例2: mailMerged
/**
* Sent mail merge
*
* @param $firstRow
* @param $mergedMsg
* @param $sent
* @param $notSent
*
* @return array
* @throws Exception
*/
private function mailMerged($firstRow, $mergedMsg, $sent, $notSent)
{
$params = $this->getParams();
$input = $this->app->input;
list($replyEmail, $replyEmailName) = $this->_replyEmailName($firstRow);
list($emailFrom, $fromName) = $this->_fromEmailName($firstRow);
$w = new FabrikWorker();
$toType = $this->_toType();
$to = $this->_to();
$oldStyle = $this->_oldStyle();
$toHow = $this->_toHow();
$mailTo = $toType == 'list' ? $firstRow->{$to} : $to;
$subject = $input->get('subject', '', 'string');
$thisTos = explode(',', $w->parseMessageForPlaceHolder($mailTo, $firstRow));
$thisSubject = $w->parseMessageForPlaceHolder($subject, $firstRow);
$preamble = $params->get('emailtable_message_preamble', '');
$postamble = $params->get('emailtable_message_postamble', '');
$mergedMsg = $preamble . $mergedMsg . $postamble;
$coverMessage = nl2br($input->get('message', '', 'html'));
$cc = null;
$bcc = null;
if (!$oldStyle) {
$mergedMsg = $coverMessage . $mergedMsg;
}
if ($toHow == 'single') {
foreach ($thisTos as $toKey => $thisTo) {
$thisTo = $w->parseMessageForPlaceholder($thisTo, $firstRow);
if (!FabrikWorker::isEmail($thisTo)) {
unset($thisTos[$toKey]);
$notSent++;
} else {
$mailTos[$toKey] = $thisTo;
}
}
if ($notSent > 0) {
$thisTos = array_values($thisTos);
}
$sent = count($thisTos);
if ($sent > 0) {
$res = FabrikWorker::sendMail($emailFrom, $fromName, $thisTos, $thisSubject, $mergedMsg, true, $cc, $bcc, $this->filepath, $replyEmail, $replyEmailName);
}
} else {
foreach ($thisTos as $thisTo) {
if (FabrikWorker::isEmail($thisTo)) {
$res = FabrikWorker::sendMail($emailFrom, $fromName, $thisTo, $thisSubject, $mergedMsg, true, $cc, $bcc, $this->filepath, $replyEmail, $replyEmailName);
if ($res) {
$sent++;
} else {
$notSent++;
}
} else {
$notSent++;
}
}
}
return array($sent, $notSent);
}
示例3: onAfterProcess
//.........这里部分代码省略.........
$emailToEval = $params->get('email_to_eval', '');
if (!empty($emailToEval)) {
$emailToEval = $w->parseMessageForPlaceholder($emailToEval, $this->data, false);
$emailToEval = @eval($emailToEval);
FabrikWorker::logEval($emailToEval, 'Caught exception on eval in email emailto : %s');
$emailToEval = explode(',', $emailToEval);
$emailTo = array_merge($emailTo, $emailToEval);
}
@(list($emailFrom, $emailFromName) = explode(":", $w->parseMessageForPlaceholder($params->get('email_from'), $this->data, false), 2));
if (empty($emailFrom)) {
$emailFrom = $this->config->get('mailfrom');
}
if (empty($emailFromName)) {
$emailFromName = $this->config->get('fromname', $emailFrom);
}
// Changes by JFQ
@(list($returnPath, $returnPathName) = explode(":", $w->parseMessageForPlaceholder($params->get('return_path'), $this->data, false), 2));
if (empty($returnPath)) {
$returnPath = null;
}
if (empty($returnPathName)) {
$returnPathName = null;
}
// End changes
$subject = $params->get('email_subject');
if ($subject == '') {
$subject = $this->config->get('sitename') . " :: Email";
}
$subject = preg_replace_callback('/&#([0-9a-fx]+);/mi', array($this, 'replace_num_entity'), $subject);
$attachType = $params->get('email_attach_type', '');
$attachFileName = $this->config->get('tmp_path') . '/' . uniqid() . '.' . $attachType;
$query = $this->_db->getQuery(true);
$emailTo = array_map('trim', $emailTo);
// Add any assigned groups to the to list
$sendTo = (array) $params->get('to_group');
$groupEmails = (array) $this->getUsersInGroups($sendTo, $field = 'email');
$emailTo = array_merge($emailTo, $groupEmails);
$emailTo = array_unique($emailTo);
// Remove blank email addresses
$emailTo = array_filter($emailTo);
$dbEmailTo = array_map(array($this->_db, 'quote'), $emailTo);
// Get an array of user ids from the email to array
if (!empty($dbEmailTo)) {
$query->select('id, email')->from('#__users')->where('email IN (' . implode(',', $dbEmailTo) . ')');
$this->_db->setQuery($query);
$userIds = $this->_db->loadObjectList('email');
} else {
$userIds = array();
}
// Send email
foreach ($emailTo as $email) {
$email = strip_tags($email);
if (FabrikWorker::isEmail($email)) {
$thisAttachments = $this->attachments;
$this->data['emailto'] = $email;
$userId = array_key_exists($email, $userIds) ? $userIds[$email]->id : 0;
$thisUser = JFactory::getUser($userId);
$thisMessage = $w->parseMessageForPlaceholder($message, $this->data, true, false, $thisUser);
$thisSubject = strip_tags($w->parseMessageForPlaceholder($subject, $this->data, true, false, $thisUser));
if (!empty($attachType)) {
if (JFile::write($attachFileName, $thisMessage)) {
$thisAttachments[] = $attachFileName;
} else {
$attachFileName = '';
}
}
$this->pdfAttachment($thisAttachments);
/*
* Sanity check for attachment files existing. Could have base folder paths for things
* like file upload elements with no file. As of J! 3.5.1, the J! mailer tosses an exception
* if files don't exist. We catch that in the sendMail helper, but remove non-files here anyway
*/
foreach ($thisAttachments as $aKey => $attachFile) {
if (!JFile::exists($attachFile)) {
unset($thisAttachments[$aKey]);
}
}
$res = FabrikWorker::sendMail($emailFrom, $emailFromName, $email, $thisSubject, $thisMessage, $htmlEmail, $cc, $bcc, $thisAttachments, $returnPath, $returnPathName);
/*
* $$$ hugh - added some error reporting, but not sure if 'invalid address' is the appropriate message,
* may need to add a generic "there was an error sending the email" message
*/
if ($res !== true) {
$this->app->enqueueMessage(JText::sprintf('PLG_FORM_EMAIL_DID_NOT_SEND_EMAIL', $email), 'notice');
}
if (JFile::exists($attachFileName)) {
JFile::delete($attachFileName);
}
} else {
$this->app->enqueueMessage(JText::sprintf('PLG_FORM_EMAIL_DID_NOT_SEND_EMAIL_INVALID_ADDRESS', $email), 'notice');
}
}
foreach ($this->deleteAttachments as $attachment) {
if (JFile::exists($attachment)) {
JFile::delete($attachment);
}
}
$this->updateRow();
return true;
}