本文整理汇总了PHP中JUtility::sendMail方法的典型用法代码示例。如果您正苦于以下问题:PHP JUtility::sendMail方法的具体用法?PHP JUtility::sendMail怎么用?PHP JUtility::sendMail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUtility
的用法示例。
在下文中一共展示了JUtility::sendMail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _actionRequest
protected function _actionRequest(KCommandContext $context)
{
if (!($email = KRequest::get('post.email', 'email'))) {
$this->setRedirect(KRequest::referrer(), JText::_('INVALID_EMAIL_ADDRESS'), 'error');
return false;
}
$user = $this->getService('com://site/users.model.users')->set('email', $email)->getItem();
if (!$user->id || $user->block) {
$this->setRedirect(KRequest::referrer(), JText::_('COULD_NOT_FIND_USER'), 'error');
return false;
}
$helper = $this->getService('com://site/users.helper.password');
$token = $helper->getHash($helper->getRandom());
$salt = $helper->getSalt($token);
$user->activation = md5($token . $salt) . ':' . $salt;
$user->save();
$configuration = JFactory::getConfig();
$site_name = $configuration->getValue('sitename');
$site_url = KRequest::url()->get(KHttpUrl::SCHEME | KHttpUrl::HOST | KHttpUrl::PORT);
$url = $site_url . JRoute::_('index.php?option=com_users&view=reset&layout=confirm');
$from_email = $configuration->getValue('mailfrom');
$from_name = $configuration->getValue('fromname');
$subject = JText::sprintf('PASSWORD_RESET_CONFIRMATION_EMAIL_TITLE', $site_name);
$body = JText::sprintf('PASSWORD_RESET_CONFIRMATION_EMAIL_TEXT', $site_name, $token, $url);
if (!JUtility::sendMail($from_email, $from_name, $email, $subject, $body)) {
$this->setRedirect(KRequest::referrer(), JText::_('ERROR_SENDING_CONFIRMATION_EMAIL'), 'error');
return false;
} else {
$this->_redirect = 'index.php?option=com_users&view=reset&layout=confirm';
}
}
示例2: sendEmail
function sendEmail()
{
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
$post = JRequest::get('post');
$this->addModelPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models');
$model = $this->getModel('location');
$location = $model->getData();
$contact_name = $post['contact_name'];
$contact_email = $post['contact_email'];
$contact_message = $post['contact_message'];
if ($contact_name == null || $contact_message == null) {
echo JText::_('Please enter a name and message to send.');
return false;
} else {
if (false) {
return false;
} else {
JUtility::sendMail($contact_email, $contact_name, $location->email, 'Contact Message for: ' . $location->name, $contact_message, 0, null, null, null, $contact_email, $contact_name);
echo JText::_('Message Sent');
return true;
}
}
return false;
}
示例3: testSendMail
/**
* Testing sendMail().
*
* @param array Input arguments for array
* @param array Arguments received by array
* @param bool Expected result of method call
*
* @return void
* @dataProvider casesSendMail
*/
public function testSendMail($args, $expectedArgs, $expResult)
{
$mockMailer = $this->getMock('JMail', array('sendMail'));
$mockMailer->expects($this->once())->method('sendMail')->with($this->equalTo($expectedArgs['from']), $this->equalTo($expectedArgs['fromname']), $this->equalTo($expectedArgs['recipient']), $this->equalTo($expectedArgs['subject']), $this->equalTo($expectedArgs['body']), $this->equalTo($expectedArgs['mode']), $this->equalTo($expectedArgs['cc']), $this->equalTo($expectedArgs['bcc']), $this->equalTo($expectedArgs['attachment']), $this->equalTo($expectedArgs['replyto']), $this->equalTo($expectedArgs['replytoname']))->will($this->returnValue($expResult));
JFactory::$mailer = $mockMailer;
$this->assertThat(JUtility::sendMail($args['from'], $args['fromname'], $args['recipient'], $args['subject'], $args['body'], $args['mode'], $args['cc'], $args['bcc'], $args['attachment'], $args['replyto'], $args['replytoname']), $this->equalTo($expResult));
}
示例4: save
function save()
{
// Check for request forgeries
JRequest::checkToken() or die('COM_JOOMLEAGUE_GLOBAL_INVALID_TOKEN');
$cid = JRequest::getInt("cid", 0);
$post = JRequest::get('post');
if ($cid > 0) {
$club =& JTable::getInstance("Club", "Table");
$club->load($cid);
$club->bind($post);
$params =& JComponentHelper::getParams('com_joomleague');
if ($club->store() && $params->get('cfg_edit_club_info_update_notify') == "1") {
$db = JFactory::getDBO();
$user = JFactory::getUser();
$query = "SELECT email\n FROM #__users \n WHERE usertype = 'Super Administrator' \n OR usertype = 'Administrator'";
$db->setQuery($query);
$to = $db->loadResultArray();
$subject = addslashes(sprintf(JText::_("COM_JOOMLEAGUE_ADMIN_EDIT_CLUB_INFO_SUBJECT"), $club->name));
$message = addslashes(sprintf(JText::_("COM_JOOMLEAGUE_ADMIN_EDIT_CLUB_INFO_MESSAGE"), $user->name, $club->name));
$message .= $this->_getShowClubInfoLink();
JUtility::sendMail('', '', $to, $subject, $message);
}
}
$this->setRedirect($this->_getShowClubInfoLink());
}
示例5: sendOnPageLoad
function sendOnPageLoad($max = 5)
{
$db = EasyBlogHelper::db();
$config = EasyBlogHelper::getConfig();
$sendHTML = $config->get('main_mailqueuehtmlformat', 0);
// Delete existing mails that has already been sent.
$query = 'DELETE FROM ' . $db->nameQuote('#__easyblog_mailq') . ' WHERE ' . $db->nameQuote('status') . '=' . $db->Quote(1) . ' AND DATEDIFF(NOW(), `created`) >= 7';
$db->setQuery($query);
$db->Query();
$query = 'SELECT `id` FROM `#__easyblog_mailq` WHERE `status` = 0';
$query .= ' ORDER BY `created` ASC';
$query .= ' LIMIT ' . $max;
$db->setQuery($query);
$result = $db->loadObjectList();
if (!empty($result)) {
foreach ($result as $mail) {
$mailq = EasyBlogHelper::getTable('MailQueue', 'Table');
$mailq->load($mail->id);
// update the status to 1 == proccessed
$mailq->status = 1;
if ($mailq->store()) {
// Send emails out.
if (EasyBlogHelper::getJoomlaVersion() >= '3.0') {
$mail = JFactory::getMailer();
$mail->sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
} else {
JUtility::sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
}
}
}
}
}
示例6: send
public function send( $max = 5 )
{
$konfig = Komento::getKonfig();
if( $konfig->get( 'disable_mailq' ) )
{
return false;
}
$db = Komento::getDBO();
$config = Komento::getConfig();
$sql = Komento::getSql();
$sql->select( '#__komento_mailq' )
->column( 'id' )
->where( 'status', 0 )
->order( 'created' )
->limit( $max );
$result = $sql->loadObjectList();
if(! empty($result))
{
foreach($result as $mail)
{
$mailq = Komento::getTable('mailq');
$mailq->load($mail->id);
$sendHTML = $mailq->type == 'html' ? 1 : 0;
$state = 0;
if( empty( $mailq->recipient ) )
{
$state = 1;
}
//send emails.
if( Komento::isJoomla15() )
{
$state = JUtility::sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
}
else
{
$mail = JFactory::getMailer();
$state = $mail->sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
}
if( $state )
{
// update the status to 1 == proccessed
$mailq->status = 1;
$mailq->store();
}
}
}
}
示例7: dispatchEmail
static function dispatchEmail($from, $fromname, $to_email, $subject, $body, $attachment = null)
{
if (!version_compare(JVERSION, '1.6.0', 'ge')) {
$sendresult =& JUtility::sendMail($from, $fromname, $to_email, $subject, $body, null, null, null, $attachment);
} else {
$sendresult =& JFactory::getMailer()->sendMail($from, $fromname, $to_email, $subject, $body, null, null, null, $attachment);
}
return $sendresult;
}
示例8: sendMail
/**
* Mail function (uses phpMailer)
*
* @param string $from From email address
* @param string $fromname From name
* @param mixed $recipient Recipient email address(es)
* @param string $subject Email subject
* @param string $body Message body
* @param boolean $mode False = plain text, true = HTML
* @param mixed $cc CC email address(es)
* @param mixed $bcc BCC email address(es)
* @param mixed $attachment Attachment file name(s)
* @param mixed $replyto Reply to email address(es)
* @param mixed $replytoname Reply to name(s)
*
* @return boolean True on success
*
* @see JMail::sendMail()
* @since 11.1
*/
public static function sendMail($from, $fromname, $recipient, $subject, $body, $mode = 0, $cc = null, $bcc = null, $attachment = null, $replyto = null, $replytoname = null)
{
if (version_compare(JVERSION, '2.5.0', '>=')) {
// Get a JMail instance
$mail = JFactory::getMailer();
//$mail->sendMail("webmaster@joomprod.com", "webmaster@joomprod.com", "webmaster@joomprod.com","je fais un test", "je fais un test", 1);
return $mail->sendMail($from, $fromname, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyto, $replytoname);
} else {
return JUtility::sendMail($from, $fromname, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, $replyto, $replytoname);
}
}
示例9: process
/**
* do the plugin action
* @return number of records updated
*/
function process(&$data)
{
$db = FabrikWorker::getDbo();
$sql = "SELECT n.*, e.event AS event, e.id AS event_id,
n.user_id AS observer_id, observer_user.name AS observer_name, observer_user.email AS observer_email,
e.user_id AS creator_id, creator_user.name AS creator_name, creator_user.email AS creator_email
FROM #__{package}_notification AS n".
"\n LEFT JOIN #__{package}_notification_event AS e ON e.reference = n.reference".
"\n LEFT JOIN #__{package}_notification_event_sent AS s ON s.notification_event_id = e.id".
"\n INNER JOIN #__users AS observer_user ON observer_user.id = n.user_id".
"\n INNER JOIN #__users AS creator_user ON creator_user.id = e.user_id".
"\n WHERE (s.sent <> 1 OR s.sent IS NULL)".
"\n AND n.user_id <> e.user_id".
"\n ORDER BY n.reference"; //don't bother informing users about events that they've created themselves
$db->setQuery($sql);
$rows = $db->loadObjectList();
$config = JFactory::getConfig();
$email_from = $config->getValue('mailfrom');
$sitename = $config->getValue('sitename');
$sent = array();
$usermsgs = array();
foreach ($rows as $row) {
/*
* {observer_name, creator_name, event, record url
* dear %s, %s has %s on %s
*/
$event = JText::_($row->event);
list($listid, $formid, $rowid) = explode('.', $row->reference);
$url = JRoute::_('index.php?option=com_fabrik&view=details&listid='.$listid.'&formid='.$formid.'&rowid='.$rowid);
$msg = JText::sprintf('FABRIK_NOTIFICATION_EMAIL_PART', $row->creator_name, $url, $event);
if (!array_key_exists($row->observer_id, $usermsgs )) {
$usermsgs[$row->observer_email] = array();
}
$usermsgs[$row->observer_email][] = $msg;
$sent[] = 'INSERT INTO #__{package}_notification_event_sent (`notification_event_id`, `user_id`, `sent`) VALUES ('.$row->event_id.', '.$row->observer_id.', 1)';
}
$subject = $sitename.": " .JText::_('FABRIK_NOTIFICATION_EMAIL_SUBJECT');
foreach ($usermsgs as $email => $messages) {
$msg = implode( ' ', $messages);
$res = JUtility::sendMail( $email_from, $email_from, $email, $subject, $msg, true);
}
if (!empty( $sent )) {
$sent = implode(';', $sent);
$db->setQuery($sent);
$db->query();
}
}
示例10: sendmail
function sendmail($JSecureConfig, $key)
{
$config = new JConfig();
$to = $JSecureConfig->emailid;
$to = $to ? $to : $config->mailfrom;
if ($to) {
$fromEmail = $config->mailfrom;
$fromName = $config->fromname;
$subject = $JSecureConfig->emailsubject;
$body = JText::_('BODY_MESSAGE:') . $_SERVER['REMOTE_ADDR'] . "<br/>";
$body .= JText::_(' USING KEY:') . $key;
JUtility::sendMail($fromEmail, $fromName, $to, $subject, $body, 1);
}
}
示例11: _sendReminderMail
/**
* Sends a username reminder to the e-mail address
* specified containing the specified username.
*
* @since 1.5
* @param string A user's e-mail address
* @param string A user's username
* @return bool True on success/false on failure
*/
function _sendReminderMail($email, $username)
{
$config =& JFactory::getConfig();
$uri =& JFactory::getURI();
$url = $uri->toString(array('scheme', 'host', 'port')) . JRoute::_('index.php?option=com_user&view=login', false);
$from = $config->getValue('mailfrom');
$fromname = $config->getValue('fromname');
$subject = JText::sprintf('USERNAME_REMINDER_EMAIL_TITLE', $config->getValue('sitename'));
$body = JText::sprintf('USERNAME_REMINDER_EMAIL_TEXT', $config->getValue('sitename'), $username, $url);
if (!JUtility::sendMail($from, $fromname, $email, $subject, $body)) {
$this->setError('ERROR_SENDING_REMINDER_EMAIL');
return false;
}
return true;
}
示例12: send
/**
* function to send mails (uses JUtility::sendMail in mambo 4.5.1 and later, falls back to phpmail if JUtility::sendMail doesn't exist
*
* @param string $fromMail
* @param string $fromName
* @param string $toMail
* @param string $subject
* @param string $body
* message to be send
*/
function send($fromMail, $fromName, $toMail, $subject, $body)
{
if (function_exists(JUtility::sendMail)) {
JUtility::sendMail($fromMail, $fromName, $toMail, $subject, $body);
} else {
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/plain; charset=\"utf-8\"\r\n";
$headers .= "From: {$fromName} <{$fromMail}>\r\n";
$headers .= "Reply-To: {$fromName} <{$fromMail}>\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-MSMail-Priority: Low\r\n";
$headers .= "X-Mailer: Kunena Forum\r\n";
mail($toMail, $subject, $body, $headers);
}
}
示例13: checkStartExtension
function checkStartExtension()
{
$option = JRequest::getCmd('option');
$mainframe =& JFactory::getApplication();
$user = JFactory::getUser();
$fileextension = JPATH_SITE . DS . 'tmp' . DS . 'lmoimport-2-0.txt';
$xmlfile = '';
if (!JFile::exists($fileextension)) {
$to = 'diddipoeler@gmx.de';
$subject = 'LMO-Import Extension';
$message = 'LMO-Import Extension wurde auf der Seite : ' . JURI::base() . ' gestartet.';
JUtility::sendMail('', JURI::base(), $to, $subject, $message);
$xmlfile = $xmlfile . $message;
JFile::write($fileextension, $xmlfile);
}
}
示例14: _sendEmail
function _sendEmail($subject, $body)
{
$jfbcLibrary = JFBConnectFacebookLibrary::getInstance();
$configModel = $jfbcLibrary->getConfigModel();
$toname = $configModel->getSetting('social_notification_email_address');
$toname = explode(',', $toname);
// Don't send emails to no one :)
if ($toname[0] == "") {
return;
}
$app =& JFactory::getApplication();
$sitename = $app->getCfg('sitename');
$mailfrom = $app->getCfg('mailfrom');
$fromname = $app->getCfg('fromname');
$subject = $subject . " - " . $sitename;
JUtility::sendMail($mailfrom, $fromname, $toname, $subject, $body);
}
示例15: emailCommunityAdmins
/**
* Sends an email to site administrators
*
* @param String $subject A string representation of the email subject.
* @param String $message A string representation of the email message.
**/
public static function emailCommunityAdmins($subject, $message)
{
$mainframe =& JFactory::getApplication();
$model = CFactory::getModel('Register');
$recipients = $model->getSuperAdministratorEmail();
$sitename = $mainframe->getCfg('sitename');
$mailfrom = $mainframe->getCfg('mailfrom');
$fromname = $mainframe->getCfg('fromname');
$subject = html_entity_decode($subject, ENT_QUOTES);
foreach ($recipients as $recipient) {
if ($recipient->sendEmail) {
$message = html_entity_decode($message, ENT_QUOTES);
JUtility::sendMail($mailfrom, $fromname, $recipient->email, $subject, $message);
}
}
return true;
}