本文整理汇总了PHP中Pimcore_Tool::getMail方法的典型用法代码示例。如果您正苦于以下问题:PHP Pimcore_Tool::getMail方法的具体用法?PHP Pimcore_Tool::getMail怎么用?PHP Pimcore_Tool::getMail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore_Tool
的用法示例。
在下文中一共展示了Pimcore_Tool::getMail方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: lostpasswordAction
public function lostpasswordAction()
{
$username = $this->_getParam("username");
if ($username) {
$user = User::getByName($username);
if (!$user instanceof User) {
$this->view->error = "user unknown";
} else {
if ($user->isActive()) {
if ($user->getEmail()) {
$token = Pimcore_Tool_Authentication::generateToken($username, $user->getPassword(), MCRYPT_TRIPLEDES, MCRYPT_MODE_ECB);
$protocol = "http://";
if (strpos(strtolower($_SERVER["SERVER_PROTOCOL"]), "https") === 0) {
$protocol = "https://";
}
$uri = $protocol . $_SERVER['SERVER_NAME'];
$loginUrl = $uri . "/admin/login/login/?username=" . $username . "&token=" . $token;
try {
$mail = Pimcore_Tool::getMail(array($user->getEmail()), "Pimcore lost password service");
$mail->setBodyText("Login to pimcore and change your password using the following link. This temporary login link will expire in 30 minutes: \r\n\r\n" . $loginUrl);
$mail->send();
$this->view->success = true;
} catch (Exception $e) {
$this->view->error = "could not send email";
}
} else {
$this->view->error = "user has no email address";
}
} else {
$this->view->error = "user inactive";
}
}
}
}
示例2: lostpasswordAction
public function lostpasswordAction()
{
$username = $this->_getParam("username");
if ($username) {
$user = User::getByName($username);
if (!$user instanceof User) {
$this->view->error = "user unknown";
} else {
if ($user->isActive()) {
if ($user->getEmail()) {
$token = Pimcore_Tool_Authentication::generateToken($username, $user->getPassword(), MCRYPT_TRIPLEDES, MCRYPT_MODE_ECB);
$uri = $this->getRequest()->getScheme() . "://" . $this->getRequest()->getHttpHost();
$loginUrl = $uri . "/admin/login/login/?username=" . $username . "&token=" . $token . "&reset=true";
try {
$mail = Pimcore_Tool::getMail(array($user->getEmail()), "Pimcore lost password service");
$mail->setIgnoreDebugMode(true);
$mail->setBodyText("Login to pimcore and change your password using the following link. This temporary login link will expire in 30 minutes: \r\n\r\n" . $loginUrl);
$mail->send();
$this->view->success = true;
} catch (Exception $e) {
$this->view->error = "could not send email";
}
} else {
$this->view->error = "user has no email address";
}
} else {
$this->view->error = "user inactive";
}
}
}
}
示例3: mail
/**
*
*/
public function mail()
{
$conf = Pimcore_Config::getSystemConfig();
if (!empty($conf->general->logrecipient)) {
Logger::debug(get_class($this) . ": detected log recipient:" . $conf->general->logrecipient);
$user = User::getById($conf->general->logrecipient);
Logger::debug(get_class($this) . ": detected log recipient:" . $user->getEmail());
if ($user instanceof User && $user->isAdmin()) {
$email = $user->getEmail();
Logger::debug(get_class($this) . ": user is valid");
if (!empty($email)) {
if (is_dir(PIMCORE_LOG_MAIL_TEMP)) {
Logger::debug(get_class($this) . ": detected mail log dir");
Logger::debug(get_class($this) . ": opening dir " . PIMCORE_LOG_MAIL_TEMP);
if ($handle = opendir(PIMCORE_LOG_MAIL_TEMP)) {
Logger::debug(get_class($this) . ": reading dir " . PIMCORE_LOG_MAIL_TEMP);
while (false !== ($file = readdir($handle))) {
Logger::debug(get_class($this) . ": detected file " . $file);
if (is_file(PIMCORE_LOG_MAIL_TEMP . "/" . $file) and is_writable(PIMCORE_LOG_MAIL_TEMP . "/" . $file)) {
$now = time();
$threshold = 1 * 60 * 15;
$fileModified = filemtime(PIMCORE_LOG_MAIL_TEMP . "/" . $file);
Logger::debug(get_class($this) . ": file is writeable and was last modified: " . $fileModified);
if ($fileModified !== FALSE and $fileModified < $now - $threshold) {
$mail = Pimcore_Tool::getMail(array($email), "pimcore log notification - " . $file);
$mail->setIgnoreDebugMode(true);
$mail->setBodyText(file_get_contents(PIMCORE_LOG_MAIL_TEMP . "/" . $file));
$mail->send();
@unlink(PIMCORE_LOG_MAIL_TEMP . "/" . $file);
Logger::debug(get_class($this) . ": sent mail and deleted temp log file " . $file);
} else {
if ($fileModified > $now - $threshold) {
Logger::debug(get_class($this) . ": leaving temp log file alone because file [ {$file} ] was written to within the last 15 minutes");
}
}
}
}
}
}
} else {
Logger::err(get_class($this) . ": Cannot send mail to configured log user [" . $user->getName() . "] because email is empty");
}
} else {
Logger::err(get_class($this) . ": Cannot send mail to configured log user. User is either null or not an admin");
}
} else {
Logger::debug(get_class($this) . ": No log recipient configured");
}
}
示例4: initLogger
/**
* @static
*
*/
public static function initLogger()
{
// try to load configuration
$conf = Pimcore_Config::getSystemConfig();
if ($conf) {
//firephp logger
if ($conf->general->firephp) {
$writerFirebug = new Zend_Log_Writer_Firebug();
$loggerFirebug = new Zend_Log($writerFirebug);
Logger::addLogger($loggerFirebug);
}
}
if (!is_file(PIMCORE_LOG_DEBUG)) {
if (is_writable(dirname(PIMCORE_LOG_DEBUG))) {
file_put_contents(PIMCORE_LOG_DEBUG, "AUTOCREATE\n");
}
}
if (is_writable(PIMCORE_LOG_DEBUG)) {
// check for big logfile, empty it if it's bigger than about 200M
if (filesize(PIMCORE_LOG_DEBUG) > 200000000) {
file_put_contents(PIMCORE_LOG_DEBUG, "");
}
$prioMapping = array("debug" => Zend_Log::DEBUG, "info" => Zend_Log::INFO, "notice" => Zend_Log::NOTICE, "warning" => Zend_Log::WARN, "error" => Zend_Log::ERR, "critical" => Zend_Log::CRIT, "alert" => Zend_Log::ALERT, "emergency" => Zend_Log::EMERG);
$prioConf = array();
$prios = array();
if ($conf && $conf->general->loglevel) {
$prioConf = $conf->general->loglevel->toArray();
if (is_array($prioConf)) {
foreach ($prioConf as $level => $state) {
if ($state) {
$prios[] = $prioMapping[$level];
}
}
}
} else {
// log everything if config isn't loaded (eg. at the installer)
foreach ($prioMapping as $p) {
$prios[] = $p;
}
}
if (!empty($prios)) {
$writerFile = new Zend_Log_Writer_Stream(PIMCORE_LOG_DEBUG);
$loggerFile = new Zend_Log($writerFile);
Logger::addLogger($loggerFile);
Logger::setPriorities($prios);
}
$conf = Pimcore_Config::getSystemConfig();
if ($conf) {
//email logger
if (!empty($conf->general->logrecipient)) {
$user = User::getById($conf->general->logrecipient);
if ($user instanceof User && $user->isAdmin()) {
$email = $user->getEmail();
if (!empty($email)) {
$mail = Pimcore_Tool::getMail(array($email), "pimcore log notification");
if (!is_dir(PIMCORE_LOG_MAIL_TEMP)) {
mkdir(PIMCORE_LOG_MAIL_TEMP, 0755, true);
}
$tempfile = PIMCORE_LOG_MAIL_TEMP . "/log-" . uniqid() . ".log";
$writerEmail = new Pimcore_Log_Writer_Mail($tempfile, $mail);
$loggerEmail = new Zend_Log($writerEmail);
Logger::addLogger($loggerEmail);
}
}
}
}
}
}