本文整理汇总了PHP中JFactory::getMailer方法的典型用法代码示例。如果您正苦于以下问题:PHP JFactory::getMailer方法的具体用法?PHP JFactory::getMailer怎么用?PHP JFactory::getMailer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFactory
的用法示例。
在下文中一共展示了JFactory::getMailer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Do a batch send
*/
function send($total = 100)
{
$mailqModel = CFactory::getModel('mailq');
$userModel = CFactory::getModel('user');
$mails = $mailqModel->get($total);
$jconfig = JFactory::getConfig();
$mailer = JFactory::getMailer();
$config = CFactory::getConfig();
$senderEmail = $jconfig->getValue('mailfrom');
$senderName = $jconfig->getValue('fromname');
if (empty($mails)) {
return;
}
CFactory::load('helpers', 'string');
foreach ($mails as $row) {
// @rule: only send emails that is valid.
// @rule: make sure recipient is not blocked!
$userid = $userModel->getUserFromEmail($row->recipient);
$user = CFactory::getUser($userid);
if (!$user->isBlocked() && !JString::stristr($row->recipient, 'foo.bar')) {
$mailer->setSender(array($senderEmail, $senderName));
$mailer->addRecipient($row->recipient);
$mailer->setSubject($row->subject);
$tmpl = new CTemplate();
$raw = isset($row->params) ? $row->params : '';
$params = new JParameter($row->params);
$base = $config->get('htmlemail') ? 'email.html' : 'email.text';
if ($config->get('htmlemail')) {
$row->body = JString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $row->body);
$mailer->IsHTML(true);
} else {
//@rule: Some content might contain 'html' tags. Strip them out since this mail should never contain html tags.
$row->body = CStringHelper::escape(strip_tags($row->body));
}
$tmpl->set('content', $row->body);
$tmpl->set('template', rtrim(JURI::root(), '/') . '/components/com_community/templates/' . $config->get('template'));
$tmpl->set('sitename', $config->get('sitename'));
$row->body = $tmpl->fetch($base);
// Replace any occurences of custom variables within the braces scoe { }
if (!empty($row->body)) {
preg_match_all("/{(.*?)}/", $row->body, $matches, PREG_SET_ORDER);
foreach ($matches as $val) {
$replaceWith = $params->get($val[1], null);
//if the replacement start with 'index.php', we can CRoute it
if (strpos($replaceWith, 'index.php') === 0) {
$replaceWith = CRoute::getExternalURL($replaceWith);
}
if (!is_null($replaceWith)) {
$row->body = JString::str_ireplace($val[0], $replaceWith, $row->body);
}
}
}
unset($tmpl);
$mailer->setBody($row->body);
$mailer->send();
}
$mailqModel->markSent($row->id);
$mailer->ClearAllRecipients();
}
}
示例2: send
function send($message)
{
global $mainframe;
if (empty($message)) {
$this->setError(JText::_('The alert is empty'));
return false;
}
if (is_array($message)) {
$message = implode('<br /><br />', $message);
}
$recepients = $this->_getEmailsToSend();
if (empty($recepients) || !count($recepients)) {
$this->setError(JText::_('No recepients for email or bad emails'));
}
$mail =& JFactory::getMailer();
$mail->addRecipient($recepients);
$sender = $this->_getSender();
$mail->setSender($sender);
$mail->addReplyTo($sender);
$mail->isHTML(true);
$params =& $this->_getParams();
$subject = $params->get('alerts_mail_subject', 'Mighty Defender alert');
$mail->setSubject($subject);
$mail->setBody($message);
if (!$mail->Send()) {
$this->setError(JText::_('Failed sending mail'));
return false;
}
return true;
}
示例3: sendVouchers
public function sendVouchers($cids)
{
$app = JFactory::getApplication();
$config = JFactory::getConfig();
$params = J2Store::config();
$sitename = $config->get('sitename');
$emailHelper = J2Store::email();
$mailfrom = $config->get('mailfrom');
$fromname = $config->get('fromname');
$failed = 0;
foreach ($cids as $cid) {
$voucherTable = F0FTable::getAnInstance('Voucher', 'J2StoreTable')->getClone();
$voucherTable->load($cid);
$mailer = JFactory::getMailer();
$mailer->setSender(array($mailfrom, $fromname));
$mailer->isHtml(true);
$mailer->addRecipient($voucherTable->email_to);
$mailer->setSubject($voucherTable->subject);
// parse inline images before setting the body
$emailHelper->processInlineImages($voucherTable->email_body, $mailer);
$mailer->setBody($voucherTable->email_body);
//Allow plugins to modify
J2Store::plugin()->event('BeforeSendVoucher', array($voucherTable, &$mailer));
if ($mailer->Send() !== true) {
$this->setError(JText::sprintf('J2STORE_VOUCHERS_SENDING_FAILED_TO_RECEIPIENT', $voucherTable->email_to));
$failed++;
}
J2Store::plugin()->event('AfterSendVoucher', array($voucherTable, &$mailer));
$mailer = null;
}
if ($failed > 0) {
return false;
}
return true;
}
示例4: onArrival
function onArrival($hookParameters, $workflow, $currentStation, $currentStep)
{
$pManager =& getPluginManager();
$pManager->loadPlugins('acl');
$tempResponse = null;
$tempResponse = $pManager->invokeMethod('acl', 'getUsers', array($workflow->acl), array($currentStation->group));
$userList = $tempResponse[$workflow->acl];
$tempResponse = $pManager->invokeMethod('acl', 'getUsers', array($workflow->acl), array($workflow->admin_gid));
$adminList = $tempResponse[$workflow->acl];
$mail = JFactory::getMailer();
if (intval($hookParameters->SendAdmin) && count($adminList)) {
$mail->IsHTML(true);
foreach ($adminList as $admin) {
$mail->AddRecipient($admin->email);
}
$mail->SetSubject(JText::_('Item moved'));
$translatedMessage = $this->_translate($hookParameters->AdminText, $hookParameters, $workflow, $currentStation, $currentStep);
$mail->SetBody($translatedMessage);
$mail->Send();
}
if (intval($hookParameters->SendUser) && count($userList)) {
$mail->IsHTML(true);
foreach ($userList as $user) {
$mail->AddRecipient($user->email);
}
$mail->SetSubject(JText::_('New task awaits'));
$translatedMessage = $this->_translate($hookParameters->UserText, $hookParameters, $workflow, $currentStation);
$mail->SetBody($translatedMessage);
$mail->Send();
}
}
示例5: sendMemberDaytimeToAdmin
function sendMemberDaytimeToAdmin($member_id, $service_id, $daytime_id)
{
define("BodyMemberDaytimeToAdmin", "<h1>Nouvelle inscription à une tranche horaire</h1><p>Un bénévole s'est inscrit à un secteur / tranche horaire.</p><p><strong>Nom :</strong> %s <br /><strong>Secteur :</strong> %s<br /><strong>Date :</strong> %s<br /><strong>Tranche horaire :</strong> %s</p><p><a href=\"" . JURI::root() . "/administrator/index.php?option=com_estivole&view=member&layout=edit&member_id=%s\">Cliquez ici</a> pour valider l'inscription et/ou recontacter le bénévole.</p>");
define("SubjectMemberDaytimeToAdmin", "Nouvelle inscription à une tranche horaire");
$db = JFactory::getDBO();
$query = $db->getQuery(TRUE);
$this->user = JFactory::getUser();
// Get the dispatcher and load the user's plugins.
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('user');
$data = new JObject();
$data->id = $this->user->id;
// Trigger the data preparation event.
$dispatcher->trigger('onContentPrepareData', array('com_users.profilestivole', &$data));
$userProfilEstivole = $data;
$userName = $userProfilEstivole->profilestivole['firstname'] . ' ' . $userProfilEstivole->profilestivole['lastname'];
$query->select('*');
$query->from('#__estivole_members as b, #__estivole_services as s, #__estivole_daytimes as d');
$query->where('b.member_id = ' . (int) $member_id);
$query->where('s.service_id = ' . (int) $service_id);
$query->where('d.daytime_id = ' . (int) $daytime_id);
$db->setQuery($query);
$mailModel = $db->loadObject();
$mail = JFactory::getMailer();
$mail->setBody(sprintf(constant("BodyMemberDaytimeToAdmin"), $userName, $mailModel->service_name, date('d-m-Y', strtotime($mailModel->daytime_day)), date('H:i', strtotime($mailModel->daytime_hour_start)) . ' - ' . date('H:i', strtotime($mailModel->daytime_hour_end)), $mailModel->member_id));
$mail->setSubject(constant("SubjectMemberDaytimeToAdmin"));
$mail->isHtml();
$recipient = array('benevoles@estivale.ch', $mailModel->email_responsable);
$mail->addRecipient($recipient);
$mail->Send('estivole@estivale.ch');
}
示例6: doExecute
/**
* Entry point for the script
*
*/
public function doExecute()
{
$mailfrom = JFactory::getConfig()->get('mailfrom');
$fromname = JFactory::getConfig()->get('fromname');
$db = JFactory::getDbo();
// Get plugin params
$query = $db->getQuery(true);
$query->select('params')->from('#__extensions')->where('element = ' . $db->quote('pfnotifications'))->where('type = ' . $db->quote('plugin'));
$db->setQuery($query);
$plg_params = $db->loadResult();
$params = new JRegistry();
$params->loadString($plg_params);
$limit = (int) $params->get('cron_limit');
// Get a list of emails to send
$query->clear();
$query->select('id, email, subject, message, created')->from('#__pf_emailqueue')->order('id ASC');
$db->setQuery($query, 0, $limit);
$items = $db->loadObjectList();
if (!is_array($items)) {
$items = array();
}
// Send and delete each email
foreach ($items as $item) {
$mailer = JFactory::getMailer();
$mailer->sendMail($mailfrom, $fromname, $item->email, $item->subject, $item->message);
$query->clear();
$query->delete('#__pf_emailqueue')->where('id = ' . (int) $item->id);
$db->setQuery($query);
$db->execute();
}
}
示例7: sendMail
/**
* Send email whith user data from form
*
* @param array $params An object containing the module parameters
*
* @access public
*/
public static function sendMail($params)
{
$sender = $params->get('sender');
$recipient = $params->get('recipient');
$subject = $params->get('subject');
// Getting the site name
$sitename = JFactory::getApplication()->get('sitename');
// Getting user form data-------------------------------------------------
$name = JFilterInput::getInstance()->clean(JRequest::getVar('name'));
$phone = JFilterInput::getInstance()->clean(JRequest::getVar('phone'));
$email = JFilterInput::getInstance()->clean(JRequest::getVar('email'));
$message = JFilterInput::getInstance()->clean(JRequest::getVar('message'));
// Set the massage body vars
$nameLabel = JText::_('MOD_JCALLBACK_FORM_NAME_LABEL_VALUE');
$phoneLabel = JText::_('MOD_JCALLBACK_FORM_PHONE_LABEL_VALUE');
$emailLabel = JText::_('MOD_JCALLBACK_FORM_EMAIL_LABEL_VALUE');
$messageLabel = JText::_('MOD_JCALLBACK_FORM_MESSAGE_LABEL_VALUE');
$emailLabel = $email ? "<b>{$emailLabel}:</b> {$email}" : "";
$messageLabel = $message ? "<b>{$messageLabel}:</b> {$message}" : "";
// Get the JMail ogject
$mailer = JFactory::getMailer();
// Set JMail object params------------------------------------------------
$mailer->setSubject($subject);
$params->get('useSiteMailfrom') ? $mailer->setSender(JFactory::getConfig()->get('mailfrom')) : $mailer->setSender($sender);
$mailer->addRecipient($recipient);
// Get the mail message body
require JModuleHelper::getLayoutPath('mod_jcallback', 'default_email_message');
$mailer->isHTML(true);
$mailer->Encoding = 'base64';
$mailer->setBody($body);
$mailer->Send();
// The mail sending errors will be shown in the Joomla Warning Message from JMail object..
}
示例8: sendEmail
function sendEmail()
{
global $mainframe;
$mail = JFactory::getMailer();
$modId = JRequest::getVar('modId');
$db = JFactory::getDBO();
$sql = "SELECT params FROM #__modules WHERE id={$modId}";
$db->setQuery($sql);
$data = $db->loadResult();
$params = json_decode($data);
$success = $params->success;
$failed = $params->failed;
$recipient = $params->email;
$email = JRequest::getVar('email');
$name = JRequest::getVar('name');
$subject = JRequest::getVar('subject');
$message = JRequest::getVar('message');
$sender = array($email, $name);
$mail->setSender($sender);
$mail->addRecipient($recipient);
$mail->setSubject($subject);
$mail->isHTML(true);
$mail->Encoding = 'base64';
$mail->setBody($message);
if ($mail->Send()) {
echo '<p class="sp_qc_success">' . $success . '</p>';
} else {
echo '<p class="sp_qc_warn">' . $failed . '</p>';
}
}
示例9: _send
/**
* {@inheritdoc}
*/
protected function _send()
{
$mailer = \JFactory::getMailer();
if (count($this->_recipient) == 2) {
$mailer->addRecipient($this->_recipient[0], $this->_recipient[1]);
}
if (count($this->_from) == 2) {
$mailer->setFrom($this->_from[0], $this->_from[1]);
}
$mailer->isHtml($this->_htmlMode);
$mailer->setBody($this->_body);
$mailer->setSubject($this->_subject);
foreach ($this->_atachments as $path => $name) {
$mailer->addAttachment($path, $name);
}
foreach ($this->_headers as $headerKey => $headerValue) {
$mailer->addCustomHeader($headerKey, $headerValue);
}
$result = $mailer->send();
if ($mailer->isError() || !$result) {
if ($mailer->ErrorInfo) {
$this->_error($mailer->ErrorInfo);
}
return false;
}
return $result;
}
示例10: Process
public function Process()
{
$mail = JFactory::getMailer();
$this->set_from($mail);
$this->set_to($mail, "to_address", "addRecipient");
$this->set_to($mail, "cc_address", "addCC");
$this->set_to($mail, "bcc_address", "addBCC");
$mail->setSubject($this->subject());
$body = $this->body();
$body .= $this->attachments($mail);
$body .= PHP_EOL;
// Info about url
$body .= JFactory::getConfig()->get("sitename") . " - " . $this->CurrentURL() . PHP_EOL;
// Info about client
$body .= "Client: " . $this->ClientIPaddress() . " - " . $_SERVER['HTTP_USER_AGENT'] . PHP_EOL;
$body = JMailHelper::cleanBody($body);
$mail->setBody($body);
$sent = $this->send($mail);
if ($sent) {
// Notify email send success
$this->MessageBoard->Add($this->Params->get("email_sent_text"), FoxMessageBoard::success);
$this->Logger->Write("Notification email sent.");
}
return $sent;
}
示例11: send_certificate
function send_certificate()
{
$app = JFactory::getApplication();
$params = $app->getParams();
$moodle_url = $params->get('MOODLE_URL');
$cert_id = JRequest::getVar('cert_id');
$simple = JRequest::getVar('simple');
$email = JRequest::getString('mailto', '', 'post');
$sender = JRequest::getString('sender', '', 'post');
$from = JRequest::getString('from', '', 'post');
$user = JFactory::getUser();
$username = $user->username;
$subject_default = JText::sprintf('COM_JOOMDLE_CERTIFICATE_EMAIL_SUBJECT', $user->name);
$subject = JRequest::getString('subject', $subject_default, 'post');
if (!$subject) {
$subject = $subject_default;
}
$mailer = JFactory::getMailer();
$config = JFactory::getConfig();
$sender = array($config->get('mailfrom'), $config->get('fromname'));
$mailer->setSender($sender);
$mailer->addRecipient($email);
$body = JText::sprintf('COM_JOOMDLE_CERTIFICATE_EMAIL_BODY', $user->name);
$mailer->setSubject($subject);
$mailer->setBody($body);
$session = JFactory::getSession();
$token = md5($session->getId());
$pdf = file_get_contents($moodle_url . '/auth/joomdle/' . $simple . 'certificate_view.php?id=' . $cert_id . '&certificate=1&action=review&username=' . $username . '&token=' . $token);
$tmp_path = $config->get('tmp_path');
$filename = 'certificate-' . $cert_id . '-' . $user->name . '.pdf';
file_put_contents($tmp_path . '/' . $filename, $pdf);
$mailer->addAttachment($tmp_path . '/' . $filename);
$send = $mailer->Send();
unlink($tmp_path . '/' . $filename);
if ($send !== true) {
JError::raiseNotice(500, JText::_('COM_JOOMDLE_EMAIL_NOT_SENT'));
} else {
?>
<div style="padding: 10px;">
<div style="text-align:right">
<a href="javascript: void window.close()">
<?php
echo JText::_('COM_JOOMDLE_CLOSE_WINDOW');
?>
<?php
echo JHtml::_('image', 'mailto/close-x.png', NULL, NULL, true);
?>
</a>
</div>
<h2>
<?php
echo JText::_('COM_JOOMDLE_EMAIL_SENT');
?>
</h2>
</div>
<?php
}
}
示例12: ActNotificaUtente
public static function ActNotificaUtente($array)
{
$mailer = JFactory::getMailer();
$config = JFactory::getConfig();
$sender = array($config->get('mailfrom'), $config->get('fromname'));
FB::log($sender, " sender ActNotificaUtente ");
$mailer->setSender($sender);
$db = JFactory::getDBO();
$query = "select b.id as id, b.name as nome, b.email as email, a.titolo as titolo\n from #__gg_contenuti a, #__users as b,#__gg_notifiche_utente_contenuti_map c\n where\n a.tipologia = c.idtipologiacontenuto\n and c.idutente = b.id\n and a.id = " . $array['id'];
FB::log($query, " ActNotificaUtente ");
$db->setQuery($query);
$result = $db->loadAssocList();
FB::log($result, " user ActNotificaUtente ");
//$mailer->addRecipient("roberto_setti@yahoo.it");
foreach ($result as $sender) {
FB::log(gglmsHelper::checkContenuto4Utente($sender['id'], $array['id']), " check user ActNotificaUtente ");
FB::log($sender, " sender dentro foreach ActNotificaUtente ");
if (gglmsHelper::checkContenuto4Utente($sender['id'], $array['id']) != 0) {
$mailer->addRecipient($sender['email']);
$body = "Gentile " . $sender['nome'] . " e' stato pubblicato in EdiAcademy un nuovo contenuto dal titolo: " . $sender['titolo'];
$mailer->setSubject('Notifica from EdiAcademy');
$mailer->setBody($body);
FB::log($mailer, " mailer ActNotificaUtente ");
$send = $mailer->Send();
if ($send !== true) {
echo 'Error sending email: ' . $send->__toString();
FB::log($send->__toString(), " error email send ");
}
FB::log($send, " send ActNotificaUtente ");
//exit();
$mailer->ClearAllRecipients();
}
}
}
示例13: sendMail
function sendMail()
{
$user_id = JRequest::getVar('user_id');
$filePath = JPATH_SITE . "/components/com_flexpaper/output/certificate.pdf";
$mailer =& JFactory::getMailer();
$config =& JFactory::getConfig();
//sender
$sender = array($config->getValue('config.mailfrom'), $config->getValue('config.fromname'));
$mailer->setSender($sender);
//recipient
$recipient = array($this->getEmail($user_id));
$mailer->addRecipient($recipient);
$body = "Your body string\nin double quotes if you want to parse the \nnewlines etc";
$mailer->setSubject('Your subject string');
$mailer->setBody($body);
// Optional file attached
$mailer->addAttachment($filePath);
$send =& $mailer->Send();
// echo "<pre>";
// print_r($send); die;
if ($send !== true) {
echo 'Error sending email: ' . $send->message;
} else {
echo 'Mail with certificate was sent on email address ' . $this->getEmail($user_id);
}
exit;
}
示例14: Process
public function Process()
{
$copy_to_submitter = (bool) JRequest::getVar($this->SafeName("copy_to_submitter" . $this->GetId()), NULL, 'POST') || $this->Params->get("copy_to_submitter", NULL) == 1;
if (!$copy_to_submitter || !isset($this->FieldsBuilder->senderEmail->b2jFieldValue) || empty($this->FieldsBuilder->senderEmail->b2jFieldValue)) {
$this->B2JSession->Clear('filelist');
return true;
}
$mail = JFactory::getMailer();
$mail->isHTML(true);
$this->set_from($mail);
$this->set_to($mail);
$mail->setSubject(JMailHelper::cleanSubject($this->Params->get("email_copy_subject", "")));
$body = $this->Params->get("email_copy_text", "") . PHP_EOL;
$body .= PHP_EOL;
if ($this->Params->get("email_copy_summary", NULL)) {
$body .= $this->body();
$body .= PHP_EOL;
$body .= $this->attachments();
$body .= PHP_EOL;
}
$body .= "------" . PHP_EOL . $this->Application->getCfg("sitename") . PHP_EOL;
$body = JMailHelper::cleanBody($body);
$mail->setBody($body);
$this->B2JSession->Clear('filelist');
$this->send($mail);
return true;
}
示例15: onPurchase
public function onPurchase($article_id = null, $user = null, $status = null)
{
// Load the article from the database
$db = JFactory::getDBO();
$db->setQuery('SELECT * FROM #__content WHERE id = ' . (int) $article_id);
$article = $db->loadObject();
if (empty($article)) {
return false;
}
// Parse the text a bit
$article_text = $article->introtext;
$article_text = str_replace('{name}', $user->name, $article_text);
$article_text = str_replace('{email}', $user->email, $article_text);
// Construct other variables
$config = JFactory::getConfig();
$sender = array($config->getValue('config.mailfrom'), $config->getValue('config.fromname'));
// Send the mail
jimport('joomla.mail.mail');
$mail = JFactory::getMailer();
$mail->setSender($sender);
$mail->addRecipient($user->email);
$mail->addCC($config->getValue('config.mailfrom'));
$mail->setBody($article_text);
$mail->setSubject($article->title);
$mail->isHTML(true);
$mail->send();
return true;
}