當前位置: 首頁>>代碼示例>>PHP>>正文


PHP JMail類代碼示例

本文整理匯總了PHP中JMail的典型用法代碼示例。如果您正苦於以下問題:PHP JMail類的具體用法?PHP JMail怎麽用?PHP JMail使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了JMail類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: save

 public function save()
 {
     // Check for request forgeries
     JSession::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") {
             $user = JFactory::getUser();
             $db = JFactory::getDbo();
             $query = $db->getQuery(true);
             $query->select('u.email');
             $query->from('#__users AS u');
             $query->leftJoin('#__user_usergroup_map AS map ON map.user_id = u.id');
             $query->leftJoin('#__usergroups AS g ON g.id = map.group_id');
             $query->where('g.title = ' . $db->quote("Super Users") . ' OR g.title = ' . $db->quote("Administrator"));
             $query->order('u.username ASC');
             $db->setQuery($query);
             $to = $db->loadColumn();
             $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();
             JMail::sendMail('', '', $to, $subject, $message);
         }
     }
     $this->setRedirect($this->_getShowClubInfoLink());
 }
開發者ID:hfmprs,項目名稱:JoomLeague,代碼行數:31,代碼來源:clubinfo.php

示例2: testIsHTML

 /**
  * Tests the IsHTML method.
  *
  * @covers  JMail::IsHTML
  *
  * @return void
  */
 public function testIsHTML()
 {
     $returnedObject = $this->object->isHtml(false);
     $this->assertThat('text/plain', $this->equalTo($this->object->ContentType));
     // Test to ensure that a JMail object is being returned for chaining
     $this->assertInstanceOf('JMail', $returnedObject);
 }
開發者ID:ZerGabriel,項目名稱:joomla-platform,代碼行數:14,代碼來源:JMailTest.php

示例3: save

 public function save()
 {
     // Check for request forgeries
     JSession::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->loadColumn();
             $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();
             JMail::sendMail('', '', $to, $subject, $message);
         }
     }
     $this->setRedirect($this->_getShowClubInfoLink());
 }
開發者ID:Heart1010,項目名稱:JoomLeague,代碼行數:25,代碼來源:clubinfo.php

示例4: testAddReplyTo

 /**
  * Tests the addReplyTo method.
  * 
  * @covers  JMail::addReplyTo
  * 
  * @return void
  */
 public function testAddReplyTo()
 {
     $recipient = 'test@example.com';
     $name = 'test_name';
     $expected = array('test@example.com' => array('test@example.com', 'test_name'));
     $this->object->addReplyTo($recipient, $name);
     $this->assertThat($expected, $this->equalTo(TestReflection::getValue($this->object, 'ReplyTo')));
 }
開發者ID:nprasath002,項目名稱:joomla-platform,代碼行數:15,代碼來源:JMailTest.php

示例5: set_from

 /**
  * @param JMail $mail
  */
 private function set_from(&$mail)
 {
     $emailhelper = new FoxEmailHelper($this->Params);
     /** @var Joomla\Registry\Registry $config */
     $config = JComponentHelper::getParams("com_foxcontact");
     // Set a default value
     $default = (object) array("select" => "submitter", "email" => "", "name" => "");
     $adminemailfrom = $config->get("adminemailfrom", $default);
     $from = $emailhelper->convert($adminemailfrom);
     $mail->setSender($from);
     $adminemailreplyto = $config->get("adminemailreplyto", $default);
     $replyto = $emailhelper->convert($adminemailreplyto);
     // In Joomla 1.7 From and Reply-to fields is set by default to the Global admin email
     // but a call to setSender() won't change the Reply-to field
     $mail->ClearReplyTos();
     // addReplyTo() function expects an array(address, name) in Joomla 2, and two strings (address, name) in Joomla 3
     $mail->addReplyTo($replyto[0], $replyto[1]);
 }
開發者ID:HPReflectoR,項目名稱:GlavExpert,代碼行數:21,代碼來源:fadminmailer.php

示例6: send

 /**
  * @param  JMail  $mail
  * @param  array  $receivers
  *
  * @return boolean
  */
 public static function send(JMail $mail, array $receivers)
 {
     $config = KunenaFactory::getConfig();
     if (!empty($config->email_recipient_count)) {
         $email_recipient_count = $config->email_recipient_count;
     } else {
         $email_recipient_count = 1;
     }
     $email_recipient_privacy = $config->get('email_recipient_privacy', 'bcc');
     // If we hide email addresses from other users, we need to add TO address to prevent email from becoming spam.
     if ($email_recipient_count > 1 && $email_recipient_privacy == 'bcc' && JMailHelper::isEmailAddress($config->get('email_visible_address'))) {
         $mail->AddAddress($config->email_visible_address, JMailHelper::cleanAddress($config->board_title));
         // Also make sure that email receiver limits are not violated (TO + CC + BCC = limit).
         if ($email_recipient_count > 9) {
             $email_recipient_count--;
         }
     }
     $chunks = array_chunk($receivers, $email_recipient_count);
     $success = true;
     foreach ($chunks as $emails) {
         if ($email_recipient_count == 1 || $email_recipient_privacy == 'to') {
             echo 'TO ';
             $mail->ClearAddresses();
             $mail->addRecipient($emails);
         } elseif ($email_recipient_privacy == 'cc') {
             echo 'CC ';
             $mail->ClearCCs();
             $mail->addCC($emails);
         } else {
             echo 'BCC ';
             $mail->ClearBCCs();
             $mail->addBCC($emails);
         }
         try {
             $mail->Send();
         } catch (Exception $e) {
             $success = false;
             JLog::add($e->getMessage(), JLog::ERROR, 'kunena');
         }
     }
     return $success;
 }
開發者ID:anawu2006,項目名稱:PeerLearning,代碼行數:48,代碼來源:email.php

示例7: _sendReminderMail

 /**
  * Sends a username reminder to the e-mail address
  * specified containing the specified username.
  * @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('COM_CITRUSCART_CITRUSCART_USER_EMAIL_REMINDER', $config->getValue('sitename'));
     $body = JText::sprintf('COM_CITRUSCART_USERNAME_REMINDER_EMAIL_TEXT', $config->getValue('sitename'), $username, $url);
     if (!JMail::sendMail($from, $fromname, $email, $subject, $body)) {
         $this->setError('COM_CITRUSCART_ERROR_SENDING_REMINDER_EMAIL');
         return false;
     }
     return true;
 }
開發者ID:joomlacorner,項目名稱:citruscart,代碼行數:22,代碼來源:remind.php

示例8: testIsHtml

 /**
  * Tests the IsHTML method.
  *
  * @covers  JMail::IsHTML
  *
  * @return void
  */
 public function testIsHtml()
 {
     $this->object->isHtml(false);
     $this->assertThat('text/plain', $this->equalTo($this->object->ContentType));
 }
開發者ID:joomla-projects,項目名稱:media-manager-improvement,代碼行數:12,代碼來源:JMailTest.php

示例9: getMailer

 function getMailer()
 {
     if (!FSS_Settings::Get('email_send_override')) {
         $mailer = JFactory::getMailer();
         $mailer->setSender($this->Get_Sender());
         $mailer->CharSet = 'UTF-8';
         return $mailer;
     }
     $smtpauth = FSS_Settings::Get('email_send_smtp_auth') == 0 ? null : 1;
     $smtpuser = FSS_Settings::Get('email_send_smtp_username');
     // $conf->get('smtpuser');
     $smtppass = FSS_Settings::Get('email_send_smtp_password');
     // $conf->get('smtppass');
     $smtphost = FSS_Settings::Get('email_send_smtp_host');
     // $conf->get('smtphost');
     $smtpsecure = FSS_Settings::Get('email_send_smtp_security');
     // $conf->get('smtpsecure');
     $smtpport = FSS_Settings::Get('email_send_smtp_port');
     // $conf->get('smtpport');
     $mailfrom = FSS_Settings::Get('email_send_from_email');
     // $conf->get('mailfrom');
     $fromname = FSS_Settings::Get('email_send_from_name');
     // $conf->get('fromname');
     $mailer = FSS_Settings::Get('email_send_mailer');
     // $conf->get('mailer');
     // Create a JMail object
     $mail = new JMail();
     // Set default sender without Reply-to
     $mail->SetFrom(JMailHelper::cleanLine($mailfrom), JMailHelper::cleanLine($fromname), 0);
     // Default mailer is to use PHP's mail function
     switch ($mailer) {
         case 'smtp':
             $mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
             break;
         case 'sendmail':
             $mail->IsSendmail();
             break;
         default:
             $mail->IsMail();
             break;
     }
     $mail->CharSet = 'UTF-8';
     return $mail;
 }
開發者ID:vstorm83,項目名稱:propertease,代碼行數:44,代碼來源:mailer.php

示例10: _sendMail

 function _sendMail(&$user, $password)
 {
     $input = JFactory::getApplication()->input;
     global $mainframe;
     $db = JFactory::getDBO();
     $name = $user->get('name');
     $email = $user->get('email');
     $username = $user->get('username');
     $usersConfig = JComponentHelper::getParams('com_users');
     $sitename = $mainframe->getCfg('sitename');
     $useractivation = $usersConfig->get('useractivation');
     $mailfrom = $mainframe->getCfg('mailfrom');
     $fromname = $mainframe->getCfg('fromname');
     $siteURL = JURI::base();
     $subject = sprintf(JText::_('COM_CITRUSCART_ACCOUNT_DETAILS_FOR'), $name, $sitename);
     $subject = html_entity_decode($subject, ENT_QUOTES);
     if ($useractivation == 1) {
         $message = sprintf(JText::_('COM_CITRUSCART_SEND_MSG_ACTIVATE'), $name, $sitename, $siteURL . "index.php?option=com_user&task=activate&activation=" . $user->get('activation'), $siteURL, $username, $password);
     } else {
         $message = sprintf(JText::_('COM_CITRUSCART_SEND_MSG'), $name, $sitename, $siteURL);
     }
     $message = html_entity_decode($message, ENT_QUOTES);
     //get all super administrator
     $query = 'SELECT name, email, sendEmail' . ' FROM #__users' . ' WHERE LOWER( usertype ) = "super administrator"';
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     // Send email to user
     if (!$mailfrom || !$fromname) {
         $fromname = $rows[0]->name;
         $mailfrom = $rows[0]->email;
     }
     JMail::sendMail($mailfrom, $fromname, $email, $subject, $message);
     // Send notification to all administrators
     $subject2 = sprintf(JText::_('COM_CITRUSCART_ACCOUNT_DETAILS_FOR'), $name, $sitename);
     $subject2 = html_entity_decode($subject2, ENT_QUOTES);
     // get superadministrators id
     foreach ($rows as $row) {
         if ($row->sendEmail) {
             $message2 = sprintf(JText::_('COM_CITRUSCART_SEND_MSG_ADMIN'), $row->name, $sitename, $name, $email, $username);
             $message2 = html_entity_decode($message2, ENT_QUOTES);
             JMail::sendMail($mailfrom, $fromname, $row->email, $subject2, $message2);
         }
     }
 }
開發者ID:joomlacorner,項目名稱:citruscart,代碼行數:44,代碼來源:controller.php

示例11: send

 /**
  * Send the email
  *
  * @param JMail $mail Joomla mailer
  * @return bool true on success
  */
 protected function send(&$mail)
 {
     if (($error = $mail->Send()) !== true) {
         //$info = empty($mail->ErrorInfo) ? $error->getMessage() : $mail->ErrorInfo;
         // Obtaining the problem information from Joomla mailer is a nightmare
         if (is_object($error)) {
             // It is an instance of JError. Calls the getMessage() method
             $info = $error->getMessage();
         } else {
             if (!empty($mail->ErrorInfo)) {
                 // Send() returned false. If a $mail->ErrorInfo property is set, this is the cause
                 $info = $mail->ErrorInfo;
             } else {
                 // Send() returned false, but $mail->ErrorInfo is empty. The only reasonable cause can be $mailonline = 0
                 $info = JText::_("JLIB_MAIL_FUNCTION_OFFLINE");
             }
         }
         $msg = JText::_($GLOBALS["COM_NAME"] . "_ERR_SENDING_MAIL") . ". " . $info;
         $this->MessageBoard->Add($msg, FoxMessageBoard::error);
         $this->Logger->Write($msg);
         //JLog::add($msg, JLog::ERROR, get_class($this));
         return false;
     }
     //JLog::add("Email sent.", JLog::INFO, get_class($this));
     return true;
 }
開發者ID:HPReflectoR,項目名稱:GlavExpert,代碼行數:32,代碼來源:fdispatcher.php

示例12: createMailer

 /**
  * Create a mailer object
  *
  * @return  JMail object
  *
  * @see     JMail
  * @since   11.1
  */
 protected static function createMailer()
 {
     $conf = self::getConfig();
     $smtpauth = $conf->get('smtpauth') == 0 ? null : 1;
     $smtpuser = $conf->get('smtpuser');
     $smtppass = $conf->get('smtppass');
     $smtphost = $conf->get('smtphost');
     $smtpsecure = $conf->get('smtpsecure');
     $smtpport = $conf->get('smtpport');
     $mailfrom = $conf->get('mailfrom');
     $fromname = $conf->get('fromname');
     $mailer = $conf->get('mailer');
     // Create a JMail object
     $mail = JMail::getInstance();
     // Set default sender without Reply-to
     $mail->SetFrom(JMailHelper::cleanLine($mailfrom), JMailHelper::cleanLine($fromname), 0);
     // Default mailer is to use PHP's mail function
     switch ($mailer) {
         case 'smtp':
             $mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
             break;
         case 'sendmail':
             $mail->IsSendmail();
             break;
         default:
             $mail->IsMail();
             break;
     }
     return $mail;
 }
開發者ID:renzhewk,項目名稱:joomla-platform,代碼行數:38,代碼來源:factory.php

示例13: _createMailer

 /**
  * Create a mailer object
  *
  * @return  JMail object
  * @since   11.1
  */
 protected static function _createMailer()
 {
     jimport('joomla.mail.mail');
     $conf = self::getConfig();
     $sendmail = $conf->get('sendmail');
     $smtpauth = $conf->get('smtpauth') == 0 ? null : 1;
     $smtpuser = $conf->get('smtpuser');
     $smtppass = $conf->get('smtppass');
     $smtphost = $conf->get('smtphost');
     $smtpsecure = $conf->get('smtpsecure');
     $smtpport = $conf->get('smtpport');
     $mailfrom = $conf->get('mailfrom');
     $fromname = $conf->get('fromname');
     $mailer = $conf->get('mailer');
     // Create a JMail object
     $mail = JMail::getInstance();
     // Set default sender
     $mail->setSender(array($mailfrom, $fromname));
     // Default mailer is to use PHP's mail function
     switch ($mailer) {
         case 'smtp':
             $mail->useSMTP($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport);
             break;
         case 'sendmail':
             $mail->IsSendmail();
             break;
         default:
             $mail->IsMail();
             break;
     }
     return $mail;
 }
開發者ID:ramdesh,項目名稱:joomla-platform,代碼行數:38,代碼來源:factory.php

示例14: juserRegister

	public static function juserRegister($juser) {
		$result = array();
		$oseMscconfig = oseRegistry::call('msc')->getConfig('', 'obj');
		$config = JFactory::getConfig();
		$params = JComponentHelper::getParams('com_users');
		$newUserType = self::getNewUserType($params->get('new_usertype'));
		$juser['gid'] = $newUserType;
		$data = (array) self::getJuserData($juser);
		// Initialise the table with JUser.
		$user = new JUser;
		foreach ($juser as $k => $v) {
			$data[$k] = $v;
		}
		// Prepare the data for the user object.
		$useractivation = $params->get('useractivation');
		// Check if the user needs to activate their account.
		if (($useractivation == 1) || ($useractivation == 2)) {
			jimport('joomla.user.helper');
			$data['activation'] = JApplication::getHash(JUserHelper::genRandomPassword());
			$data['block'] = 1;
		}
		// Bind the data.
		if (!$user->bind($data)) {
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::sprintf('COM_USERS_REGISTRATION_BIND_FAILED', $user->getError());
		}
		// Load the users plugin group.
		JPluginHelper::importPlugin('user');
		if (!$user->save()) {
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['reload'] = ($oseMscconfig->error_registration == 'refresh') ? true : false;
			;
			$result['content'] = JText::_($user->getError());
		} else {
			// Mark the user_id in order to user in payment form
			if (($useractivation == 1) || ($useractivation == 2)) {
				$session = JFactory::getSession();
				$oseUser = array();
				$oseUser['user_id'] = $user->id;
				$oseUser['block'] = true;
				$oseUser['activation'] = true;
				$session->set('ose_user', $oseUser);
			}
			$result['success'] = true;
			$result['user'] = $user;
			$result['title'] = 'Done';
			$result['content'] = 'Juser saved successfully';
			// Compile the notification mail values.
			$data = $user->getProperties();
			$data['fromname'] = $config->get('fromname');
			$data['mailfrom'] = $config->get('mailfrom');
			$data['sitename'] = $config->get('sitename');
			$data['siteurl'] = JUri::base();
			if (JOOMLA16 == true) {
				// Handle account activation/confirmation emails.
				if ($useractivation == 2) {
					// Set the link to confirm the user email.
					$uri = JURI::getInstance();
					$base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
					$data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);
					$emailSubject = JText::sprintf('COM_USERS_OSEMSC_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
					$emailBody = JText::sprintf('COM_USERS_OSEMSC_EMAIL_REGISTERED_WITH_ADMIN_ACTIVATION_BODY', $data['name'], $data['sitename'],
							$data['siteurl'] . 'index.php?option=com_users&task=registration.activate&token=' . $data['activation'], $data['siteurl'], $data['username'],
							$data['password_clear']);
				} else if ($useractivation == 1) {
					// Set the link to activate the user account.
					$uri = JURI::getInstance();
					$base = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
					$data['activate'] = $base . JRoute::_('index.php?option=com_users&task=registration.activate&token=' . $data['activation'], false);
					$emailSubject = JText::sprintf('COM_USERS_OSEMSC_EMAIL_ACCOUNT_DETAILS', $data['name'], $data['sitename']);
					$emailBody = JText::sprintf('COM_USERS_OSEMSC_EMAIL_REGISTERED_WITH_ACTIVATION_BODY', $data['name'], $data['sitename'],
							$data['siteurl'] . 'index.php?option=com_users&task=registration.activate&token=' . $data['activation'], $data['siteurl'], $data['username'],
							$data['password_clear']);
				} else {
					$emailSubject = "";
					$emailBody = "";
				}
				// Send the registration email.
				if (!empty($emailSubject) && !empty($emailBody)) {
					if (JOOMLA30 == true) {
						$mailer = new JMail();
						$return = $mailer->sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $emailBody);
					} else {
						$return = JUtility::sendMail($data['mailfrom'], $data['fromname'], $data['email'], $emailSubject, $emailBody);
					}
				} else {
					$return = true;
				}
				// Check for an error.
				if ($return !== true) {
					$this->setError(JText::_('COM_USERS_REGISTRATION_SEND_MAIL_FAILED'));
					// Send a system message to administrators receiving system mails
					$db = JFactory::getDBO();
					$q = "SELECT id
						FROM #__users
						WHERE block = 0
						AND sendEmail = 1";
					$db->setQuery($q);
//.........這裏部分代碼省略.........
開發者ID:kosmosby,項目名稱:medicine-prof,代碼行數:101,代碼來源:oseMscPublic.php

示例15: sendEmail

 public static function sendEmail($from, $fromName, $replyTo, $toEmail, $cc, $bcc, $subject, $content, $isHtml)
 {
     jimport('joomla.mail.mail');
     $mail = new JMail();
     $mail->setSender(array($from, $fromName));
     if (isset($replyTo)) {
         $mail->addReplyTo($replyTo);
     }
     $mail->addRecipient($toEmail);
     if (isset($cc)) {
         $mail->addCC($cc);
     }
     if (isset($bcc)) {
         $mail->addBCC($bcc);
     }
     $mail->setSubject($subject);
     $mail->setBody($content);
     $mail->IsHTML($isHtml);
     $ret = $mail->send();
     $log = Logger::getInstance();
     $log->LogDebug("E-mail with subject " . $subject . " sent from " . $from . " to " . $toEmail . " " . serialize($bcc) . " result:" . $ret);
     return $ret;
 }
開發者ID:benji1979,項目名稱:teszt1,代碼行數:23,代碼來源:EmailService.php


注:本文中的JMail類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。